Message Boards Message Boards

Integrate this equation using the Wolfram Language?

Posted 8 years ago

Hi, I have problem to integrate this equation w.r.t. x.

Integrate[x^3/Sqrt[(1 - x) (1 - x a^2 Cos[\[Alpha]]) - 
  3 a x Log[x]], {x, 0, 1}]

Can anyone help me with this problem? Thanks in advance!

Attachments:
POSTED BY: Nurul Ainina
12 Replies

Hi Nurul,

sorry for this late response. If you are interested in accurate numerical results then the method shown by @Mariusz Iwaniuk will work perfect. One other option is an approximation which might be less accurate but gives an analytical expression. Here is a very simple approach:

One can sample the integrand function along the finite interval of integration; the sampling values still contain the undefined parameters! From these values one can create the InterpolatingPolynomial - which of course can be integrated analytically! Here is my tiny bit of code:

ClearAll["Global`*"]
(* the integrand: *)    
f[x_] := x^3/Sqrt[(1 - x) (1 - x a^2 Cos[\[Alpha]]) - 3 a x Log[x]]
(* sampling the interval between 0 and 1: *)    
samples = Simplify@Table[{x, f[x]}, {x, 0.01, .99, .08}];
ipp = InterpolatingPolynomial[samples, x];

Now the integration can be done analytically:

enter image description here

As you can see you end up with an analytical expression depending on the parameters only. If this approximation is not good enough, then just use more terms/samples.

Isn't Mathematica just great?!? Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 8 years ago

Hi Henrik!

Thank you very much for your response and sharing your code! Mathematica is great and so are you :)

POSTED BY: Nurul Ainina

Numeric solution.

ClearAll["Global`*"]
f[a_?NumericQ, \[Alpha]_?NumericQ] := NIntegrate[x^3/Sqrt[(1 - x)*(1 - x*a^2*Cos[\[Alpha]]) - 3*a*x*Log[x]], {x, 0, 1}]

for a=1 and alfa=Pi

a = 1;
\[Alpha] = Pi;
f[a, \[Alpha]]
(*0.422834*)

  Plot[Evaluate@Table[f[a, \[Alpha]], {\[Alpha], 0, Pi, Pi/4}], {a, 0, 5}, PlotLegends -> {"\[Alpha]=0", "\[Alpha]=Pi/4", "\[Alpha]=Pi/2", 
    "\[Alpha]=3Pi/4", "\[Alpha]=Pi"}, AxesLabel -> {a, f[a, \[Alpha]]}]
  Plot[Evaluate@Table[f[a, \[Alpha]], {a, 0, 3, 1/2}], {\[Alpha], 0, Pi}, PlotLegends -> {"a=0", "a=1/2", "a=1", "a=3/2", "a=2", "a=5/2",
     "a=3"}, AxesLabel -> {\[Alpha], f[a, \[Alpha]]}]

enter image description here

Plot3D[f[a, \[Alpha]], {a, 0, 3}, {\[Alpha], 0, Pi},  AxesLabel -> Automatic, PlotLegends -> {"Integral"}]

enter image description here

ParametricPlot3D[Evaluate[Table[{a, \[Alpha], f[a, \[Alpha]]}, {\[Alpha], 0, 3, 0.25}]], {a, 0, 3}, BoxRatios -> {1, 1, 1}, AxesLabel -> {"a", "\[Alpha]", "f[a,\[Alpha]]"}]

enter image description here

POSTED BY: Mariusz Iwaniuk
Posted 8 years ago

Thank you very much! I really appreciate your help!

POSTED BY: Nurul Ainina
Posted 8 years ago

Is it possible to get answer in term of a?

POSTED BY: Nurul Ainina

Ok.Maybe like this:

ClearAll["Global`*"]
\[Alpha] = Pi/4;
f[a_?NumericQ] :=  NIntegrate[x^3/Sqrt[(1 - x)*(1 - x*a^2*Cos[\[Alpha]]) - 3*a*x*Log[x]], {x, 0, 1}]
Plot[f[a], {a, 0, 5}, PlotLegends -> {"\[Alpha]=Pi/4"}, AxesLabel -> {a, f[a]}]

enter image description here

POSTED BY: Mariusz Iwaniuk
Posted 8 years ago

Hi, sorry for the hiatus.

What if I want to know the value of "a" if I prescribed the value of C? enter image description here

POSTED BY: Nurul Ainina
 ClearAll["Global`*"]
 Remove["Global`*"]

 f[a_?NumericQ] := NIntegrate[x^3/Sqrt[(1 - x)*(1 - x*a^2*Cos[\[Alpha]]) - 3*a*x*Log[x]], {x, 0, 1}]

 c = 0.7;
 \[Alpha] = Pi/4;

 sol1 = FindRoot[c == f[a], {a, 1/2}]
 (* {a -> 0.267439} *)

 sol2 = FindRoot[c == f[a], {a, 4}]
 (* {a -> 4.15722} *)

 Plot[{f[a], c}, {a, 0, 5}, PlotLegends -> {"\[Alpha]=Pi/4", "c"}, Epilog -> {Red, AbsolutePointSize[6], Point[{{a /. sol1, c}, {a /. sol2, c}}]}, 
 Prolog -> {Green, Line[{{a /. sol1, 0.4}, {a /. sol1, c + 0.1}}], Line[{{a /. sol2, 0.4}, {a /. sol2, c + 0.1}}]}, AxesLabel -> {a, f[a]}]

enter image description here

POSTED BY: Mariusz Iwaniuk
Posted 8 years ago

Wow! You are amazing! I have learned a lot from you! Thank you very much!

POSTED BY: Nurul Ainina

You're welcome. :)

POSTED BY: Mariusz Iwaniuk

This is just too complicated to integrate in closed form. Numerical integration will work.

POSTED BY: S M Blinder
Posted 8 years ago

Thank you for your comment :D

POSTED BY: Nurul Ainina
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract