5
$\begingroup$

I have the ODE:

$$y''+\lambda y = B^3\sin^3(\sqrt{\lambda}x) \ y(0)=0, \int_0^1 y(x)\sin(n\pi x)dx=0$$

I am not sure how to write the mathematica code to solve this ODE, obviously I need here DSolve but how to incorporate the integral condition?

Thanks.

$\endgroup$
9
$\begingroup$

The integral condition can be thought as a normalization condition to determine the constant of integration. For example

f = DSolveValue[{y''[x] + λ y[x] == B^3 Sin[Sqrt[λ] x]^3,y[0] == 0}, y, x]

enter image description here And the constant of integration C[2] can be determined by

eqn = Integrate[f[x]*Sin[n π x], {x, 0, 1}] == 0 // Simplify;
Solve[eqn, C[2]] // Simplify

enter image description here

As pointed out by Winther, the expression can be further simplified if n is an integer

Simplify[%, n ∈ Integers]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ It's very likely $n$ is an integer for this problem. In that case doing a Simplify[%, n \[Element] Integers] is also very useful to further simplify the expression since $\sin(n\pi) = 0$ and $\cos(n\pi) = (-1)^n$. $\endgroup$ – Winther May 15 '16 at 23:48
  • $\begingroup$ @Winther Thanks for pointing that out. $\endgroup$ – xslittlegrass May 16 '16 at 1:22
2
$\begingroup$
sol = DSolve[ {y''[x] + λ y[x] == B^3  Sin[Sqrt[λ] x]^3 , y[0] == 0, 
       Integrate[y[z] Sin[n π z], {z, 0, 1}] == 0}, y[x], x];

y[x] /. sol

Mathematica graphics

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.