DSolve[{yy’‘’‘+Mu^2*yy’‘==0,
yy[0]==0,yy[l]==0,
yy’‘[0]==0, yy’'[l]==0},
yy,x]
returned result is {{yy(x)->0}}
But i want a solution like
yy[x] == C1*Sin[(C2*Pi)/l*x] (0 <= x <= l)
DSolve[{yy’‘’‘+Mu^2*yy’‘==0,
yy[0]==0,yy[l]==0,
yy’‘[0]==0, yy’'[l]==0},
yy,x]
returned result is {{yy(x)->0}}
But i want a solution like
yy[x] == C1*Sin[(C2*Pi)/l*x] (0 <= x <= l)
This post is tagged as a question, and the title is a question; but the code seems to be a solution. Is it good enough, or are you looking for some kind of help?
I removed the constants to make the ODE simple and used constants for initial conditions, which can be modified, accordingly.
(* 1st approach *)
dsolSDL03 = DSolve[
{D[y[x], {x, 4}] + D[y[x], {x, 2}] == 0,
y[0] == 4, y'[0] == 3, y''[0] == 2, y'''[0] == 1 },
{y}, {x, 0, 10}]
(* 2nd approach *)
dsolSDL04 = DSolve[
{D[y0[x], {x, 1}] == y1[x] (* 1st derivative of y[x] *),
D[y1[x], {x, 1}] == y2[x] (* 2nd derivative of y[x] *),
D[y2[x], {x, 1}] == y3[x] (* 3rd derivative of y[x] *),
D[y3[x], {x, 1}] == -y2[x] (* 4th derivative of y[x] *),
y0[0] == 4, y1[0] == 3, y2[0] == 2, y3[0] == 1 },
{y0, y1, y2, y3}, {x, 0, 10}]
{Plot[Evaluate[{y[x], y'[x], y''[x], y'''[x]} /. dsolSDL03], {x, 0, 10}],
Plot[Evaluate[{y0[x], y1[x], y2[x], y3[x]} /. dsolSDL04], {x, 0, 10}]}
I guess I could add that DSolve[] treats μ as a given parameter, not as an unknown to be solved for. The only solution that is generically true — that is, true for almost all values of μ and l — is the trivial solution. You have to take special steps, such as you’ve shown, to solve the eigenvalue problem. Was that what you were trying to demonstrate?
In the second order case DSolve provides conditions on the parameters:
DSolve[{yy''[x] + Mu^2*yy[x] == 0,
yy[0] == 0, yy[l] == 0},
yy[x], x]
In the fourth order case, we may impose the initial conditions first and the final conditions later:
sol0 = DSolve[{yy''''[x] + Mu^2*yy''[x] == 0,
yy[0] == 0, yy''[0] == 0}, yy, x]
conditionsAtL = {yy[l] == 0, yy''[l] == 0, Mu > 0, l > 0} /. sol0[[1]]
paramConditions = conditionsAtL // Solve
finalSols = yy[x] /. sol0 /. paramConditions
Thanks for the replies. Will try to understand them when i have more time then at the moment
Since DSolve[] won’t solve the eigenvalue problem by itself, one has to use Solve[] or something else to finish the job. Of course, there are different approaches and stages where one might do that.
Given the general solution to a linear ODE, the boundary conditions (BCs) lead to a linear problem plus a condition that defines the eigenvalues. The extra condition is usually nonlinear, which might complicate solving the problem. In the OP’s example, it’s a trigonometric equation that is readily solved.
DSolve[] will try to solve eigenvalue problems when there are exactly two boundary conditions, but that’s not the case in the problem at hand. Since there are four BCs, DSolve[] solves the system as a BVP, treating mu as a fixed parameter.
Note that the harmonic oscillator equation is handled as a special case by the eigenvalue-problem solver in DSolve[]. One advantage of the special handling is that you get one family of eigenvalues, instead of the two families that Solve[] and Reduce[] usually return when you solve Sin[u] == 0, one for u == 2n Pi (even multiplies) and one for u == (2n+1) Pi (odd multiples). In the approach below, we get two families of these types.
solToFunction = # /. {y_[x__] -> val_} :> {y -> Function[{x}, val]} &; (* utility *)
(* Set up the problem *)
ClearAll[yy, x, l, \[Mu]];
ode = yy''''[x] + \[Mu]^2 yy''[x] == 0;
bcs = {yy[0] == 0, yy[l] == 0, yy''[0] == 0, yy''[l] == 0};
(* get general solution *)
gensol = DSolve[ode, yy[x], x];
(* matrix of linear system from BCs == Part [[2]] *)
bcsys = CoefficientArrays[
Subtract @@@ First[bcs /. solToFunction@gensol], Array[C, 4]][[2]];
(* solve the boundary conditions *)
bcsol = Simplify[
Reduce[{
bcsys . Array[C, 4] == {0, 0, 0, 0}, (* solve for nullspace *)
Det[bcsys] == 0},(* nontrivial nullspace/eigenvalue condition *)
Array[C, 4]],
l > 0 && \[Mu] > 0] // (* extra conditions *)
(* solve for parameter mu and whichever C[k]'s Solve can *)
Solve[#, Array[C, 4]~Append~\[Mu]] &;
First[gensol] /. bcsol (* plug in values of parameters *)
Solve::svars: Equations may not give solutions for all “solve” variables.
The warning message is because Solve[] cannot solve for all the C[k] parameters of integration (C[2] in this case). That is, of course, exactly what we want to have happen.
To follow up on my remark about DSolve[] not solving for parameters, if one makes mu a dependent variable, then DSolve[] will solve for it. This can be done by replacing μ by μ[x] and adding the differential equation μ'[x] == 0. Unfortunately, the default solver uses inverse functions in this case. That yields only one solution, the trivial solution, instead of all solutions:
ode = yy''''[x] + \[Mu]^2 yy''[x] == 0;
bcs = {yy[0] == 0, yy[l] == 0, yy''[0] == 0, yy''[l] == 0};
DSolve[{ode /. \[Mu] -> \[Mu][x], \[Mu]'[x] == 0, bcs}, {yy[x], \[Mu][x]}, x,
Assumptions -> \[Mu][x] > 0 && l > 0]
(* `DSolve::ifun`: Inverse functions are being used by DSolve, so some solutions may not be found. *)
(* {{yy[x] -> 0, \[Mu][x] -> C[1]}} *)
However, we can use what is often called the Villegas-Gayley trick to adjust how Solve[] works:
Internal`InheritedBlock[{Solve},
Unprotect[Solve];
Solve[eq_, v_, opts___] /; ! TrueQ[$in] := Block[{$in = True},
Simplify@Solve[Flatten@{eq, $Assumptions}, v, Method -> Reduce, opts]];
Protect[Solve];
DSolve[{ode /. \[Mu] -> \[Mu][x], \[Mu]'[x] == 0, bcs}, {yy[x], \[Mu][x]}, x,
Assumptions -> \[Mu][x] > 0 && l > 0 && C[1] > 0]
]
(*
{{yy[x] -> 0, \[Mu][x] -> C[1]},
{yy[x] -> ConditionalExpression[
-((l^3*C[3] Sin[(2*Pi*x*C[6])/l])/(8*Pi^3*C[6]^3)),
Element[C[6], Integers] && C[6] >= 1],
\[Mu][x] -> ConditionalExpression[
(2*Pi*C[6])/l,
Element[C[6], Integers] && C[6] >= 1]},
{yy[x] -> ConditionalExpression[
-((l^3*C[3] Sin[(x*(Pi + 2*Pi*C[6]))/l])/(Pi^3*(1 + 2*C[6])^3)),
Element[C[6], Integers] && C[6] >= 0],
\[Mu][x] -> ConditionalExpression[
(Pi + 2*Pi*C[6])/l,
Element[C[6], Integers] && C[6] >= 0]}}
*)
The extra condition C[1] > 0 is not necessary but simplifies the output. It was added as an afterthought, after seeing \[Mu][x] was solved as \[Mu][x] -> C[1] in terms of C[1]. The assumption \[Mu][x] > 0 is not automatically extended to include C[1].
One could simplify the values in the solution to
C[3] Sin[2 π x C[6] / l] and
C[3] Sin[x (π + 2 π C[6]) / l],
if one wanted to. A general code to do so takes some work.
Im afraid that i have to revisit this issue later when i have gained more experience with Mathematica. I have much more experience with AMS on TI-89 and compatibles in Basic and also with lower level programming for that System in C but at the moment this ist to hard for me. I was thinking it would be much simpler, probably just something like adding an assumption.