Axel Vogt

5821 Reputation

20 Badges

20 years, 221 days
Munich, Bavaria, Germany

MaplePrimes Activity


These are answers submitted by Axel Vogt

One can simplify the integrals over the complex error function into just one, which speeds up.

I did not use acer's error handling / code (I do not quire understand it), but a cut off.

A proper way for the nasty error  function would be through https://en.wikipedia.org/wiki/Faddeeva_function because of the damping by exp(-kappa^2). There is code for it (through the literature on the German Wikipedia site), but not in Maple.

Edit 13.09.22: the cut off = 6 results from roughly estimating an (absolute) integration error to be less than 1e-15.

# https://www.mapleprimes.com/questions/234736-How-To-Reduce-Evaluating-Time

restart; interface(version); Digits:=15;
local gamma: # or better something like gg instead

`Standard Worksheet Interface, Maple 2021.2, Windows 7, November 23 2021 Build ID 1576349`

 

15

(1)

X:=Int(exp(-kappa^2*(delta^2 + 1)/2)*cos(kappa*beta)*cos(kappa*gamma)/(kappa), kappa = Lambda .. infinity);
Y:='Int(-exp(-kappa^2*(delta^2 + 1)/2)*cos(kappa*beta)*Im(exp(kappa*gamma*I)*erf( (gamma+kappa*I)/sqrt(2)))/(kappa), kappa = Lambda .. infinity)';
theJ:= 'sqrt(X^2+Y^2)/2*exp(-alpha^2/2)*lambda^2';

Int(exp(-(1/2)*kappa^2*(delta^2+1))*cos(kappa*beta)*cos(kappa*gamma)/kappa, kappa = Lambda .. infinity)

 

Int(-exp(-(1/2)*kappa^2*(delta^2+1))*cos(kappa*beta)*Im(exp(I*kappa*gamma)*erf((gamma+I*kappa)/sqrt(2)))/kappa, kappa = Lambda .. infinity)

 

(1/2)*sqrt(X^2+Y^2)*exp(-(1/2)*alpha^2)*lambda^2

(2)

forget(evalf):
'eval(theJ, [alpha=4,delta=1,Lambda=0.001,beta=8,gamma=3])':
CodeTools:-Usage(''%''=evalf(%) );
# this is valid for 15 decimals

memory used=2.61GiB, alloc change=198.67MiB, cpu time=29.86s, real time=28.76s, gc time=2.45s

 

eval(theJ, [alpha = 4, delta = 1, Lambda = 0.1e-2, beta = 8, gamma = 3]) = 0.730427393719220e-3*lambda^2

(3)

subs(infinity=6, theJ): # cut off
numJ2:=subsindets(%,'specfunc(anything,Int)', 'q -> Int(op(q), epsilon = 1e-4, method = _d01akc)'):

forget(evalf):
'eval(numJ2, [alpha=4,delta=1,Lambda=0.001,beta=8,gamma=3])':
CodeTools:-Usage(''%''=evalf(%) );

memory used=8.97MiB, alloc change=0 bytes, cpu time=109.00ms, real time=125.00ms, gc time=0ns

 

eval(numJ2, [alpha = 4, delta = 1, Lambda = 0.1e-2, beta = 8, gamma = 3]) = 0.730427393783615e-3*lambda^2

(4)

 

Download MP_234736.mw

For example:


 

p1:=plot(sqrt(x), x=0..2, color=red):
p2:=plot(1/x, x=-3..0, color=blue):
plots[display]([p1,p2]);

 

 


 

Download MP_234721.mw

Essentially you need Int(x^(1/10)*exp(x),x=0..2) = 6.47950080882301

Int(x^(1/10)*exp(x),x);
IntegrationTools:-Parts(%, exp(x));
value(%):
V:=simplify(%) assuming 0<x;

Plotting "shows" it is continous [Re(V), Im(V)]: plot(%, x=-0.1..2.1);

limit(V, x=2, left)-limit(V, x=0, right);  
expand(%);
evalf(%);

"proves" the value
-1/10*(-1)^(9/10)*GAMMA(1/10,-2)+2^(1/10)*exp(2)+1/10*Pi*(-1)^(9/10)/sin(1/10*Pi)/GAMMA(9/10)
is correct

Have not tried for your final integral

You want to write proc(x,y,t), else y is local (as you did) and not known outside

Cant you feed the solution into the ode and then using MultiSeries:-series ?


 

 

# https://www.mapleprimes.com/questions/234443-How-To-Use-Odetest-To-Very-Series-Solution
restart; interface(version);

