MaplePrimes Questions

From old memory, I recall some boolean algebra.  We have zeros and ones.

Some of us are familiar with logic gates. 

The simplest is the simple inverter.  It inverts.

Very interesting.

https://en.wikipedia.org/wiki/Boolean_algebra 

I have defined a function pp(x).  It plots correctly 

but pp(2020); should return 410, and it returns 98000. Maybe I am doing something stupid, but I just can't figure out what!

a := 0.340699639252428*10^13;
b := -0.118229737138742*10^11;
c := 0.175816922773262*10^8;
d := -14523.7138112711;
e := 7.19782673654200;
f := -0.00214008825847444;
g := 0.353463615941623*10^(-6);

h := -0.250170509163729*10^(-10);

pp := x -> a + b*x + c*x^2 + d*x^3 + e*x^4 + f*x^5 + g*x^6 + h*x^7;

plot([pp(x)], x = 1960 .. 2100, gridlines = true, size = [900, 600])

 

Good day, all. I hope we are staying safe.

Please I need help with the regard to the following codes.

The major issue is with rho:=x[n]/h. The rho needs to change values as x[n] changes in the computation. This I think I have gotten wrong. Your professional modifications or/and corrections to the code would be appreciated.

Thank you and kind regards.

restart;
Digits:=20:
#assume(alpha>0,alpha < 1):
f:=proc(n)
	-y[n]-x[n]+(x[n])^2+(2*(x[n])^(2-alpha))/GAMMA(3-alpha)+((x[n])^(1-alpha))/GAMMA(2-alpha):
end proc:

e2:=y[n+2] = y[n]+(1/2)*((alpha^2-alpha)*rho^2+(2*alpha^2-2)*rho+(4/3)*alpha^2-(2/3)*alpha)*(rho*h)^alpha*GAMMA(2-alpha)*f(n)/rho-alpha*GAMMA(2-alpha)*((-1+alpha)*rho^2+(2*alpha-2)*rho+(4/3)*alpha-8/3)*(h*(rho+1))^alpha*f(n+1)/(rho+1)+(1/2)*((alpha^2-alpha)*rho^2+2*(-1+alpha)^2*rho+(4/3)*alpha^2-(14/3)*alpha+4)*(h*(rho+2))^alpha*f(n+2)*GAMMA(2-alpha)/(rho+2):
e1:=y[n+1] = y[n]+(1/4)*((alpha^2-alpha)*rho^2+(alpha^2+3*alpha-4)*rho+(1/3)*alpha^2+(4/3)*alpha)*GAMMA(2-alpha)*f(n)/((rho*h)^(-alpha)*rho)-(1/2)*GAMMA(2-alpha)*((alpha^2-alpha)*rho^2+(alpha^2+alpha-2)*rho+(1/3)*alpha^2+(1/3)*alpha-2)*f(n+1)/((h*(rho+1))^(-alpha)*(rho+1))+(1/4)*((-1+alpha)*rho^2+(-1+alpha)*rho+(1/3)*alpha-2/3)*alpha*GAMMA(2-alpha)*f(n+2)/((h*(rho+2))^(-alpha)*(rho+2)):


alpha:=0.25:
inx:=0:
iny:=0:
#x[0]:=0:
h:=1/20:
N:=solve(h*p = 1, p):
n:=0:
c:=1:
rho:=x[n]/h: 
err := Vector(round(N)):
exy_lst := Vector(round(N)):

for j from 0 to 2 do
	t[j]:=inx+j*h:
end do:
vars:=y[n+1],y[n+2]:

step := [seq](eval(x, x=c*h), c=1..N):

printf("%4s%15s%15s%16s\n", 
	"h","Num.y","Ex.y","Error y");
st := time():
for k from 1 to N/2 do

	par1:=x[n]=t[0],x[n+1]=t[1],x[n+2]=t[2]:
	par2:=y[n]=iny:
	res:=eval(<vars>, fsolve(eval({e||(1..2)},[par1,par2]), {vars}));

	for i from 1 to 2 do
		exy:=eval(-c*h+(c*h)^2):
		printf("%5.3f%17.9f%15.9f%15.5g\n", 
		h*c,res[i],exy,abs(res[i]-exy)):
		
		err[c] := abs(evalf(res[i]-exy)):
		exy_lst[c] := exy:
		numerical_y1[c] := res[i]:
		c:=c+1:
		rho:=rho+1:
	end do:
	iny:=res[2]:
	inx:=t[2]:
	for j from 0 to 2 do
		t[j]:=inx + j*h:
	end do:
end do:
v:=time() - st;
printf("Maximum error is %.13g\n", max(err));

numerical_array_y1 := [seq(numerical_y1[i], i = 1 .. N)]:

time_t := [seq](step[i], i = 1 .. N):

with(plots):
numerical_plot_y1 := plot(time_t, numerical_array_y1, style = [point], symbol = [asterisk],
				color = [blue,blue],symbolsize = 15, title="y numerical",legend = ["Numerical"]);
exact_plot_y1 := plot(time_t, exy_lst, style = [line], symbol = [box], 
				color = [red,red], symbolsize = 10, title="y exact",legend = ["Exact"]);

display({numerical_plot_y1, exact_plot_y1}, title = "Exact and Numerical Solution of Example 1 ");

 

how can i solve this operate differential equation

convert(expand((D[1] - 1)*(D[1]^2 + 2)*y(x) = 0), diff);
dsolve(%)

 

Consider an easy example of a table.

myTable:=table(["a"=1,"b"=-1,"c"=1]);

