# How to write a code to solve my ODE problem?

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.

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}, y, x] And the constant of integration C can be determined by

eqn = Integrate[f[x]*Sin[n π x], {x, 0, 1}] == 0 // Simplify;
Solve[eqn, C] // Simplify As pointed out by Winther, the expression can be further simplified if n is an integer

Simplify[%, n ∈ Integers] • 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$. – Winther May 15 '16 at 23:48
• @Winther Thanks for pointing that out. – xslittlegrass May 16 '16 at 1:22
sol = DSolve[ {y''[x] + λ y[x] == B^3  Sin[Sqrt[λ] x]^3 , y == 0,
Integrate[y[z] Sin[n π z], {z, 0, 1}] == 0}, y[x], x];

y[x] /. sol 