I typed

== integral (e^cosx)((cosx)^2)(sinx) from x=0 to pi 

into Mathematica, but it doesn't seem to generate an answer. What did I do wrong?

I entered the query directly on the Wolfram|Alpha and there it did give an answer.

  • $\begingroup$ Syntax is wrong. Check help pages about 'Integrate' and functions. $\endgroup$ – Mariusz Iwaniuk Dec 29 '20 at 21:45
  • $\begingroup$ this is in the form for the wolfram alpha querie, so what is wrong with the syntax? a.e. ==integral (e^cosx)((cosx)^2) from x=0 to pi will give an answer but ==integral (e^cosx)((cosx)^2)(sinx) from x=0 to pi will not $\endgroup$ – apri Dec 29 '20 at 21:55
  • $\begingroup$ It works on WolframAlpha's web interface, but I agree that it doesn't work when I tried it in a notebook by invoking the Alpha interface with ==. Otherwise, in Mathematica use NIntegrate[E^Cos[x] Cos[x]^2 Sin[x], {x, 0, Pi}] which is honestly not that much more complex. You can also use Integrate instead of NIntegrate to receive a symbolic answer. $\endgroup$ – MarcoB Dec 29 '20 at 21:59
  • $\begingroup$ The reason why I want to use the alpha interface is for the 'step-by-step' function, if I only want an answer I could type =integral (e^cosx)((cosx)^2)(sinx) from x=0 to pi as well $\endgroup$ – apri Dec 29 '20 at 22:09

For some reason this works (in ver. 12.1) and gives the "Step-By-Step Solution" option: WolframAlpha["--Integrate[E^Cos[x]*Cos[x]^2*Sin[x], {x, 0, Pi}]"]
WolframAlpha["Integrate[E^Cos[x]*Cos[x]^2*Sin[x], {x, 0, Pi}]"]
does not.

  • $\begingroup$ This also works: WolframAlpha["1*Integrate[E^Cos[x]*Cos[x]^2*Sin[x], {x, 0, Pi}]"] $\endgroup$ – Rudy Potter Dec 29 '20 at 23:07
  • $\begingroup$ yes it works for in version 12.0 as well! $\endgroup$ – apri Dec 30 '20 at 0:29
  • $\begingroup$ I tried == 1*integral (e^cosx) ((cosx)^2) (sinx) from x = 0 to pi, and it works now, awesome! $\endgroup$ – apri Dec 30 '20 at 0:30
  • $\begingroup$ That's great! I'm still amazed it is ok not having a space between the trig functions and the x. $\endgroup$ – Rudy Potter Dec 30 '20 at 5:15

Alternatively, use the indefinite integral

sol = WolframAlpha[
  "integral (E^(cos x))((cos x)^2)(sin x) dx", {{"IndefiniteIntegral", 2}, 
   "Content"}, PodStates -> {"IndefiniteIntegral__Step-by-step solution"}]

enter image description here

From the first fundamental theorem of calculus

Subtract @@ ((-(1/2))*E^Cos[x]*
      (-(4*Cos[x]) + Cos[2*x] + 5) /. {{x -> Pi}, {x -> 0}})

(* -(5/E) + E *)


Integrate[E^Cos[x] Cos[x]^2 Sin[x], {x, 0, Pi}]

(* -(5/E) + E *)

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.