# Thread: Kind request for help

1. ## Kind 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 smix:

wherein sk:

k = 0 - 4
x is the 5 element vector, that has x0 - x4 elements
d is the 11 element coefficient vector, that has d0 - d10 elements
in the formula b is 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 bi element from the formula is b[i-1] in my program.
I could simply implement this, no big deal - unless xk would not equal 0... When xk = 0, the natural logarithm cannot be computed, so i must add some checking if xk = 0, if yes the program should skip computing ln(xk) (sk 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 few hours and because of that kinda frustrated. I will be very, very very grateful for help. Thanks in advance.

2. Split problem into many small ones. For example first part of Smix:
Code:
```double a = 0;
for(int i=0; <5; i++) {
a += x[i] * s[i];
}```
and so forth. Very mechanical way. Also I think math.h has natural logarithm function.

3. Originally Posted by zoom
I think math.h has natural logarithm function.
True. But if you write C++, you might want to include cmath, rather than math.h (which is what C programmers use)

4. Thanks for reply, but... I am still in the same point. I bet this can be done in some more "civilized" way, i mean compact/concise. For example with a combination of for and if instructions. And of course cmath has natural logarithm function.

5. I'd like to correct and clear some things in the description, sorry for the mess, I was a bit tired when posting. So here it is:

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

Any idea?