1
$\begingroup$

I have the following expression

a = 4 Cos[af / 2]^2; b = 1 - 5 Cos[af / 2]^2; c = Cos[af / 2]^2;
s = Sqrt[a*x^4 + b*x^2 + c]

and I need the integration of $s$ in terms of $x$ from $0$ to $1$ to get a function w.r.t. af only, so that I can analyze it and plot it.

I'm using the command

int1 = Simplify[ Integrate[s, {x, 0, 1}] ]

which gives me an error of sth like referencing some memory, I guess it's because it's out of memory?

So I tried int1 = Integrate[s, x] which gives me an expression involving the EllipticF function which I've not heard of, and the simplify command can't give me a simple form. Then I found that int1=0 when x=0, so the integral should equal to

up = int1 /. x -> 1

But this expression still involves the EllipticF function. I wonder if this integration is so complex? It's really out of my expectation, I thought it should be some simple problem that had appeared in the textbook..

Finally, if I have to use a numerical integration instead of symbolic, I wonder how I could plot $s$ w.r.t. $af$ in the range of $af$ in [0, Pi/2]? I tried the command

NIntegrate[s, {x, 0, 1}]  

which gives me the error:

the integrand Sqrt[Cos[af/2]^2+x^2 (1-5 Cos[Times[<<2>>]]^2)+4 x^4 \ Cos[af]^2] has evaluated to non-numerical values for all sampling \ points in the region with boundaries {{0,1}}. >>

Then I tried to plot using the function I called "up" (meaning the upper bound)

Plot[up, {af, 0, Pi/2}]

then it gives me a frame without any plot, don't know why.

Could someone help me on simplifying this expression, preferably symbolically, or generate the desired plot numerically?

P.S. The above problem comes from an expression

ww = Cos[t] Sqrt[Sin[af]^2 Sin[t]^2 + 4 Cos[af/2]^4 Cos[2 t]^2]
intw = Integrate[ww, {t, 0, Pi/2}]

So if the latter problem can be solved, the original problem is solved.

$\endgroup$
3
  • 3
    $\begingroup$ "It's really out of my expectation" - any integral involving the square root of a quartic polynomial is considered an elliptic integral, so that's why you get the functions you saw. $\endgroup$ Commented Jun 8, 2016 at 23:15
  • $\begingroup$ @J.M., thanks, I didn't know that... Anyway, seems the symbolic form is way too complex, so I'll refer to the numerical method offered by MarcoB. Thanks to you all! $\endgroup$
    – larry
    Commented Jun 9, 2016 at 21:49
  • $\begingroup$ Yes, since your goal is to maximize the function, the symbolic form isn't very helpful, since you'll end up with a nonlinear transcendental equation to solve anyway. $\endgroup$ Commented Jun 9, 2016 at 21:59

1 Answer 1

2
$\begingroup$

Here's a possible approach:

Clear[a, b, c, s, int]
a = 4 Cos[af/2]^2;
b = 1 - 5 Cos[af/2]^2;
c = Cos[af/2]^2;
s = Sqrt[a*x^4 + b*x^2 + c];

int[par_?NumericQ] := With[{integrand = s /. af -> par}, NIntegrate[integrand, {x, 0, 1}]]

Plot[int[af], {af, -2 Pi, 2 Pi}]

Mathematica graphics


Finding the maxima and minima using the int expression is also possible. Let's first isolate a region of interest. Inspection of the plot shows that the function is even and periodic, with period $2\pi$), so we can concentrate on the region $0\le\text{af}\le\pi$:

Plot[int[af], {af, 0, Pi + 1}]

plot for maxima

Using numerical optimizers:

NMinimize[{int[af], -0.5 <= af <= 0.5}, af]
NMaximize[{int[af], 1 <= af <= 1.5}, af]
NMinimize[{int[af], 3 <= af <= 4}, af]

(* Out:
{0.609476, {af -> 7.34092*10^-9}}
{0.631135, {af -> 1.04617}}
{0.5, {af -> 3.14159}}
*)

One can see that a local minimum is obtained at $\text{af}=0$, then the global maximum is obtained at $\text{af}=1.04617 \approx \pi/3$, and the global minimum at $\text{af}=3.14159 \approx \pi$. The corresponding values of the function are reported above as well.

$\endgroup$
3
  • $\begingroup$ Hi MarcoB, thanks, this works perfectly. But I wonder if I can get the value of af and int when it reaches its maximum or minimum? Thanks $\endgroup$
    – larry
    Commented Jun 8, 2016 at 22:51
  • $\begingroup$ @larry Yes, you can use the same int[af] numerical function to find the extrema. See the update at the bottom of my answer. $\endgroup$
    – MarcoB
    Commented Jun 8, 2016 at 23:13
  • $\begingroup$ this works great, thanks a lot! $\endgroup$
    – larry
    Commented Jun 9, 2016 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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