MaplePrimes Questions

Hi there!

Sorry to ask, but I don't know how I can solve it in a smart way. I want to take the covariant derivative of a specific vector, whose components are specifically defined, which can be constant or some functions of the coordinates. But, as soon as I define that specific vector, the covariant derivative fails to compute, saying there are "too many levels of recursion". Let me show what I mean.

I have these two attempts to get this:

 

First attempt

 

restart

with(Physics)

Setup(mathematicalnotation = true)

Coordinates(X = spherical)

{X}

(1.1)

Parameters(k)

{k}

(1.2)

Setup(metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = (a(t)*r)^2, (3, 3) = (a(t)*r*sin(theta))^2, (4, 4) = -1})

[metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = a(t)^2*r^2, (3, 3) = a(t)^2*r^2*sin(theta)^2, (4, 4) = -1}]

(1.3)

Define(b[mu])

{Physics:-D_[mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.4)

NULL

Define(Db[nu, mu] = D_[nu](b[mu](X)))NULL

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.5)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.6)

Db[]

Db[mu, nu] = Matrix(%id = 18446746372997772822)

(1.7)

beta := proc (X) options operator, arrow; b0 end proc``

proc (X) options operator, arrow; b0 end proc

(1.8)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.9)

Db[]

Error, (in index/PhysicsTensor) too many levels of recursion

 

````

Second attempt

 

restart

with(Physics)

Setup(mathematicalnotation = true)

Coordinates(X = spherical)

{X}

(2.1)

Parameters(beta, k)

{beta, k}

(2.2)

Setup(metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = (a(t)*r)^2, (3, 3) = (a(t)*r*sin(theta))^2, (4, 4) = -1})

[metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = a(t)^2*r^2, (3, 3) = a(t)^2*r^2*sin(theta)^2, (4, 4) = -1}]

(2.3)

Define(b[mu])

{Physics:-D_[mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.4)

``

Define(Db[nu, mu] = D_[nu](b[mu](X)))``

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.5)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.6)

Db[]

Error, (in index/PhysicsTensor) too many levels of recursion

 

````

``

On my first attempt, expression (1.7) is almost fine, but β is supposed to be constant (and a function of "t" in the future), so I set it as a constant function. But then it causes that problem. Therefore, on my second attempt, I tried to set β as a parameter since the beginning, but it was no good either.


If I were to take the covariant derivative as "D_[nu](b[mu])" (without the "(X)"), it would not have that specific problem, but would not be a good solution, since the covariant derivative would discard the partial derivative of b[mu] and, if it would have some dependence on the coordinates, it would give a wrong result.


The only way it seems to work is by defining the tensor "Db[mu,nu]" explicitly as "d_[mu](b[nu](X)) - Christoffel[~alpha, mu, nu]*b[alpha]". (It seems that the problem comes from that "(X)" next to "b[alpha]" in the connection term.) But that would be an awful way to circumvent the problem. Isn't there any better way to get this?


Can someone help me with this, please?


Thanks for any help!

 

Download Cov._derivative_of_a_specific_vector.mw

 

I rename text file as mws when I click it , it show a few button and then need to extra click maple input and then need to click enter in order to run.

 

how to run directly when I open it with maple?

For a spring hanging vertically from a fixed point, suppose the spring constant, k, is a function of the distance from the fixed point to the other (lowest) end of the spring (for example; the diameter of the spring's coils changes along the length of the spring) .

What ODE reflecting this situation will yield solutions for the harmonic motion of the spring after it is stretched from its equilibrium position?

In Maple 2019, I'm using the "applyrule" function to write a simple routine for contracting vector indices, following the Einstein summation convention (repeated indices are summed).

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(a,k) * vec(b,k)
);

Output:

dotproduct(a, b)

So far it works as expected. Now I add an "uncontracted" vector, and the code seems to become unpredictable. First, let me show a case in which the code still works:

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(u,k) * vec(u,i) * vec(c,k)
);

Output:

dotproduct(c, u)*vec(u, i)

As expected, contraction has been done on the repeated index "k", but vec(u,i) was left alone. However, the above code fails if I simply change the variable name "u" to "a":

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(a,k) * vec(a,i) * vec(c,k)
);

Output:

vec(a, k)*vec(a, i)*vec(c, k)

Apparently, the rule was not applied because I used "a:symbol" in the transformation rule. But I thought "a::symbol" should be considered a wildcard that represents any symbol, including "a" itself?

Depending on the exact input, this bug sometimes shows up, sometimes not, but the above examples are verified to be reproducible. A simple workaround is always avoiding the use of the same variable, but this seems to be hack. Is there a proper solution?

How can add a PNG within a text section of a Maple Worksheet without having the image appear with a black background?

Does Maple have an alpha channel or transparency setting that must be toggled for this to work?

Maple 2019
macOS 10.14.6

I am added pictures from the clipboard via drag+drop.

(Yes, I know that I can use JPEG without this problem and that is NOT my question).

--
JJW

hi . i want to get maximize in dsolve numeric y(t) D(y)(t) and y(t) double dot

