Newton-raphson for a specific function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Emil G. P. Stender
el 18 de Sept. de 2015
Respondida: Emil G. P. Stender
el 25 de Sept. de 2015
I would like to use Newton raphson to solve the following equation:
(([L]_0*(1-injectvol/V)^n )-([M]_0*(1-(1-injectvol/V)^n ))*x )*(N-l*x )^l-k*x*(N-(l-1) x )^(l-1)=0.
where [L]_0, [M]_0, injectvol and V are known constants, n is a known variable and assuming values of N, k and l which are also constants.
With the following script:
dx=1; % Change in variable is set to a high value
x=input('Enter the initial estimate -> '); % Initial estimate
iter = 0; % Iteration counter
disp('iter Dc J dx x') % Heading for result
while abs(dx) >= 0.000001 && iter < 100 % Test for convergence
iter = iter + 1; % No. of iterations
Dc=(((L*(1-0.000006/0.000950)^(n))-(M*(1-(1-0.000006/0.000950)^(n)))*x)*(N-l*x)^(l)-k*x*(N-(l-1)*x)^(l-1)); % Residual
J = diff(Dc,x); % Derivative
dx= Dc/(J); %Change in variable
x=x+dx; % Successive solution
fprintf('%g', iter), disp([Dc, J, dx, x])
end
I keep getting an error:
Error in newtontest (line 9)
dx= Dc/(J); %Change in variable
can anyone help me with what is wrong?
best regards: Emil Stender
0 comentarios
Respuestas (2)
Jae Song
el 18 de Sept. de 2015
In the following line:
dx= Dc/(J);
if the computation of Dc/(J) is not matrix computation, you need to use ./
Dc./(J)
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!