Ein wenig Numerik - Un peu de calcul numérique

Wurzel - Racine

Remove["`*"]

x^2=a, x=?,
2 x^2 = x^2 +x^2 = x^2 + a,
x= 1/2 (x+a/x),
x[n+1]=1/2 (x[n]+a/x[n]),

a=2;x[1]=1.5;
x[n_]:=1/2 (x[n-1]+a/x[n-1]);

a=2;x[1]=1.5;
x[n_]:=1/2 (x[n-1]+a/x[n-1]);
Table[{n,x[n]},{n,1,10}]//MatrixForm

Verschiedenes - Des choses diverses

Remove["`*"]

f[x_]:=(x^(E^x))^x;f[x]

f1[x_,e_]:=(f[x+e]-f[x])/e;  f1[x,e]

f1[2,e]

Plot[Evaluate[N[f1[2,e],10]],{e,-0.000001,0.000001},PlotRange->{639316,639317}];

N[f1[2,0.00000001],100]

?PlotRange

?*Precision*

D[f[x],x]

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

%//N

?Integrate

Integrate[x^2,x]

Integrate[x^2,{x,0,1}]

Integrate[Sin[x] x^2 + E^x /x ,x]

Integrate[Sin[x] x^2 ,x]

Integrate[E^x /x ,x]

Integrate[E^x /x ,{x,1,2}]

Integrate[E^x /x ,{x,1,2}]//N

Integrate[E^x /x ,{x,1,2}]//N //Chop

NIntegrate[E^x /x ,{x,1,2}]

f[x_]:=(x^(E^x))^x; f[x]

D[f[x],x]

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

(D[f[x],x] /. x->2)//N

f1[x_,Δx_]:=(f[x+Δx]-f[x])/Δx; f1[x,Δx]

f1[2,Δx]

Plot[ f1[2,Δx], {Δx,-0.1,0.1}];

Plot[ f1[2,Δx], {Δx,-0.000000001,0.000000001}];

?*Precision*

$MachinePrecision

Plot[ f1[2,Δx], {Δx,-0.000001,0.000001}];

Plot[ f1[2,Δx], {Δx,-0.000001,0.000001},PlotRange->{639315,639318}];

f1[2,0]

Limit[f1[2,Δx],Δx->0]

Limit[f1[2,Δx],Δx->0]//N

Some Orders

Remove["`*"]

Nest

Remove["`*"]

?Nest

Nest[f,x,4]

Nest[Sin,x,4]

p[n_]:=Plot[Nest[Sin,x,n],{x,0,4Pi}]; p[4];

Table[p[n],{n,0,100}];

FindRoot

Remove["`*"]

f[x_]:= 5 E^(-x^2) ArcCos[x]-Pi

Plot[f[x],{x,0,1}];

f[0.6]

?FindRoot

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

?FindRoot

N[FindRoot[f[x]==0,{x,0.6}],20]

f1[x_]:=Sin[1/x];

Plot[f1[x],{x,0,1}];

FindRoot[f1[x]==0,{x,0.0060}]

FindRoot[f1[x]==0,{x,0.0061}]

FindRoot[f1[x]==0,{x,0.0062}]

Plot[f1[x],{x,0.00600585,0.00624137}];

FindRoot - Newton

Remove["`*"]

f[x_]:=E^(-x^2)-0.5;
Plot[f[x],{x,-2,2}];

f[x]

Plot[f[x],{x,0.8,0.9}];

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

x[1] = 1

x[n_]:=x[n-1]-f[x[n-1]]/f'[x[n-1]];

x[5]

f'[z[n-1]]

D[f[z[n-1]],z[n-1]]

f[x_]:=E^(-x^2)-0.5;
Plot[f[x],{x,-2,2}];

f[x]

Plot[f[x],{x,0.8,0.9}];

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

f[z[n]]

f'[z[n]]

z[n_]:=z[n-1]-f[z[n-1]]/f'[z[n-1]];

z[1]=0.8;
Table[{n,z[n]},{n,1,10}] // MatrixForm