restart;
with(plots);
with(Optimization);
sol := {diff(y(t), t, t) + 2*diff(y(t), t) + 4*y(t) = 0.9*sin(9*t), y(0) = 0, D(y)(0) = 0};
so := dsolve(sol, numeric, method = rkf45);
plots:-odeplot(so, [t, y(t)], t = 0 .. 4);
Maximize(??????);
 

hello. i write this code for use 6 cpu cores but it write 4

I find eval(Diff(x,x)) still is Diff(x,x)

how to make become 1

or how to evaluate Capital Diff ?

 

and I find sum(diff(x^k,x)/k! , k=1..n)

return exp(x) *gamma(n,x)/gamma(n)

why not exp(x)?

 

and diff( m(x+ diff(...) ...) / diff without m(x) , why return 0

i still have not define m(x)

 

I know how to define functions and generally how to pass them to another function and usually everything works out... rarely though I run in to problems and my lack of how maple works internally becomes a stumbling block. I usually just hack things together. I'd rather understand what exactly is happening.

 

It seems that apply and unapply have something to do with this.

 

I usually define functions like this, e.g.,

 

f := x->x^2 + 3;

g := (f,x)->cos(f(x));

 

and things like g(f,x) work as expected.

But this doesn't always work.

 

E := proc(f, depth)
    if depth <= 0 then return f; fi:
     E(f(x), depth-1); # Trying to actually compute f(f(x)), say. I know we can just loop.
end proc:


E(x->2*x, 3);

2*x(x)(x)

 

rather than 8x

 

I see that maple is somehow applying the function but in some odd way(it seems to be creating a function from the variable x and then another function from that).

 

Anyways, I don't understand the mechanics of it. In some cases f works other one must add the variablef(x), etc...

 

There seems to be some subtle difference between f and f(x)...  In a programing language like C. f is sort of a function pointer and f(x) is an evaluation of f at x. I guess there is something similar goingn on with maple but i've not been able to figure it out. Any ideas?

I have been able implement this procedure here. 

AreaBetween := overload([proc(fnc::{list}, a::anything, b::anything, col::list) option overload; plottools:-transform(unapply([x, y + fnc[2]], x, y))(plot([fnc[1]] + [-fnc[2]], x = a .. b, col = [col[2], col[3]], gridlines, size = [600, 600], thickness = 3, filled = [color = col[1]])); end proc])

1) How do get to construct a larger canvas? Meaning if I want a xy axis, x = -10..10, y = -10..10 however only x = a..b is suppose to be shaded. Can I do that with my procedure? 

2) Only the lower graph is colored currently. How do I get it to color the upper graph? 

Many thanks in advance. 

Hello;

Maple 2019.2.1 on windows 10

Is there a trick to make inttrans:-fourier(erf(x),x,k) return the Fourier transform of the error function? Now, using Maple 2019.2.1 it returns unevaluated. But direct application of Fourier transform integral does return the correct result. So why inttrans does not work? 
 

inttrans:-fourier(erf(x),x,k)

fourier(erf(x), x, k)

1/sqrt(2*Pi)*int(erf(x)*exp(-I*x*k),x=-infinity..infinity)

-I*2^(1/2)*exp(-(1/4)*k^2)/(Pi^(1/2)*k)

 

 

Download erf.mw

 

 

 

Hi,