ode:=x^3*diff(y(x),x$2)+x^2*diff(y(x),x)+y(x): #=0;
sol:=dsolve(ode,y(x),'series',x=infinity):
#odetest(sol,ode,'series','point'=infinity);

rhs(sol): #convert(%, polynom);
Y:= unapply(%, x):

eval(ode, y=Y):
MultiSeries:-series(%, x, 6);

series(+O(x^(-6)),x,-6)

(1)

 


 

Download MP_234443_odetest_series.mw

You have many terms, 196*109. Here is a suggestion: write the inner Sum as function, evaluate the outer additions and then feed the function with its numerical values.

I changed your variable l, because it is bad to read it and reduced addition to 20*10 (well, I lost patients). Also note that you may have to do some more work if you want to care for rounding errors of 20000 terms of quite different magnitude and signs.

Hope it helps.

MP_234318.mw

Edit: I need roughly 200 sec to get 5.76900063193468*10^29 with an old Win PC, summing up over your original range.

Likewise you can look into the Digital Library of Mathematical Functions https://dlmf.nist.gov/,

https://dlmf.nist.gov/19.6

I would do it in a paper & pencil style (it is a mess how this board displays it)

# https://www.mapleprimes.com/questions/234277-How-To-Solve-A-Cubic-Assuming-Discriminant

restart;

 

f := 2*y^3*z - y^2 -2*m;
#F:=unapply(f, y);

f := 2*y^3*z-y^2-2*m

(1)

assume(m<0, 0<z);

discrim(f,y); signum(%); convert(%, piecewise, m);

-8*m*(54*m*z^2+1)

signum(54*m*z^2+1)

piecewise(m < -1/(54*z^2), -1, m = -1/(54*z^2), 0, -1/(54*z^2) < m, 1)

(2)

# translate "0 < discrim(f,y)"
additionally(-1/(54*z^2) < m);

#getassumptions({m,z});

diff(f, y);
Q:=[solve(%)]; # local extrema

6*y^2*z-2*y

Warning, solve may be ignoring assumptions on the input variables.

Q := [{y = 0, z = z}, {y = 1/((3*z)), z = z}]

(3)

eval(f, Q[1]); signum(%);

-2*m

1

(4)

eval(f, Q[2]); normal(%); # = discrim(f,y) * factors with known signs
signum(%);

-1/((27*z^2))-2*m

-(54*m*z^2+1)/(27*z^2)

-1

(5)

limit(f, y=-infinity);
limit(f, y=+infinity);

-infinity

infinity

(6)

 

Thus f comes from -oo, takes a positive value in y=0 and a negative value

in the positive y= 1/(3*z) and runs to +oo.

Hence it has 3 real zeros.

 

 

Download MP_234277_CubicSolve.mws

MP_234277_CubicSolve.pdf

As far as I see you have a linear system 4 x 4. The according matrix has rank <= 3. Hence the solution is not a point

MP234160_QuestionNo1.mw

For your example the following would do:

sin(x)/x; convert(%, hypergeom, include=sin); convert(%, BesselJ);

or even shorter

sin(x)/x; convert(%, BesselJ, include=sin);

@vv 

Sum(Beta(k,1/2)/(2*k+1)^2,k=1..infinity);
convert(%, MeijerG);
#convert(%, hypergeom); # needed if evalf is used
convert(%, Int): value(%);
                        infinity
                         -----
                          \      Beta(1/2, k)
                           )     ------------
                          /                2
                         -----    (2 k + 1)
                         k = 1


          1/2
    1/4 Pi    MeijerG([[-1/2, 0, 0], []], [[0], [-3/2, -3/2]], -1)


                            4 - 4 Catalan

 

You may try assuming, not assume. Or use "simplify(%) assuming ..." for the result.

BTW: Maple 2021 returns /(A^2-B^2)^(1/2)*EllipticK(B*2^(1/2)*(-1/(A^2-B^2))^(1/2))

I posted an answer at https://www.mapleprimes.com/questions/233780-Plot-Absolute-Advantage-Of-Option-A   but that thread disappeared (was it deleted?)

VT:=V_TEV-V_P:
indets(%, symbol);
                                {E, T}

So your VT depends on E = income and T = time and the following shows the values:

plot3d(VT, E=10^5 ... 10^6, T = 1 ..5, axes=boxed);

plot3d(VT/E, E=10^5 ... 10^6, T = 1 ..5, axes=boxed); shows you the values relative to income

Remark: your r seems to stand for rates, 0.1 = 10% is somewhat high, perhaps you want to see it for 1% or 3%

You may consider to use Excel and - if really needed - connect Excel and Maple

2 3 4 5 6 7 8 Last Page 4 of 92