z[1]=0.2;
Table[{n,z[n]},{n,1,10}] // MatrixForm

z[1]=0.15;
Table[{n,z[n]},{n,1,10}] // MatrixForm

z[1]=0.1;
Table[{n,z[n]},{n,1,10}] // MatrixForm

z[1]=0.0;
Table[{n,z[n]},{n,1,10}] // MatrixForm

Fixpunkt u.a. - Point fix et autres

Remove["`*"]

?Do

?If

?While

?Nest

Nest[g,x,4]

g[x_]:=Sin[x]

Nest[g,x,10]

p[n_]:=Plot[Nest[Sin,x,n]/Nest[Sin,Pi/2,n],{x,0,2Pi},PlotRange->{-1,1}];

p[3];

Table[p[n],{n,1,100,4}];

Remove[g,x]

g[x_]:=-0.5 x(x-5)

Plot[{g[x],x},{x,-1,5},AspectRatio->Automatic];

Table[Nest[g,3.1,n],{n,1,20}] // MatrixForm

?AspectRatio

g[x_]:=E^-x

Table[Nest[g,3.1,n],{n,1,20}] // MatrixForm

g[x_]:=1/Log[x]

Table[Nest[g,3.1,n],{n,1,20}] // MatrixForm

f[x_]:=1/x^2 + 1

Table[Nest[f,1,n],{n,1,24}]//N // MatrixForm

Nest[f,1,25]//N

f[x_]:=2/x

Nest[f,1.5,10]//N

abs[x_ /; x > 0] := x;
abs[x_ /; x < 0] := -x;

f[x_] := 
      Log[Abs[x]] E^x  + E^(x^2)/x + x Sin[x] - Cos[x]/x

fa[x_] := 
        Log[x] E^x  + E^(x^2)/x + x Sin[x] - 
          Cos[x]/x;
fb[x_] := 
      Log[-x] E^x  + E^(x^2)/x + x Sin[x] - Cos[x]/x

Plot[{fa[x], f[b]}, {x, -2, 2}];

p1 = Plot[{fa[x]}, {x, 0, 2}];
p2 = Plot[{fb[x]}, {x, -2, 0}];

Show[p1, p2];

?fa

fa[x]

fa1[x_] := Evaluate[D[fa[x], x]]; fa1[x]

fb1[x_] := Evaluate[D[fb[x], x]]; fb1[x]

p1 = Plot[{fa1[x]}, {x, 0, 2}];
p2 = Plot[{fb1[x]}, {x, -2, 0}];

Show[p1, p2];

Remove[g]

g[x_]:=Cos[x];

nest[x_,n_]:=Nest[g,x,n];
nest[x,5]

nest[2,5] //N

p[n_]:= Plot[nest[x,n],{x,0,Pi/2},PlotRange->{0.5,1}]

Table[p[n],{n,2,100,2}];

g[x_]:=f[x]+x;

nest[x_,n_]:=Nest[g,x,n];
nest[x,5]

nest[2,5] //N

p[n_]:= Plot[nest[x,n],{x,0,Pi/2},PlotRange->{0.5,1}]

Table[p[n],{n,2,10,2}];

Table[{n,nest[0.8,n]},{n,1,10}] // MatrixForm

x2=x1-f[x1]/f'[x1]

Arbeit

Remove[f]

f[x_]:=E^(-x^2)-0.5;
Plot[f[x],{x,-2,2}];

x[n_]:=x[n-1]-f[x[n-1]]/f'[x[n-1]]

x[1]=0.9;
Table[x[n],{n,1,10}]

x[4]

Plot[f[x],{x,0.8,0.9}];

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

Hilfszone

h[x_]:=3x^4+x^2; {h'[x],D[h[x],x]}

?While

?Nest

g[n_,x_]:=Nest[Sin,x,n]

p[n_]:=Plot[g[n,x],{x,0,Pi},PlotRange->{0,1}]

Table[p[n],{n,1,100}];