# Definite Integral [closed]

I am not able to do the following integration.

$$\begin{equation} \int_{0}^{a} x\sin^2 \left(\frac{n \pi x}{a} \right)dx \end{equation}$$

It shows an error that "more input is needed".

The mathematica code that I wrote is

R = Range[1, 10];
X = Integrate[x.[Sin[R.\[Pi].x/a]]^2, {x, 0, a}]

• Please copy the Mathematica code that you tried. – MelaGo Oct 6 '19 at 21:49
• Maybe you mean this: Integrate[x (Sin[n \[Pi] x/a])^2, {x, 0, a}] – MelaGo Oct 6 '19 at 22:02

Update: Evaluate for range of n

solution = Integrate[x*Sin[n*π*x/a]^2, {x, 0, a}]
Table[solution, {n, 0, 4}]

(* {Indeterminate, a^2/4, a^2/4, a^2/4, a^2/4} *)


Replace . with *.

Integrate[x*Sin[n*π*x/a]^2, {x, 0, a}]


$$-\frac{a^2 \left(-2 \pi ^2 n^2+2 \pi n \sin (2 \pi n)+\cos (2 \pi n)-1\right)}{8 \pi ^2 n^2}$$

• I want n to represent integers from 0 to some n. So the sin(2 \pi n) and Cos(2 \pi n) terms would take the respective values. – Khushal Oct 6 '19 at 22:07
• Sin[2 n π] is 0 for all n. Cos[2 n π] is 1 for all n. So the answer is a^2/4 for all integers n. – Rohit Namjoshi Oct 6 '19 at 22:18
• I get that. But I want to input this info in Mathematica. So that I get the final result. – Khushal Oct 6 '19 at 22:21
• Simplify[Integrate[x*Sin[n*\[Pi]*x/a]^2, {x, 0, a}], n \[Element] Integers] – march Oct 7 '19 at 4:05