comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Solving a non-linear equation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Solving a non-linear equation [message #88242 is a reply to message #88241] Wed, 02 April 2014 08:36 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Wednesday, April 2, 2014 10:33:43 AM UTC-4, Reetsspacey wrote:
> Hi,
>
>
>
> My problem is this: I have a non-linear equation, of the form y = exp(x)+x. I have a large matrix of Y values, and for each cell (Y-value) I would like to calculate a best-fit X. How can I do this???

The easiest way is to use Newton's method.

If you're trying to find the root of f(x), given a trial solution of x0, the next best solution is,
x = x0 - f(x0) / f'(x0)
where f'(x0) is the derivative of the function. Now you have a new x0 and can try again for multiple iterations.

For you, this would be, in IDL language,
for i = 0, n_iter-1 do begin
x = x0 - (x + exp(x) - y)/(1 + exp(x))
x0 = x
endfor

Your function is very well behaved (no extrema) so you should be able to pick x0=0 as your starting point and then keep iterating until you achieve the desired precision.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: services provided by Al madinah international university for students
Next Topic: transfer the specific data in array A to array B

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:31:02 PDT 2025

Total time taken to generate the page: 0.00413 seconds