I'm confused. Is this a differential equation? Or are you setting the RHS equal to a number and solving for x?
Hi all,
I am trying to solve a non-linear equation with the following format:
f(x)=x/ (c+2^(x));
where c is a constant, and x is my variable.
Does anyone have any suggestion on how i can solve such equations?!
I have already tried using the "fsolve" function in Matlab, which works, but is not very suitable for this type of equations.
Any help is much appreciated.
Amir
Ok, so you're solving
for
Are there any restrictions on c?
You're dealing with a transcendental equation there. No exact method comes to mind. If c > 0, then the LHS is differentiable for all x. You could use Newton-Raphson on the function
Are you trying to find the solution for a particular c and y? Or are you more ambitious?
Hi Adrian,
That's correct, i am trying to solve x / (c+ 2^x) =y for x, where c>0 and y>0.
I am trying to solve for a particular value of c and y. In fact, the actual equation that i have is slightly more complex, but
i tried to keep it as simple as possible, to avoid any misunderstanding.
the exact equation is:
y=x / {c1+[(2^(x/c2)-1)/c3]}
where c1,c2,c3,y >0
I would still use Newton-Raphson. However, I would investigate the existence of solutions. For example, it doesn't look as though the equation with c1 = c2 = c3 = y = 1 has a real root. One avenue of thought here would be to find the maximum of your function, and find out when it's greater than zero. You might be able to use that to find conditions on your constants in order for a solution to exist. It makes no sense trying to find solutions that don't exist!
I have already verified the existence of solutions for this problem using the "fsolve" function in Matlab. However, i am trying to find alternative ways of tackling this problem, either using just maths or numerical methods.
I am not sure how familiar you are with the "fsolve" function in Matlab, but it requires a starting point for x. Due to the nature of the equation, different starting points give different results, which is why i am trying to find an alternative way of solving this function.
do you have any suggestions ?
many thanks
Well, from the graph, I think I would say that depending on the constants you have, more than one solution exists. It is in the nature of many numerical algorithms (e.g., Newton-Raphson) to converge to the closest solution. I don't think your problem is fsolve. I think your problem is knowing which solution you want. Or, if you want all of them, finding a way to pick your initial conditions so that you can capture all the solutions in multiple runs of fsolve. Do you follow me?. Due to the nature of the equation, different starting points give different results, which is why i am trying to find an alternative way of solving this function.
That is absolutely correct, my problem has 2 solutions and i need both of them. One of the issues is the starting point, which i can find by trial and error, or is there a more sophisticated method ?
In fact, the function i am working on is the summation of two functions, which are both very similar, y=A+B ( where i have only given A). SO the shape i get by plotting it is a circular shape, which is why for some values of x, i have 2 solutions.
do you think Newthon-Raphson is still the way forward?
If you're sure that your function always has two solutions (and depending on the values of the constants, I can believe that quite easily), then here's a sophisticated way to find both solutions. There's a local maximum between the two solutions. (I'm going off the graph here of one of the representative curves). So take the derivative of your function, and set it equal to zero. Finding that root might itself require Newton-Raphson; however, I think that in general you'll find two solutions: one at +infinity, which is no use to you, and one small positive solution. Next, for the original function, pick one starting point that is less than the local max by, say, 1, and one starting point that is greater than the local max by 1. I think that would be a better method of picking starting points than random guessing. If you're to the right of the local max, then Newton-Raphson should converge to the right root. If your starting point is to the left of the local max, then Newton-Raphson should converge to the left root. Make sense?