Lösungen / Solutions

1

f[x_]:=1/2 (x+1)(x-1)(x-2); f[x]//Expand

Plot[f[x],{x,-2.2,3.2},Epilog->{PointSize[0.03],Point[{-2,f[-2]}],Point[{3,f[3]}],Line[{{-2,f[-2]},{3,f[3]}}],Line[{{-2,f[-2]},{3,f[-2]}}],Line[{{3,f[-2]},{3,f[3]}}]},PlotRange->All];

m = (f[3]-f[-2])/(3-(-2))

D[f[x],x]//Expand

D[f[x],x] /. x->-2

D[f[x],x]//Expand /. x->s

(D[f[x],x]//Expand) /. x->s

solv = Solve[((D[f[x],x]//Expand) /. x->s)==m,{s}]//Flatten

%//N

x1 = s /.solv[[1]]

x2 = s /.solv[[2]]

Plot[f[x],{x,-2.2,3.2},Epilog->{PointSize[0.03],Point[{-2,f[-2]}],Point[{3,f[3]}],Point[{x1,f[x1]}],Point[{x2,f[x2]}],Line[{{-2,f[-2]},{3,f[3]}}],Line[{{-2,f[-2]},{3,f[-2]}}],Line[{{3,f[-2]},{3,f[3]}}]},PlotRange->All];

2

Intervallschachtelung / Emboîtement

Remove["Global`*"]

x1[1]=0; x2[1]=Pi/2; 

f[x_]:=Cos[x]-1/2; 

xm[n_]:=(x1[n]+x2[n])/2;
Do[
	If[f[x1[n]] f[xm[n]]<0, 
		x1[n+1]=x1[n];x2[n+1]=xm[n];	
			Print["n = ", n , "  Approximation, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]},"  ", {x1[n],xm[n],x2[n]}//N ],
		If[f[x2[n]] f[xm[n]]<0,
			x2[n+1]=x2[n];x1[n+1]=xm[n]; 
				Print["n = ", n , "  Approximation, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]},"  ", {x1[n],xm[n],x2[n]}//N ], 
			Print["Nullstelle getroffen, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]} ] 
		]
	],
{n,1,20}]

FindRoot[f[x]==0,{x,0.5}]

Newton / Newton

Formel / Formule

Remove["Global`*"]

g[x_,n_,b_]:=(D[f[x],x]/.x->p[n]) x + b; g[x,m,b]

g[p[m],m,b]==f[p[m]]

solvN[m_]:= Solve[g[p[m],m,b]==f[p[m]],{b}]//Flatten; solvN[n]

g[x_,n_]:=g[x,n,b] /.solvN[n];  g[y,r]

solvM[m_]:=Solve[g[x,m]==0,{x}]//Flatten ; solvM[m]//Simplify

p[m+1]=x/. solvM[m] //Simplify

Iteration / Itération

f[x_]:=Cos[x]-0.5;  q[0]=0.5;

p[m_]:= (x - f[x]/(Evaluate[D[f[x],x]])) /. x-> q[m-1]; p[m]

p[1]

Do[q[n]=p[n]//N;p[n+1]//N;Print[q[n],"   ",p[n+1]]
,{n,1,10}]

Regula falsi / Regula falsi

Formel / Formule

Remove["Global`*"]

m = (f[x2]-f[x1])/(x2-x1); g[x_]:= m x + b; g[x]

solv= Solve[g[x1]==f[x1],{b}]//Flatten

g[x_]:= m x + b /. solv;  g[x]

Solve[g[x]==0,{x}]

Iteration / Itération

x1[1]=0//N; x2[1]=Pi/2 // N; 

f[x_]:=Cos[x]-1/2; 

xm[n_]:=(x2[n] f[x1[n]] - x1[n] f[x2[n]])/(f[x1[n]]-f[x2[n]]);
Do[
	If[f[x1[n]] f[xm[n]]<0, 
		x1[n+1]=x1[n];x2[n+1]=xm[n];	
			Print["n = ", n , "  Approximation, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]},"  ", {x1[n],xm[n],x2[n]}//N ],
		If[f[x2[n]] f[xm[n]]<0,
			x2[n+1]=x2[n];x1[n+1]=xm[n]; 
				Print["n = ", n , "  Approximation, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]},"  ", {x1[n],xm[n],x2[n]}//N ], 
			Print["Nullstelle getroffen, {x1[n],xm[n],x2[n]} = ", {x1[n],xm[n],x2[n]} ] 
		]
	],
{n,1,10}]

Fixpunkt / Emboîtement

Remove[f];

f[x_]:=Cos[x]-1/2;
f1[x_]:=f[x]+x;
Nest[f1,x,5]

Table[Nest[f1,0.5,n],{n,1,10}]

Fixpunkt System / Emboîtement système

Remove["Global`*"]

f1[x_,y_]:=Sin[x+y];  (* f[x,y] + x = f1[x,y] *)
g1[x_,y_]:=Cos[x-y];  (* g[x,y] + x = g1[x,y] *)

a[1]=0; b[1]=0; a[0]=0; b[0]=0;
a1[n_]:=f1[a[n-1],b[n-1]];
b1[n_]:=g1[a[n-1],b[n-1]];
a[1]

a1[1]

?Do

Do[a[n]=a1[n]//N;b[n]=b1[n]//N;Print[{a[n],b[n]}],{n,2,14}]

3

Remove["Global`*"]

f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0;
s=4;
solv=Solve[{f[0,a0,a1,a2,a3,a4,a5,a6]==0,f[1,a0,a1,a2,a3,a4,a5,a6]==1,f[2,a0,a1,a2,a3,a4,a5,a6]==2,f[3,a0,a1,a2,a3,a4,a5,a6]==3,f[4,a0,a1,a2,a3,a4,a5,a6]==s,f[5,a0,a1,a2,a3,a4,a5,a6]==5,f[6,a0,a1,a2,a3,a4,a5,a6]==6},{a0,a1,a2,a3,a4,a5,a6}] // Flatten;
f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0 /. solv;
Print[f[x,a0,a1,a2,a3,a4,a5,a6]];
Plot[f[x,a0,a1,a2,a3,a4,a5,a6],{x,-1,7},Epilog->{PointSize[0.03],Point[{0,0}],Point[{1,1}],Point[{2,2}],Point[{3,3}],Point[{4,s}],Point[{5,5}],Point[{6,6}]}];

f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0;
s=5;
solv=Solve[{f[0,a0,a1,a2,a3,a4,a5,a6]==0,f[1,a0,a1,a2,a3,a4,a5,a6]==1,f[2,a0,a1,a2,a3,a4,a5,a6]==2,f[3,a0,a1,a2,a3,a4,a5,a6]==3,f[4,a0,a1,a2,a3,a4,a5,a6]==s,f[5,a0,a1,a2,a3,a4,a5,a6]==5,f[6,a0,a1,a2,a3,a4,a5,a6]==6},{a0,a1,a2,a3,a4,a5,a6}] // Flatten;
f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0 /. solv;
Print[f[x,a0,a1,a2,a3,a4,a5,a6]];
Plot[{x,f[x,a0,a1,a2,a3,a4,a5,a6]},{x,-1,7},Epilog->{PointSize[0.03],Point[{0,0}],Point[{1,1}],Point[{2,2}],Point[{3,3}],Point[{4,s}],Point[{5,5}],Point[{6,6}]}];

f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0;
s=3;
solv=Solve[{f[0,a0,a1,a2,a3,a4,a5,a6]==0,f[1,a0,a1,a2,a3,a4,a5,a6]==1,f[2,a0,a1,a2,a3,a4,a5,a6]==2,f[3,a0,a1,a2,a3,a4,a5,a6]==3,f[4,a0,a1,a2,a3,a4,a5,a6]==s,f[5,a0,a1,a2,a3,a4,a5,a6]==5,f[6,a0,a1,a2,a3,a4,a5,a6]==6},{a0,a1,a2,a3,a4,a5,a6}] // Flatten;
f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0 /. solv;
Print[f[x,a0,a1,a2,a3,a4,a5,a6]];
Plot[{x,f[x,a0,a1,a2,a3,a4,a5,a6]},{x,-1,7},Epilog->{PointSize[0.03],Point[{0,0}],Point[{1,1}],Point[{2,2}],Point[{3,3}],Point[{4,s}],Point[{5,5}],Point[{6,6}]}];

f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0;
s=-6;
solv=Solve[{f[0,a0,a1,a2,a3,a4,a5,a6]==0,f[1,a0,a1,a2,a3,a4,a5,a6]==1,f[2,a0,a1,a2,a3,a4,a5,a6]==2,f[3,a0,a1,a2,a3,a4,a5,a6]==3,f[4,a0,a1,a2,a3,a4,a5,a6]==s,f[5,a0,a1,a2,a3,a4,a5,a6]==5,f[6,a0,a1,a2,a3,a4,a5,a6]==6},{a0,a1,a2,a3,a4,a5,a6}] // Flatten;
f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0 /. solv;
Print[f[x,a0,a1,a2,a3,a4,a5,a6]];
Plot[{x,f[x,a0,a1,a2,a3,a4,a5,a6]},{x,-1,7},Epilog->{PointSize[0.03],Point[{0,0}],Point[{1,1}],Point[{2,2}],Point[{3,3}],Point[{4,s}],Point[{5,5}],Point[{6,6}]}];

f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0;
s=-12;
solv=Solve[{f[0,a0,a1,a2,a3,a4,a5,a6]==0,f[1,a0,a1,a2,a3,a4,a5,a6]==1,f[2,a0,a1,a2,a3,a4,a5,a6]==2,f[3,a0,a1,a2,a3,a4,a5,a6]==3,f[4,a0,a1,a2,a3,a4,a5,a6]==s,f[5,a0,a1,a2,a3,a4,a5,a6]==5,f[6,a0,a1,a2,a3,a4,a5,a6]==6},{a0,a1,a2,a3,a4,a5,a6}] // Flatten;
f[x_,a0_,a1_,a2_,a3_,a4_,a5_,a6_]:=a6 x^6+ a5 x^5+ a4 x^4 + a3 x^3 + a2 x^2 + a1 x + a0 /. solv;
Print[f[x,a0,a1,a2,a3,a4,a5,a6]];
Plot[{x,f[x,a0,a1,a2,a3,a4,a5,a6]},{x,-1,7},Epilog->{PointSize[0.03],Point[{0,0}],Point[{1,1}],Point[{2,2}],Point[{3,3}],Point[{4,s}],Point[{5,5}],Point[{6,6}]}];