I have a set of functions of the form P :=  { a(t), b(t), f(g(t)), u(v(w(t)), A(a(t), b(t)), ... } and I want to obtain the set Q := { a(t), b(t), g(t), w(t) } (that is the set of the innermost functions)
Since more than an hour I'm fighting without success with select and parmatch and I'm desperatly askink for your help.

Thanks in advance
 
PS : the list P only contains functions of t, never of t and of another variables.

Any one help me  to remove the error.

I want to plot the curve for different values of alpha.

here is my codes.

thanks in advance 

 

restart:
with(linalg):with(plots): 
ge[1]:=diff(u[1](x,t),t)=alpha*diff((u[2](x,t)-1)*diff(u[1](x,t),x),x)+(16*x*t-2*t-16*(u[2](x,t)-1))*(u[1](x,t)-1)+10*x*exp(-4*x):
ge[2]:=diff(u[2](x,t),t)=diff(u[2](x,t),x$2)+alpha*diff(u[1](x,t),x)+4*(u[1](x,t)-1)+x^2-2*t-10*t*exp(-4*x): 
bc1[1]:=u[1](x,t)-1: 
bc1[2]:=u[2](x,t)-1: 
bc2[1]:=3*u[1](x,t)+diff(u[1](x,t),x)-3:
bc2[2]:=5*diff(u[2](x,t),x)-evalf(exp(4))*(u[1](x,t)-1):
IC[1]:=u[1](x,0)=1: 
IC[2]:=u[2](x,0)=1: 
NN:=2: 
N:=2:
L:=1:
for i to NN do  
dydxf[i]:=1/2*(-u[2,i](t)-3*u[0,i](t)+4*u[1,i](t))/h: 
dydxb[i]:=1/2*(u[N-1,i](t)+3*u[N+1,i](t)-4*u[N,i](t))/h:
dydx[i]:=1/2/h*(u[m+1,i](t)-u[m-1,i](t)); 
d2ydx2[i]:=1/h^2*(u[m-1,i](t)-2*u[m,i](t)+u[m+1,i](t)):od:
 for i to NN do bc1[i]:=subs(diff(u[1](x,t),x)=dydxf[1],
diff(u[2](x,t),x)=dydxf[2],u[1](x,t) 
=u[0,1](t),u[2](x,t)=u[0,2](t),x=0,bc1[i]):od: 
for i to NN do bc2[i]:=subs(diff(u[1](x,t),x)=dydxb[1],
diff(u[2](x,t),x)=dydxb[2],u[1](x,t) 
=u[N+1,1](t),u[2](x,t)=u[N+1,2](t),x=L,bc2[i]):od:
for i to NN do eq[0,i]:=bc1[i];eq[N+1,i]:=bc2[i]:od: 
for i from 1 to N do eq[i,1]:=diff(u[i,1](t),t)= subs(diff(u[1](x,t),x$2) =
subs(m=i,d2ydx2[1]), 
diff(u[2](x,t),x$2) = subs(m=i,d2ydx2[2]),diff(u[1](x,t),x) =
subs(m=i,dydx[1]),diff(u[2](x,t),x) = subs(m=i,dydx[2]),u[1](x,t)=u[i,1](t), 
u[2](x,t)=u[i,2](t),x=i*h,rhs(ge[1])):od:

for i from 1 to N do eq[i,2]:=diff(u[i,2](t),t)= subs(diff(u[1](x,t),x$2) =
subs(m=i,d2ydx2[1]), 
diff(u[2](x,t),x$2) = subs(m=i,d2ydx2[2]),diff(u[1](x,t),x) =
subs(m=i,dydx[1]),diff(u[2](x,t),x) = subs(m=i,dydx[2]),u[1](x,t)=u[i,1](t),
u[2](x,t)=u[i,2](t),x=i*h,rhs(ge[2])):od: 

for i to NN do u[0,i](t):=(solve(eq[0,i],u[0,i](t))):od:

 for i to NN do u[N+1,i](t):=(solve(eq[N+1,i],u[N+1,i](t))):od:

 h:=L/(N+1): 

for i from 1 to N do eq[i,1]:=eval(eq[i,1]):od: 
 for i from 1 to N do eq[i,2]:=eval(eq[i,2]):od:

eqs:=seq(seq((eq[i,j]),i=1..N),j=1..NN): 
Y:=seq(seq(u[i,j](t),i=1..N),j=1..NN): 

 ICs:=seq(u[i,1](0)=rhs(IC[1]),i=1..N),seq(u[i,2](0)=rhs(IC[2]),i=1..N): 

sol:=dsolve({eqs,ICs},{Y},type=numeric,stiff=true,maxfun=1000000,abserr=1e-6,relerr=1e-5,output=listprocedure):

Warning, The use of global variables in numerical ODE problems is deprecated, and will be removed in a future release. Use the 'parameters' argument instead (see ?dsolve,numeric,parameters)
for j to NN do for i to N do U[i,j]:=subs(sol,u[i,j](t)):od:od: 

for i to NN do U[0,i]:=subs(u[1,1](t)=U[1,1],u[1,2](t)=U[1,2],
u[2,1](t)=U[2,1],u[2,2](t)=U[2,2],u[0,i](t)):od:
 for i to NN do U[N+1,i]:=eval(subs(u[N,1](t)=U[N,1],u[N,2](t)=U[N,2],
u[N-1,1](t)=U[N-1,1],u[N-1,2](t)=U[N-1,2],u[N+1,i](t))):od:
tf:=1.: 
M:=30: 
T1:=[seq(tf*i/M,i=0..M)]: 
PP:=matrix(N+2,M+1): 
for i from 1 to N+2 do PP[i,1]:=evalf(subs(x=(i-1)*h,rhs(IC[1]))):od: 
for i from 1 to N+2 do for j from 2 to M+1 do
PP[i,j]:=evalf(subs(t=T1[j],U[i-1,1](t))):od:od:
 
G1:=[seq([ seq([(i-1)*h,T1[j],PP[i,j]], i=1..N+2)], j=1..M+1)]: 
t=0.02: 
pars:=[0.1,0.5,1,2,5];
clr:=[black,red,green,gold,blue];  
for m from 1 to 5 do 
G1[m]:=plot([seq(subs(alpha=pars[m],G1[i])],i=0..N+1)],thickness=3,color=clr[j]):od:  

display({seq(G1[i],i=1..5)},title="Figure ",axes=boxed,labels=[x,u]);
restart:
 

Eksamensopgaver_samlet.mw

Hey

Can anyone help me with this file?

I don't know how it happend, but the file somehow got corrupted. Is there anything i can do?

Thanks 

 s0lve  diff(U, x, t) = U by admion decomposition method

First 609 610 611 612 613 614 615 Last Page 611 of 2424