I have been trying to evaluate this symbolic function:

f[ρ_, R_, α_, yp0_, yp_] := R*((ρ - R*Cos[α])^2 + (R*Sin[α])^2 + (yp-yp0)^2)^(-(1/2));

Mathematica can compute the symbolic integration with respect to $\alpha$ but can't integrate the result with respect to $y_P$. In order to solve this issue I defined a piecewise function subdividing the interval $[0,2\pi]$ into $N$ subintervals of the same length and then I associated to each subinterval the series expanfion of $f$ with expansion point the center of the subinterval. Here is the code:

SerieAlpha[ρ_, R_, α_, yp0_, yp_, ord_, Epoint_] := 
  Assuming[Element[{ρ, R, α, yp0, yp, Epoint}, Reals] && 
    Element[ord, Integers] && R > 0 && ρ > 0, 
     f[ρ, R, α, yp0, yp], {α, Epoint, ord}]]];
Lista1[ρ_, R_, α_, yp0_, yp_, ord_, N_] := 
  Table[SerieAlpha[ρ, R, α, yp0, yp, ord, n*2*Pi/N], {n, 
    0, N}];
Lista2[N_] := 
  Table[(2*n - 1)*2*Pi/(N*2) < α <= (2*n + 1)*2*Pi/(N*2), {n, 
    0, N}];
PWNSerie[ρ_, R_, α_, yp0_, yp_, ord_, N_] := 
   Transpose[{Lista1[ρ, R, α, yp0, yp, ord, N], 

I tried to evaluate the absolute and percent error committed by this approximation method and, unless I use high values for $N$ and $ord$, it becomes very high when $(y_{P}-y_{P0})$ gets close to 0. Using high expansion orders and number of subintervals makes the function much more difficult to integrate so I would like to avoid this. These are the integrals I wanted to compare:

Integrale1[ρ_, R_, yp0_, yp_] := 
   Element[{ρ, R, yp0, yp}, Reals] && R > 0 && ρ > 0, 
   Integrate[2*f[ρ, R, α, yp0, yp], {α, 0, Pi}]]]
Integrale1S[ρ_, R_, yp0_, yp_, ord_, N_] := 
 Assuming[Element[{ρ, R, yp0, yp}, Reals] && 
   Element[{ord, N}, Integers] && R > 0 && ρ > 0, 
   2*PWNSerie[ρ, R, α, yp0, yp, ord, N], {α, 0, 

Is there anything I can do to get a better result for small values of $(y_{P}-y_{P0})$?? Would it be possible to use high expansion orders and high numbers of subinterval and still get a fast result?

  • $\begingroup$ What version are you using? Mathematica 12.1 can perfectly integrate f with respect to yp. $\endgroup$ – m0nhawk Apr 16 at 2:55
  • $\begingroup$ I am using mathematica 12.1. It is unable to integrate with respect to yp the result of the integral in alpha $\endgroup$ – gabriele colombo Apr 16 at 9:48
  • $\begingroup$ Oh, I integrated the f function. $\endgroup$ – m0nhawk Apr 16 at 14:11
  • $\begingroup$ Thanks for the editing btw. I don't really understand how you did it though $\endgroup$ – gabriele colombo Apr 16 at 14:27
  • $\begingroup$ There is a nice addon for Mathematica.SE: here. It has a bunch of nice features: formatting, references, symbols support. $\endgroup$ – m0nhawk Apr 16 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.