-1
$\begingroup$

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}]
$\endgroup$
  • $\begingroup$ Please copy the Mathematica code that you tried. $\endgroup$ – MelaGo Oct 6 '19 at 21:49
  • $\begingroup$ Maybe you mean this: Integrate[x (Sin[n \[Pi] x/a])^2, {x, 0, a}] $\endgroup$ – MelaGo Oct 6 '19 at 22:02
0
$\begingroup$

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}$$

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Khushal Oct 6 '19 at 22:07
  • 1
    $\begingroup$ 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. $\endgroup$ – Rohit Namjoshi Oct 6 '19 at 22:18
  • $\begingroup$ I get that. But I want to input this info in Mathematica. So that I get the final result. $\endgroup$ – Khushal Oct 6 '19 at 22:21
  • $\begingroup$ Simplify[Integrate[x*Sin[n*\[Pi]*x/a]^2, {x, 0, a}], n \[Element] Integers] $\endgroup$ – march Oct 7 '19 at 4:05

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