Subject: Numerical Iteration From: Abdalla Mohamed Date: 28 Dec, 2008 02:16:01 Message: 1 of 4 Hello, I want to solve this equation using numerical iteration: x= ln ( (A*B - C*x)/C) * D Thanks in advance for anyone that helps.
 Subject: Numerical Iteration From: Roger Stafford Date: 28 Dec, 2008 03:07:01 Message: 2 of 4 "Abdalla Mohamed" wrote in message ... > Hello, > > I want to solve this equation using numerical iteration: > > x= ln ( (A*B - C*x)/C) * D > > Thanks in advance for anyone that helps.   One way is to use the Newton-Raphson method. Define f(x) as  f(x) = log((A*B-C*x)/C)*D-x Use your knowledge of calculus (or the Symbolic Toolbox) to compute the derivative, f'(x). Then make an initial guess, x(0), and start the iteration  x(n+1) = x(n) - f(x(n))/f'(x(n)) Keep it going until x(n) converges to some limiting value, and that value will be your solution, since f(x(n)) will necessarily have approached zero.   Hint: use a 'while' loop to accomplish this iteration using as its exiting condition whatever your criterion is for convergence.   Have you despaired of using the 'lambertw' function? It works pretty well. I've tried it. Roger Stafford
 Subject: Numerical Iteration From: Abdalla Mohamed Date: 28 Dec, 2008 05:14:01 Message: 3 of 4 "Roger Stafford" wrote in message ... > "Abdalla Mohamed" wrote in message ... > > Hello, > > > > I want to solve this equation using numerical iteration: > > > > x= ln ( (A*B - C*x)/C) * D > > > > Thanks in advance for anyone that helps. > > One way is to use the Newton-Raphson method. Define f(x) as > > f(x) = log((A*B-C*x)/C)*D-x > > Use your knowledge of calculus (or the Symbolic Toolbox) to compute the derivative, f'(x). Then make an initial guess, x(0), and start the iteration > > x(n+1) = x(n) - f(x(n))/f'(x(n)) > > Keep it going until x(n) converges to some limiting value, and that value will be your solution, since f(x(n)) will necessarily have approached zero. > > Hint: use a 'while' loop to accomplish this iteration using as its exiting condition whatever your criterion is for convergence. > > Have you despaired of using the 'lambertw' function? It works pretty well. I've tried it. > > Roger Stafford Hey Rogers, I wrote this code following ur instructions, given that i am a new user,and i am getting an error: A=3.9387; B=0.099077; C=2.5776; f(x)=log((A-x)/B)*C-x; %% Undefined function or variable 'x'. f1(x)=(-C/(A-x))-1; x(0)= 21.7; n=0:1:10; x(n+1) = x(n) - y(x(n))/y1(x(n));   Please help me debug this error, and also, is this going to function properly ? Thanks for your time
 Subject: Numerical Iteration From: Jean-Marc Gulliet Date: 28 Dec, 2008 07:58:04 Message: 4 of 4 Abdalla Mohamed wrote: > "Roger Stafford" wrote in message ... >> "Abdalla Mohamed" wrote in message ... >>> Hello, >>> >>> I want to solve this equation using numerical iteration: >>> >>> x= ln ( (A*B - C*x)/C) * D >>> >>> Thanks in advance for anyone that helps. >> One way is to use the Newton-Raphson method. Define f(x) as >> >> f(x) = log((A*B-C*x)/C)*D-x >> >> Use your knowledge of calculus (or the Symbolic Toolbox) to compute the derivative, f'(x). Then make an initial guess, x(0), and start the iteration >> >> x(n+1) = x(n) - f(x(n))/f'(x(n)) >> >> Keep it going until x(n) converges to some limiting value, and that value will be your solution, since f(x(n)) will necessarily have approached zero. >> >> Hint: use a 'while' loop to accomplish this iteration using as its exiting condition whatever your criterion is for convergence. >> >> Have you despaired of using the 'lambertw' function? It works pretty well. I've tried it. >> >> Roger Stafford > > > > Hey Rogers, > > I wrote this code following ur instructions, given that i am a new user,and i am getting an error: > > A=3.9387; > B=0.099077; > C=2.5776; > > f(x)=log((A-x)/B)*C-x; %% Undefined function or variable 'x'. > f1(x)=(-C/(A-x))-1;  > > x(0)= 21.7; How did you choose this initial value? Did you plot the function f(x)? Or is this just a typo and you meant 2.17? With the above values for A, B, and C, assuming you are looking for real values, the function f(x) is 2.5776*log(39.75392878-10.09315987*x)-x, and it is defined only when 39.75392878 - 10.09315987 * x < 0. > n=0:1:10; > x(n+1) = x(n) - y(x(n))/y1(x(n)); Looks like some typos here: y and y1 should be f and f1, shouldn't they? Also, note that Roger spoke about a *while* loop and you did not specify a convergence test (stopping criterion) either. > Please help me debug this error, and also, is this going to function properly ? > > Thanks for your time Regards, -- Jean-Marc

### Everyone's Tags:

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.