modified newton's method

10 visualizzazioni (ultimi 30 giorni)
Robin
Robin il 30 Nov 2011
I am new to matlab. How do apply a formula to an equation? EX. formula: x(sub n)=x(sub n-1) - m (f(xsub n-1)/ f'(xsub n-1) to eqn f(x) = x^3 -3x^2 + 4 = 0

Risposte (1)

bym
bym il 1 Dic 2011
one way is to use anonymous functions:
f = @(x) x^3-3*x^2+4;
fprime = @(x) 3*x^2-6*x;
then use a for loop to perform the iteration
x = zeros(10,1);
x(1)=.1
for i = 1:9
x(i+1) = x(i)-f(x(i))./fprime(x(i));
end

Categorie

Scopri di più su Problem-Based Optimization Setup in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by