We can give an index to it and get its corresponding entry if exists.

myTable["b"];

We can also get the set of all indices, or the set of all entries. But what about receiving the index or set of indices with a specific entry. for example asking what indices have the entry `1`?

Of course I can define a search procedure myself, but I thought there might be an efficient way which is already implemented as a function/method on tables.

Good afternoon. How do I disable the numbering of _Z constants? Because
of this, you can't use the procedure in a loop
Is it possible to disable numbering or do something else?

restart; with(linalg); t := 3

3

(1)

S := proc (a, b, z) local L, y, s1, s2, sist, chl, lambda1; L := diff(y(x), x, x) = lambda*y(x); assume(lambda < 0); dsolve(L, y(x)); y := unapply(rhs(%), x); s1 := y(a) = 0; s2 := y(b) = 0; sist := {s1, s2}; genmatrix(sist, {_C1, _C2}); det(%); chl := combine(%); _EnvAllSolutions := true; solve(chl); sort(%); lambda1 := subs(_Z1 = k, %); print(lambda1); lambda1 := unapply(%, k); lambda1(z) end proc:

S(0, Pi, 3);

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

 

-k^2

 

-9

(2)

for i to t do S(0, Pi, i) end do:

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

 

-_Z2^2

 

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

 

-_Z3^2

 

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

 

-_Z4^2

(3)


 

Download help.mw

This is new exception generated by Maple pdsolve in 2021. Different from the last post I gave on pdsolve. So I thought it will be better to keep them separate since the causes are different.

interface(version)
restart;
pde :=  diff(w(x,y,z),x)+(a1*x^n1*y+b1*x^m1)*diff(w(x,y,z),y)+(a2*x^n2*y+b2*x^m1)*diff(w(x,y,z),z)= 0;
pdsolve(pde,w(x,y,z));

#another example

restart;
local gamma:
pde := diff(w(x,y,z),x)+(a1*x^n1*y+ b1*x^m1)*diff(w(x,y,z),y)+(a2*x^n2*y+b2*x^m2)*diff(w(x,y,z),z)=c2*x^k2*y+c1*x^k1*z;
pdsolve(pde,w(x,y,z));

 

Error, (in GAMMA) numeric exception: division by zero

The same PDE works in 2020.2. The answer it gives is large so will not show it all below.

Screen shots

Maple 2021

 

Maple 2020.2


All on windows 10.

Do other see the same error? What causes it?

 

4 %+ 3 %* 2;
                        %*(%+(4, 3), 2)

= (4+3)*2

It makes using % very difficult in complex expressions because one has to constantly use a ton of paranethesis just to get things to work out.

1 + 4%^3  %* 2 %- 6 %/ 4;

1 + ((((4 %^ 3) %* 2) %- 6) %/ 4)

= 1 + (4^3*2 - 6)/4

I noticed number of pde's now fail in Maple 2021 with the error 

          int/gbinthm/structure INVALID subscript selector

but they do not fail in Maple 2020.2.

Here are few   examples

restart;
pde :=a*x^n*diff(w(x,y),x) + n*x^m*y*diff(w(x,y),y) =s*x^p*y^q+d;
pdsolve(pde,w(x,y));

restart;
pde :=a*x^n*diff(w(x,y),x) + n*x^m*y*diff(w(x,y),y)=c*x^k*y^s+d; 
pdsolve(pde,w(x,y)) 

restart;
pde :=a*x^n*diff(w(x,y),x)+b*x^m*y*diff(w(x,y),y) =  (c*x^k*y^s + d)*w(x,y);
pdsolve(pde,w(x,y))

restart;
pde :=  a*diff(w(x,y),x)+ y*diff(w(x,y),y) = b*w(x,y)+ c*x^n*y^m;
pdsolve(pde,w(x,y))

#etc..

Error, (in int/gbinthm/structure) invalid subscript selector
 

While in Maple 2020.2 they all work. Screen shot

Maple 2021

 

Maple 2020.2

 

Any idea why this happens? Do others see the same error?

 

 

Hi!

How to define n-dimensional metric for arbitrary n in Physics package?

Thanks

I would like to compute the euler-lagrange equations using the index notation in quantum field theory. So for example given the Lagrangian here:

 

Is there a way to derive the Euler-Lagrange equation in maple?

I've experienced problems a couple of times when trying to save a workbook in Maple 2021.

At first I thought it was due to a unstable VPN connection, but this also happens on a local drive.

Hi,

Consider the following example:

 

>> Maple express the second derivative of Legendre polynomial as

 

This form cannot, for instance, be integrated if we set n, for example, to 2.

i was wondering whether there is a trick to force Maple to express those derivatives in term of P_n using the relevent recurrence relations. This will help for further manipulations.

 

Thanks a lot!

 

Heinrich,

 

I have a 2688x1 matrix of ground acceleration data that I converted to a forcing function F (also a 2688x1 matrix) that I need to evaluate using duhamels integral. Since the forcing function can not be represented my a real expression numberical integration is required. Am needing to write a loop as seen on bottom of attached picture. Essentially to perform trapezoidal rule to return  structural motion (u).

 

Am looking for advice on how to write this loop in Maple.

I have attempted the for program in Maple per below with;

[F]:= Forcing Matrix 
[t]:= time step matrix

Assigned initial conditions sim to pic below

for i from 1..2688 do

added the functions sim to bottom of pic for Ai, Bi, and ui 

end do

 

 

 


 

First 432 433 434 435 436 437 438 Last Page 434 of 2431