
February 17th, 2013, 04:52 AM
#1
Problem with implementation of the formula(e)  request for help
Hello everyone. I am new on the forum, and also quite new to c++. Currently I develop some computational program, and have a problem with implementation of the formula(s). Let me explain this. I want to obtain s_{mix}:
wherein s_{k}:
k = 0  4 (this is just naming for the 5 different substances, because the program computes some property of these substances, and the property of its mixture)
x is a scalar, there are 5 such a scalars (for every k), so I put them into one vector
dk, that is d0  d4 are the 11 element coefficient vectors
in the formula b is the 10 element vector, whose indexing begins from 1 (this is in the document from which the above formulas come), in the program indexing begins from 0, so b_{i} element from the formula is b[i1] in my program.
I could simply implement this, no big deal  unless x_{k} would not equal 0... When x_{k} = 0, the natural logarithm cannot be computed, so i must add some checking if x_{k} = 0, if yes the program should skip computing ln(x_{k}) (s_{k} should not be taken into account in that situation as well).
I have tried to implement for/if combination, but it seems to surpass me... So I am kindly asking you  people of good will  to help me resolve the problem. I am stuck with this for a "while" and because of that kinda frustrated. I will be very, very very grateful for help. Thanks in advance.

February 17th, 2013, 11:11 AM
#2
Re: Problem with implementation of the formula(e)  request for help
If you post the code you have for which you'd like some advice we'll offer our suggestions. If you do post, please format it before post and use code tags. Go Advanced, select code, click '#'

February 17th, 2013, 02:41 PM
#3
Re: Problem with implementation of the formula(e)  request for help

February 17th, 2013, 04:56 PM
#4
Re: Problem with implementation of the formula(e)  request for help
One possible simplification is that ln(T)^bi equals bi * ln(T). Then ln(T) becomes a constant of all summation terms and can be moved out and multiplied once only after summation.
Last edited by nuzzle; February 17th, 2013 at 05:02 PM.

February 17th, 2013, 07:54 PM
#5
Re: Problem with implementation of the formula(e)  request for help
Firstly, ln(T)^bi does not equal bi * ln(T). Secondly, ln(T)^bi was not a problem. The problem was ln(xk), since xk can be 0. But thanks for willingness to help I finally figured out the solution.

February 18th, 2013, 01:51 AM
#6
Re: Problem with implementation of the formula(e)  request for help
Originally Posted by Pederator
Firstly, ln(T)^bi does not equal bi * ln(T).
No, it's ln(T^bi) that equals bi*ln(T). Sorry for that. Glad you caught it.

February 18th, 2013, 11:51 AM
#7
Re: Problem with implementation of the formula(e)  request for help
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.
Featured
