modified newton's method

10 vues (au cours des 30 derniers jours)
Robin
Robin le 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

Réponses (1)

bym
bym le 1 Déc 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

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by