TU Wien:Computernumerik VU (Schranz-Kirlinger)/Übungen SS16/Beispiel 27
Zur Navigation springen
Zur Suche springen
Lösung[Bearbeiten | Quelltext bearbeiten]
Matlab Code
function Bsp7() x1 = 0.75; x2 = 2; x3 = 2; eps = 2; xnew =[x1;x2;x3]; for i=1:10 xold = xnew; x1 = xold(1); x2 = xold(2); x3 = xold(3); f = x1+x2+x3-3; g = x1*x2+x1*x3+x2*x3-(3-eps^2); h = x1*x2*x3-(eps^2-1); dfdx1 = 1; dfdx2 = 1; dfdx3 = 1; dgdx1 = x3+x2; dgdx2 = x3+x1; dgdx3 = x2+x1; dhdx1 = x2*x3; dhdx2 = x1*x3; dhdx3 = x1*x2; %Jacobimatrix J = [dfdx1 dfdx2 dfdx3; dgdx1 dgdx2 dgdx3; dhdx1 dhdx2 dhdx3]; xnew = xold - J\[f;g;h]; disp(sprintf('i=%0.1f, x1=%0.39f, x2=%f, x3=%f', i,xnew)); end end