1
$\begingroup$

I don't know how to find the following integral by numeric $$ \int_{g(\alpha)}^{h(\alpha)}f(\alpha,x)dx$$ where,say, $ f(\alpha ,x)=1-\alpha x+\sqrt{x}\alpha^2$ and $g(\alpha)=2\alpha^2-1$, $h(\alpha)=\sqrt{\alpha}+\alpha$ . I want to calculate the integral above in interval $1/40<\alpha<1/8$ in steps of 0.01 and create a table for computations.

Thanks.

$\endgroup$
  • 2
    $\begingroup$ Have you tried NIntegrate[]? $\endgroup$ – Feyre Feb 13 '17 at 15:04
  • $\begingroup$ You might consider accepting one of the answers, if one of them answers your question. $\endgroup$ – Michael E2 May 15 '17 at 10:16
1
$\begingroup$

Try this:

f[alpha_, x_] := 1 - x alpha + Sqrt[x] alpha^2;
g[alpha_] := 2 alpha^2 - 1;
h[alpha_] := Sqrt[alpha] + alpha;
Table[NIntegrate[f[alpha, x], {x, g[alpha], h[alpha]}], {alpha, 1/40.,1/8.,0.01}]
| improve this answer | |
$\endgroup$
1
$\begingroup$
f[a_, x_] = 1 - a x + Sqrt[x] a^2;

g[a_] = 2 a^2 - 1;

h[a_] = Sqrt[a] + a;

int[a_] = 
 Assuming[{1/40 < a < 1/8}, Integrate[f[a, x], {x, g[a], h[a]}]]

(*  1 + Sqrt[a] + (3*a)/2 - (5*a^2)/2 - 
   a^(5/2) - (5*a^3)/2 + 2*a^5 + 
   (2/3)*a^2*(a*Sqrt[Sqrt[a] + a] + 
        I*(1 - 2*a^2)^(3/2) + 
        Sqrt[a^(3/2) + a^2])  *)

Plot[Evaluate@ReIm[int[a]], {a, 1/40, 1/8},
 PlotLegends -> {Re, Im},
 AxesLabel -> {a, None},
 Epilog -> Inset[
   LogPlot[
    Evaluate@ReIm[int[a]], {a, 1/40, 1/8},
    PlotLabel -> "LogPlot"],
   {0.09, 2/3}]]

enter image description here

Table[{a, int[a]}, {a, 1/40., 1/8., 0.01}] // Grid

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ i've said that the $\alpha$ values are discrete and obtain a numerical integration then each computations of $\alpha$ is inserted into a table. $\endgroup$ – Ali184 Feb 14 '17 at 5:43
  • $\begingroup$ very thanks for your complete answer. $\endgroup$ – Ali184 Feb 14 '17 at 7:07
0
$\begingroup$

If it is possible to get a closed form for the integral that is preferable as it simplifies the downstream processing. Note: this is not always possible.

Integrate[f[alpha, x], {x, g[alpha], h[alpha]}, 
 Assumptions -> 1/40 <= alpha <= 1/8]

(* 1 + Sqrt[alpha] + (3 alpha)/2 - (5 alpha^2)/2 - alpha^(
 5/2) - (5 alpha^3)/2 + 2 alpha^5 + 
 2/3 alpha^2 (alpha Sqrt[Sqrt[alpha] + alpha] + 
    I (1 - 2 alpha^2)^(3/2) + Sqrt[alpha^(3/2) + alpha^2]) *)

Now define a function, f2

f2[alpha_] := 
 1 + Sqrt[alpha] + (3 alpha)/2 - (5 alpha^2)/2 - alpha^(5/2) - (
  5 alpha^3)/2 + 2 alpha^5 + 
  2/3 alpha^2 (alpha Sqrt[Sqrt[alpha] + alpha] + 
     I (1 - 2 alpha^2)^(3/2) + Sqrt[alpha^(3/2) + alpha^2])

To generate the table

Table[{alpha, N@f2[alpha]}, {alpha, 1/40, 1/8, 1/40}]

(* {{1/40, 1.19395 + 0.000415886 I}, {1/20, 
  1.29172 + 0.00165418 I}, {3/40, 1.37048 + 0.0036869 I}, {1/10, 
  1.43738 + 0.00646767 I}, {1/8, 1.49509 + 0.00993222 I}} *)
| improve this answer | |
$\endgroup$

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.