Hi,
I am trying to solve a nonlinear equation using matlab. The function
that I am using is 'fzero'. I start with an initial guess 'x0'. Due to
the nature of the nonlinear equation, I always get the final answer
less than x0, which is physically meaningless.

There are values greater than x0 which satisfy the equation. However,
I always get lesser values. Could someone please tell me how to
write a code for that.

vinzybuoy,
Perhaps I should explain in more detail. Matlab's fzero uses Newton's method for solving the equation. If the equation has multiple roots then different starting values will in general tend to different roots. If you know what your function roughly looks like and understand graphically how Newton's method works you can choose your starting value so fzero tends to the root you are looking for.

GwynforWeb

0

vinzybuoyAuthor Commented:

Hi GwynforWeb,
If you need the nonlinear equations here it is. It is of the form:

y=f(Alpha)

These are the constants:

SPr = 15e-3;
Concen = 3.2;
T = 300;
z = 1;

Pi = 3.1415926;
kB = 1.381E-23;

B11 = -367e-20;
Eps = 78;
e = 1.602e-19;
d = 0.000000000405;
Eps_s = 35.4;

a=25e-20;
r=(a/Pi)^0.5;
k = ((8 * Pi * e * e) / (kB * T * Eps))^0.5;

%% C can vary from 0.1 to 10.0. It is a concentration value
%% of a compound. For different values of C, you will get
%% different values of Alpha. It is a inversely
%% proportionally relationship.

And this is the equation:

y=2 * log(C) - log(abs(1 / (Alpha - a))) - (a + 2 * Pi * r * r) / (Alpha - a) - ((Pi * a * r * r) / (Alpha - a) ^ 2) - (2 * B11 / Alpha) - 2 * z * log(abs(((sqrt(C3) * e * z / Alpha) + sqrt(1 + ((sqrt(C3) * e * z / Alpha)) ^ 2)))) - ((2 * C4) / C1) * ((z * e) ^ 2) / Alpha - 59;

Alpha is a parmeter which shud be greater than a=25e-20 and should not exceed abt 50e-20. But I always get values of Alpha less than a.

Can I define something in optimset so that Alpha is returned only when it is greater than a?
Also, could you pls explain me in "english", wht exactly is the meaning of TolX and TolFun in optimset? :)

thanx a lot!

0

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

vinzybuoy
You may be having round off errors, I will solve the system for all its roots this evening when I have time to check the roots are where you think they are. ( I have software to do that)

vinzybuoy,
The reason you are not getting any solutions in the ranges c=0.1 to 10 and alpha a=25e-20 to 50e-20 is that for the equation you have posted there are no solutions in that range. Are you meaning log to mean base 10 or e in your equation.

vinzybuoy
It does not matter if it is base e or 10. Here are some values of y(alpha)for different values of c and for Alpha from Alpha = 261E-20 at interavls of 2E-20. As you can see the function is no where near approaching zero

Try using x0 large and positive. Othwerwise show us what the nonlinear equation is there are other ways of doing this.

GwynforWeb