vv

12453 Reputation

19 Badges

9 years, 285 days

MaplePrimes Activity


These are answers submitted by vv

For this series (with a numeric n) there are some subtle math aspects.

1. The series may not exist if a<n [e.g. if a is noninteger]
2. For a>=n the expansion is 0  i.e. 0 + O(...)
but unfortunately Maple is not able to find it because for example

diff(sin(x)^a, x);

 

and Maple tries x=0 instead of limit(%, x=0)

You may of course expand around another point, e.g.

series(sin(x)^a, x=Pi/2, 4);

 

 

 

restart;

f:=exp(-I*x*y)*exp(x)/cosh(x)^2:

Int(f, x=-infinity..infinity) = `?`;

Int(exp(-I*x*y)*exp(x)/cosh(x)^2, x = -infinity .. infinity) = `?`

(1)

######################################
## The math explanation is omitted  ##
######################################

s:=singular(f,x):

sing:=eval(s, indets(s, suffixed(_Z))[]=n);

{x = ((1/2)*I)*Pi+I*Pi*n}

(2)

res:=simplify( residue(f, sing[]) ) assuming n::integer;

-exp((1/2)*Pi*(2*n+1)*y)*(-1)^n*(I+y)

(3)

ans := 2*Pi*I*sum(res, n=0..infinity) assuming y<0;

-(2*I)*Pi*exp((1/2)*Pi*y)*(I+y)/(exp(Pi*y)+1)

(4)

ANS:=Int(f, x=-infinity..infinity) = ans;

Int(exp(-I*x*y)*exp(x)/cosh(x)^2, x = -infinity .. infinity) = -(2*I)*Pi*exp((1/2)*Pi*y)*(I+y)/(exp(Pi*y)+1)

(5)

# numerical check

evalf(eval(ANS, y=1));

1.252040331-1.252040331*I = 1.252040331-1.252040331*I

(6)

evalf(eval(ANS, y=-1));

1.252040331+1.252040331*I = 1.252040331+1.252040331*I

(7)

evalf(eval(ANS, y=0));

3.141592654 = 3.141592654

(8)

 

The labels (A,B)  persist until the output is deleted. Even if the vector <1,2,3> is changed.

ws.mw

It is of course possible, but I don't think it's a good idea.

a:=2; b:=5;

2

 

5

(1)

x := t->t^2-3*t;

proc (t) options operator, arrow; t^2-3*t end proc

(2)

plot(x(t), t=a..b, view=[a-0.1..b+0.1,default]);

 

plot(x(b+a-t), t=a..b, tickmarks=[[a=b,b=a],default], view=[a-0.1..b+0.1,default]);

 

 

You may obtain animations using Explore.
Here is a simple example, similar to your problem.

restart;
A:=proc(c)
local p1,p2,d,x,t ;
p1:=plot(1 + c*sin(t), t=0..2*Pi, coords=polar);
d:=fsolve(x^5+x = c^5+1, x);
p2:=plot(2*x+d, x=-2..1);
plots:-display(p1,p2, view=[-2.5 .. 2.5, -1..4]) 
end proc:

Explore(A(c), c=0..2.6, animate);

 

BISSEC := proc (PP, UU, VV) 
uses LinearAlgebra,plots;
local P:=PP,U:=UU, V:=VV,
a, b, eq1, eq2, M1, M2, t, PU, PV, bissec1, bissec2; 
a := (P-U)/Norm(P-U, 2)+(P-V)/Norm(P-V, 2); M1 := P+a*t; b := (P-U)/Norm(P-U, 2)-(P-V)/Norm(P-V, 2); M2 := P+b*t; 
eq1 := op(eliminate({x = M1[1], y = M1[2]}, t)); 
eq2 := op(eliminate({x = M2[1], y = M2[2]}, t)); 
P := convert(P, list); U := convert(U, list); 
V := convert(V, list);
PU := plot([P, U]); PV := plot([P, V]); bissec1 := implicitplot(op(eq1[2]), x = 0 .. 5, y = 0 .. 10, color = red); bissec2 := implicitplot(op(eq2[2]), x = 0 .. 5, y = 0 .. 10, color = green); display([bissec1, bissec2, PU, PV], scaling = constrained) end proc:

