Allgemeine Lösungen wichtiger Differentialgleichungen mit der Maschine

a)    y'(x) + α  y(x) = f(x)

Remove["Global`*"];
solv1 = 
        DSolve[ y'[x] + α  y[x] == f[x], y, 
          x];
u[x_] := y /. solv1[[1]];
a = (u[x][x]  // 
                      InputForm)[[1]][[2]][[2]][[2]][[1]];
v[x_] := u[x][x] /. a -> t;
Print["y(x) = ", v[x]];
Print["     = ", v[x] // Simplify];
v[w] // Simplify

b)    y''(x) + α y'(x) + β  y(x) = f(x)

Gleichung

Remove["Global`*"];
solv2 = DSolve[y''[
                  x] + α y'[x] + β y[x] == f[x], y, 
            x][[1]];
u[x_] := y /. solv2[[1]];
a = u[
                    x][[2]][[3]][[2]][[2]][[1]];
b = u[
                    x][[2]][[4]][[2]][[2]][[1]];
v[
          x_] := u[x][x] /. {a -> t, 
            b -> t};
Print["y(x) = ", v[x]];
Print["     = ", v[x] // Simplify];
v[w] // Simplify

Wahl von Parametern  α = 2,  β = -1,  C[1] = 1,  C[2] = 1,  f(x) = cos(x),  Plot

Remove["Global`*"];
solv2 = DSolve[y''[
                  x] + α y'[x] + β y[x] == f[x], y, 
            x][[1]];
u[x_] := y /. solv2[[1]];
a = u[
                    x][[2]][[3]][[2]][[2]][[1]];
b = u[
                    x][[2]][[4]][[2]][[2]][[1]];
v[
          x_] := u[x][x] /. {a -> t, 
            b -> t};
s[u_] := 
        v[x]  /.  {x -> u,  α -> 
              2, β -> -1,  C[1] -> 1,  C[2] -> 1, 
            f[t] -> Cos[t]};
Print["y(x) = ",    s[x] // N // 
          Simplify];
Print["y(0) = ",    s[0] // N];
Print["y'(0) = ",   (D[s[m], m] /. m -> 0) // 
          N];
Plot[s[m], {m, 0, Pi}, AspectRatio -> 1];

Direkter Plot der exakten Lösung mit Ausgabe der Funktion

Remove["Global`*"];
solv = Flatten[DSolve[{y''[x]+2 y'[x]-1 y[x]==Cos[x],y[0]==2.86909,y'[0]==-4.80015},y,x]];
y = y/.solv;
Print["y(x) = ",Simplify[y[x]]];
Print["y(0) = ", y[0], " y'(0) = ",(D[y[x],x] /. x->0) //N];
Plot[y[x],{x,0,Pi},AspectRatio->1];
Plot[y[x],{x,0,4 Pi},AspectRatio->1];

Direkter Plot der numerischen Lösung

Remove["Global`*"];
solution=NDSolve[{y''[x]+2 y'[x]-1 y[x]==Cos[x],y[0]==2.86909,y'[0]==-4.80015},y,{x,0,4 Pi}];
Plot[y[x]/. solution,{x,0,Pi},AspectRatio->1];
Plot[y[x]/. solution,{x,0,4 Pi},AspectRatio->1];

Direkter Plot der exakten Lösung einer anderen D'Gl.

Remove["Global`*"];
solv = Flatten[DSolve[{y''[x] + y'[x] - y[x] ==Cos[x+1], y[0]==1, y'[0]==0},y,x]];
y = y/.solv;
Print["y(x) = ",Simplify[y[x]]];
Print["Numerisch y(x) = ",Simplify[y[x]]//N];
Plot[y[x],{x,0,Pi},AspectRatio->1];

p1=Plot[y[x],{x,0,Pi},AspectRatio->1];

Direkter Plot der exakten Lösung einer anderen D'Gl.

solv=Solve[λ^2+λ-1==0,{λ}][[1]];
loes1=λ /. solv;
loes1//TeXForm

solv=Solve[λ^2+λ-1==0,{λ}][[2]];
loes2=λ /. solv;
loes2//TeXForm

Remove[x,y,c1,c2]
solv = Flatten[DSolve[y''[x] + y'[x] - y[x]==0,y,x]];
y = y/.solv;
y[x]

Cos[x+1]//TrigExpand

solv3=Flatten[Simplify[Solve[{-2 r+s==Cos[1], -r-2s==-Sin[1]},{r,s}]]]

r=r /.solv3[[1]]; s=s /.solv3[[2]]

Remove[y];
y[x_,c1_,c2_]:= c1 E^(1/2(-1-Sqrt[5])x)+c2 E^(1/2(-1+Sqrt[5])x)+ r  Cos[x]+ s Sin[x];
y[x,c1,c2]//Simplify

y[x,c1,c2]

D[y[x,c1,c2],x]//Simplify

y[0,c1,c2]

(Simplify[D[y[x,c1,c2],x]]/.x->0)

solv=Flatten[Solve[Evaluate[{y[0,c1,c2]==1, (D[y[x,c1,c2],x]/.x->0)==0}],{c1,c2} ]]

c1=c1/.solv[[1]]//Simplify

c2=c2/.solv[[2]]//Simplify

y[x,c1,c2]

y[x,c1,c2]//Simplify

y[x,c1,c2]//N//Simplify

p2 = Plot[y[x,c1,c2],{x,0,Pi},AspectRatio->1];

Show[p1,p2];

Remove[x,y];
solv = Flatten[DSolve[{y''[x] + y'[x] - y[x] ==Cos[x+1], y[0]==1, y'[0]==0},y,x]];
y = y/.solv;
Print["y(x) = ",Simplify[y[x]]];
Print["Numerisch y(x) = ",Simplify[y[x]]//N];
Plot[y[x],{x,0,Pi},AspectRatio->1];

y[x]//Simplify//N