A := `<,>`(4, 8): B := `<,>`(4, 2):; C := `<,>`(1, 4):
#debug(BISSEC);
BISSEC(A, B, C);

 

P:=n -> binomial(n-1,3) - binomial(floor(n/2),3);

 

Usually, select or map produce shorter and faster solutions than a loop.

select(`>`, L, 0) /~ 2;

 

DD:=(n,alpha) -> Matrix(n+1, (i,k) -> sum(omega(i-1,j,k-1), j=ceil(alpha)..n)):
DD(2,alpha);

It remains to define your function omega:

omega := (i,j,l) -> ...

Yes, in Maple 2019 it is recommended to use

g := x-> local j; sum(..., j=1..5);

 

I have used DirectSearch, a reliable and free global optimizer (see  Maple Application Center).
Note that your model does not seem to be perfect for your data.

 

 

restart;

libname := "d:\\ds2", libname:

with(DirectSearch):

Digits:=15:

X := Vector([0, 100, 200, 300, 400, 500], datatype = float):
Y := Vector([0.2e-2, 0.5e-2, 0.7e-2, 0.75e-2, 0.77e-2, 0.8e-2], datatype = float):

f:=1/25000*(-100*a*b*(c-1)^2*exp(-1/100*(b*c+a)*t/c/(a+b))+((t+100)*a+100*c*(c+1/
100*t)*b)*(a+b))/(a+b)/(b*c+a)^2;

(1/25000)*(-100*a*b*(c-1)^2*exp(-(1/100)*(b*c+a)*t/(c*(a+b)))+((t+100)*a+100*c*(c+(1/100)*t)*b)*(a+b))/((a+b)*(b*c+a)^2)

(1)

sol:=DataFit(f,X,Y,t, [a=0..1, b=0..1, c=0..1, a+b+c=1]);

[HFloat(8.625680307110638e-5), [a = HFloat(0.9999995216155494), b = HFloat(1.5510602944156731e-7), c = HFloat(3.2768524715027054e-7)], 152]

(2)

F:=eval(f, sol[2]);

-HFloat(6.204242085295688e-10)*exp(-HFloat(30517.084720490617)*t)+HFloat(4.0000019135385154e-5)*t+HFloat(0.004000001913538312)

(3)

seq([Y[i], err=eval(F,t=X[i]) - Y[i]], i=1..numelems(X));

[HFloat(0.0020), err = HFloat(0.0020000012931141037)], [HFloat(0.0050), err = HFloat(0.0030000038270768274)], [HFloat(0.0070), err = HFloat(0.0050000057406153426)], [HFloat(0.0075), err = HFloat(0.00850000765415386)], [HFloat(0.0077), err = HFloat(0.012300009567692371)], [HFloat(0.0080), err = HFloat(0.01600001148123089)]

(4)

 


plots:-display(plot(F, t=0..500), plot(X,Y, style=point, color=blue, symbolsize=16));

 

The 0 value can be obtained as an Abel (generalized) summation:

sum(sin(Pi*n/2)*sin(n*Pi*(x + 1)/2)*cos(n*Pi*t/2) * z^n, n=1..infinity) assuming z>0,z<1:

limit(%, z=1, left);
      0

 

Your piecewise function f is not a "classical" solution of the ODE y' = 0  because as you see, f is not differentiable at some points.

There are also "generalized" solutions,  see wiki, where the function must satisfy the ODE only a.e. (almost everywhere, i.e. except on a null set), but the function must be absolutely continuous. Your piecewise funcion is not even continuous, so it is still not a solution in this wider sense.
Note that there are other contexts (e.g. distributional derivatives), but I'll stop here.

 

You essentially compare

eval(floor(n), n=1);   # 1
limit(floor(n), n=1);  # undefined

and conclude 1 = undefined (+ something about a prize).

You should be aware that floor is not continuous at 1.

 

 

LibLocation:="C:/temp/MyLib.mla": # dir with write access
LibraryTools:-Create(LibLocation); # if the library is new
LibraryTools:-Save(MyMat, LibLocation);
restart;  # check
LibLocation:="C:/temp/MyLib.mla";
libname:=LibLocation, libname;
with(MyMat);

(The path is for Windows.)

First 37 38 39 40 41 42 43 Last Page 39 of 111