Maple 2023 Questions and Posts

These are Posts and Questions associated with the product, Maple 2023

Good day to all the members who read this question.
I ask for your help to find the right way to solve this two differential equations (is attached the file). Used the common code "dsolve" but is not working on this problem. Doesn't matter if the solution is numeric or algebraic.
I will thaks a lot your kind help.
Best regards to all of you

DIFFERENTIAL_EQUATION.mw

restart

with(PDEtools)

First Part

The differential equation to solve:

(Delta*LinearAlgebra:-Transpose(D[1/2])*D__0-I*`μ__e`*D__0/(lambda+I*`μ__e`*r)-2*(`μ__e`^2*r^2+lambda^2))*R(r)

Definitions

D__n = `∂__r`+I*omega(a^2+r^2)/Delta+I*a*m/Delta+2*n*(r-M)/Delta

LinearAlgebra:-Transpose(D[n]) = `∂__r`-I*omega(a^2+r^2)/Delta-I*a*m/Delta+2*n*(r-M)/Delta

a := 1; M := 1; omega := 1; m := 1; `μ__e` := 1; lambda := 1

Delta := -2*M*r+a^2+r^2

I divided the differential equation in 3 parts (A, B, C).

A := (-I*omega(a^2+r^2)-I*a*m+r-M)*(diff(R(r), r)+I*omega(a^2+r^2)*R(r)/Delta+I*a*m*R(r)/Delta)+Delta*(diff(R(r), r, r))+I*omega(a^2+r^2)*(diff(R(r), r))+I*a*m*(diff(R(r), r))

B := -I*`μ__e`*(diff(R(r), r)+I*omega(a^2+r^2)*R(r)/Delta+I*a*m*R(r)/Delta)/(lambda+I*`μ__e`*r)

C := -(2*(`μ__e`^2*r^2+lambda^2))*R(r)

DE := A+B+C

E := dsolve(DE)

R(r) = DESol({diff(diff(_Y(r), r), r)-(1-r+I/(1+I*r))*(diff(_Y(r), r))/(r^2-2*r+1)-(-(2*I)*((-1-2*I)+r)/(r^2-2*r+1)-2/((1+I*r)*(r^2-2*r+1))+2*r^2+2)*_Y(r)/(r^2-2*r+1)}, {_Y(r)})

(1)

dsolve({DE, DE(0) = 1}, numeric, range = 0 .. 20)

Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem

 

Second Part

The differential equation to solve:

[`#msub(mi("L",fontweight = "bold"),mfrac(mn("1",fontweight = "bold"),mn("2",fontweight = "bold"),linethickness = "1"))`*LinearAlgebra:-Transpose(L[1/2])+a*`μ__e`*sin(theta)*LinearAlgebra:-Transpose(L[1/2])/(lambda+a*`μ__e`*cos(theta))+2*(lambda^2+a^2*`μ__e`*cos(theta)^2)]*S(theta) = 0

Definitions:

L__n = a*omega*`sinθ`+m*`cosecθ`+n*`cotθ`+`∂__θ`

LinearAlgebra:-Transpose(L[n]) = -a*omega*`sinθ`-m*`cosecθ`+n*`cotθ`+`∂__θ`

Also I divided the differential equation in 3 parts (A, B, C).

F := (omega*a*sin(theta)+m/sin(theta)+1/(2*tan(theta)))(diff(S(theta), theta)-omega*a*sin(theta)*S(theta)-m*S(theta)/sin(theta)+S(theta)/(2*tan(theta)))+diff(S(theta), theta, theta)-omega*a*sin(theta)*(diff(S(theta), theta))-m*(diff(S(theta), theta))/sin(theta)+(diff(S(theta), theta))/(2*tan(theta))

G := a*`μ__e`*sin(theta)*(diff(S(theta), theta)-omega*a*sin(theta)*S(theta)-m*S(theta)/sin(theta)+S(theta)/(2*tan(theta)))/(lambda+a*`μ__e`*cos(theta))

H := (2*(lambda^2+a^2*`μ__e`*cos(theta)^2))*S(theta)

DF := F+G+H

dsolve(DF)

dsolve({DF, DF(0) = 1}, numeric, range = 0 .. 20)

Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem

 

NULL

Download DIFFERENTIAL_EQUATION.mw

Dear Power Users, I tried to make a model in Maple but after several hours of struggling I need some help. Can someone tell me what I did wrong or explain to me what is the meaning of the maplemint comment on procedure (optimalisatie)? Thank you in advance.

DiLeoCasper.mw 

For the t output I need to show 1, 1.2, 1.4....2, my attempt is highlighted in green below

Can anyone assist please?

#Clear memory and load packages.
restart;
with(plots):
with(Statistics):

#Define vectors and variables.
actual:=<2,3.5136,5.8016,9.1136,13.7376,20>:
t:=<1,1.2,1.4,1.6,1.8,2>:
n:=6:
RMSE:=0:

#Perform a simple linear regression on the data.
P:=LinearFit([1,x],t,actual,x);

#Display the model errors.
printf("t    Actual P  Model P  Error\n");
for i from 1 to n do
   model:=subs(x=t[i],P):
   err:=actual[i]-model:
   RMSE:=RMSE+err^2:
   printf("%2d %7.4f% 10.4f% 9.4f\n",(i+(1/5)),actual[i],model,err);
end do:

#Display the root mean square error.
RMSE:=sqrt(RMSE/n);

#Plot the points and the model.
p1:=plot(t,actual,style=point,view=[0..7,8..26]):
p2:=plot(P,view=[0..7,8..26]):
display(p1,p2);

-HFloat(17.540266666666668)+HFloat(17.712)*x

 

t    Actual P  Model P  Error

 

Error, (in fprintf) integer expected for integer format

 

HFloat(0.7463867411787324)

 

 

NULL

Download Asst_4_Question_1f.mw

Hello,
I recently discovered the "Physics" package wich provides tools for manipulating abstract vectors (non-component).
In the "Physics:-Vectors", an orthonormal basis (i,j,k) is available and my main concern is how to generate arbitrary other 3D orthonormal bases to be able to calculate results in "vectorial form" without manipulating vectors' components.

To better explain my needs I have setup a kind of minimal example in the attached file where some questions are asked.

Thanks in advance for any feedback.

orthonormal-triads.mw

NULL

restart

with(Physics)

with(Physics[Vectors])

Creation of 2 rotation matrices

dir1 := `<,>`(0, 0, 1)

dir2 := `<,>`(0, 1, 0)

seq(assign(cat(R, i), Student:-LinearAlgebra:-RotationMatrix(theta[i], eval(cat(dir, i)))), i = 1 .. 2)

print(R1, R2)

Matrix(%id = 36893490614987576012), Matrix(%id = 36893490614987577572)

(1)

whattype(R1)

Creation of  orthogonal unit "Physics:-Vectors" from previous matrices

x1_ := _i*R1[1, 1]+_j*R1[2, 1]+_k*R1[3, 1]``

y1_ := _i*R1[1, 2]+_j*R1[2, 2]+_k*R1[3, 2]

z1_ := _i*R1[1, 3]+_j*R1[2, 3]+_k*R1[3, 3]NULL

NULL

x2_ := _i*R2[1, 1]+_j*R2[2, 1]+_k*R2[3, 1]NULL

y2_ := _i*R2[1, 2]+_j*R2[2, 2]+_k*R2[3, 2]

z2_ := _i*R2[1, 3]+_j*R2[2, 3]+_k*R2[3, 3]

Q1: Is there a more elegant way of creating "Physics:-Vectors" from matrices ?

Now, suppose that we want to compute `&x`(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`) : since `#mover(mi("y2"),mo("&rarr;"))` = `#mover(mi("j"),mo("&and;"))` we have `&x`(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`) = sin(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("j"),mo("&and;"))`)*`#mover(mi("z1"),mo("&rarr;"))` and sin(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("j"),mo("&and;"))`)*`#mover(mi("z1"),mo("&rarr;"))` = sin((1/2)*Pi-`&theta;__1`)*`#mover(mi("z1"),mo("&rarr;"))` and sin((1/2)*Pi-`&theta;__1`)*`#mover(mi("z1"),mo("&rarr;"))` = cos(theta[1])*`#mover(mi("z1"),mo("&rarr;"))`

The cross product operator  `&x`(x1_, y2_) yields

cos(theta[1])*_k

(2)

(which is a correct answer) instead of cos(theta[1])*`#mover(mi("z1"),mo("&rarr;"))` because vector `#mover(mi("z1"),mo("&rarr;"))` has is not known as a unit basis vector.

Similarly, `&x`(z1_, x1_) yields -sin(theta[1])*`#mover(mi("i"),mo("&and;"))`+cos(theta[1])*`#mover(mi("j"),mo("&and;"))` instead of  `#mover(mi("y1"),mo("&rarr;"))` as it would be the case when computing `&x`(_k, _i) ?

Q2: Is there a way to declare new triads of "Physics:-Vectors" with properties similar to the provided triad _i, _j, _k ?

Q3: Is the code defining the canonical basis i, _j, _kavailable for inspection and inspiration to setup orthonormal triads ?

Q4: Is it possible to get a (column) matrix of the vector components ? The function Physics:-Vectors:-Component(y1_, n) can only get 1 component at a time and only in the canonical basis i, _j, _k.

NULL

restart

with(Physics)

with(Physics[Vectors])NULL

After a proper definition of 2 new vector bases `#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y1"),mo("&rarr;"))`, `#mover(mi("z1"),mo("&rarr;"))` and `#mover(mi("x2"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`, `#mover(mi("z2"),mo("&rarr;"))`, the position vector OM_ := l__1*x1_+l__2*x2_NULLNULL

l__1*x1_+l__2*x2_

(3)

NULL

projected on `#mover(mi("x2"),mo("&rarr;"))` would yield directly Typesetting[delayDotProduct](l__1, `#mover(mi("x2"),mo("&rarr;"))`.`#mover(mi("x1"),mo("&rarr;"))`, true)+l__2 instead of expand(OM_.x2_)

l__1*Physics:-Vectors:-`.`(x1_, x2_)+l__2*Physics:-Vectors:-Norm(x2_)^2

(4)

because of the unit vectors.

Download orthonormal-triads.mw

This used to work in Maple 2022.  Something is broken in 2023. 

 

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1561 and is the same as the version installed in this computer, created 2023, October 20, 22:58 hours Pacific Time.`

U := Int(exp(-1/4*t - 1/4*x)*piecewise(x < -2, 1, x < -1, -x - 1, 0), x = -t .. 0);

Int(exp(-(1/4)*t-(1/4)*x)*piecewise(x < -2, 1, x < -1, -x-1, 0), x = -t .. 0)

Uval := simplify(value(U));

Uval := `simplify/piecewise/unfactor`(4*piecewise(t < 1, 0, t < 2, t-5+4*exp(`&ndash;`((1/4)*t)+1/4), 2 <= t, 1+4*exp(`&ndash;`((1/4)*t)+1/4)-4*exp(`&ndash;`((1/4)*t)+1/2)))

eval(Uval, {x=5, t=6});

`simplify/piecewise/unfactor`(4+16*exp(-5/4)-16*exp(-1))

 
 

Download simplify-piecewise-bug.mw

 

Maple thinks the inverse Laplace transform of 1/(s+a) is exp(a*t).  It should be exp(−a*t).

This used to work correctly in Maple 2022.  Something got messed up in 2023.

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

with(inttrans):

exp(-a*t);

exp(-a*t)

laplace(%, t, s);

1/(s+a)

invlaplace(%, s, t);

exp(a*t)

 

Download laplace-transform-bug.mw

This is not a critical situation. A solution was developed. However, I am interested in trying to understand and explain to a colleague why their function failed to plot. The colleague often works on problems involving large factorial values.

failed_plot.mw

Hi Everyone, 

I have a numeric integral which I hope to evaluate (ideally over a infinite domain) that for some reason is giving me difficulty and I cannot seem to find a work around. I want to use method = _d01amc in the integral as a means to speed up the process - I am motivating this by the answer i recieved from @acer in https://www.mapleprimes.com/questions/236772-Any-Ideas-On-How-To-Speed-Upimprove - however I keep recieving an error indicating overflow. 

This seems rather strange to me due to the fact that if I omit a method and just let Maple do its own thing it will eventually spit out an answer albeit slower then I would prefer for the procedure I am going to eventually impliment. 

My integrand and attempts/confusion can be seen in the attached worksheet. 

Any thoughts appreciated. 

OverflowError.mw

The sequence A161786 consists of “primes with at least one digit appearing exactly four times in the decimal expansion”. Below is the Maple program given in that OEIS page:

The code above picks out primes having exactly four identical digits (determined by ) from the first 10,000 prime numbers. However, it's easy to check that this program is rather slow (It takes about 2.6s to execute it!). 
Actually, I would like to select such primes from pn, pn+1, pn+2, …, pn+m-1 (typically, n=1,000,000 and m=1,000,000), where pk denotes the k-th prime number, yet the original program failes to do so in twenty minutes. Part of the reason is that for long sequences, the efficiency can be critical. Therefore I make a slight modification to the original code: 

A161786__0 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	#(*
	    kernelopts(opaquemodules = false):
	# *)
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := Vector('datatype' = prime);
	to m do
		if ormap(`=`, MultiSet(`convert/base`:-MakeSplit(length((p := nextprime(p))), 1, 10)(p)):-hash, 4) then
			vec ,= p
		fi
	od;
	vec
end:

Nevertheless, this version is still inefficient: 

time[real](A161786__0(10**6, 10**6));
 = 
                            182.414

Another choice is converting each of integers into a string: 

A161786__1 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	options no_options:
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := DEQueue();
	to m do
		if member(4, rhs~({StringTools['CharacterFrequencies'](nprintf("%d", (p := nextprime(p))), 'digit')})) then
			vec ,= p
		fi
	od;
	Vector([vec[]], 'datatype' = prime)
end:

This time the elapsed time is reduced to nearly two minutes: 

time[real](A161786__1(10**6, 10**6));
 = 
                            118.409

But can this task be accomplished within (a quarter of) a minute in modern Maple? In other words, is there a way to make further improvement on the performance? (Note that the reference time is mesured using a adjusted version (i.e., ) of the Mma code provided in that OEIS page.) 

When printing a Maple Worksheet  often I go in the PrintPrewiev of the Mac and then select some sides to print.

This is not working anymore since I have updated from Maple 2021 to Maple 2023.

Is this known ?

Any help for his ?

Can anyone assist with this error please?

#Clear memory and load package.
restart;  
with(LinearAlgebra):

#Initialise variables,matrices and vectors.
b:=<<18>,<-2>>:
c:=<<1>,<1>>:
i:=0:
P:=<1.08,1.37,1.56,1.61>;
t:=<5,10,15,20>;
tol:=1e-6:

#Initialise Gauss-Newton matrices.
n:=Dimension(t):
f:=Matrix(n,1):
J:=Matrix(n,2):

#Display initial parameter values.
printf("Gauss-Newton Method\n");
printf("-------------------\n");
printf("Before iterations,A = %f and B = %f\n",b(1),b(2));

#Perform the Gauss-Newton method.
while max(abs(evalf(c)))>tol do
  i:=i+1;
  for r from 1 to n do
     f(r,1):=evalf((In(b(1)+t[r])+b(2))-P[r]);
     J(r,1):=evalf(1/b(1)+t[r]);
     J(r,2):=evalf(1);
end do;
c:=Multiply(MatrixInverse(Multiply(Transpose(J),J)),Multiply(Transpose(J),f));
b:=b-c;
printf("After iterations %d, A = %f and B = %f\n",i,b(1),b(2));
end do:

Vector(4, {(1) = 1.08, (2) = 1.37, (3) = 1.56, (4) = 1.61})

 

Vector[column](%id = 36893488152076174028)

 

Gauss-Newton Method
-------------------
Before iterations,A = 18.000000 and B = -2.000000
After iterations 1, A =

 

Error, (in fprintf) number expected for floating point format

 

NULL

Download Asst_3_Q4b.mw

The x region is z<x<1 and y region is 0<y<pi//3, I think there is an error in the j values in the loop

Can anyone assist please?

#Clear memory.
restart;

#Initialise variables and arrays.
h:=0.1;
k:=Pi/30;
c:=1:
iter:=0:
tol:=1e-5;
w:=1.5;
u:=Array(0..10,0..10):
U:=Array(0..10,0..10):

#Calculate boundary u values.
for i from 0 to 10 do

   u[i,Pi/3]:=0;
   u[i,0]:=0;
end do:

for j from 0 to Pi/3 do
   u[0,j]:=0;   
   u[10,j]:=sin(3*j*k)/2;
end do:
#Perform the Gauss-Seidel method.
while c>tol do
   iter:=iter+1;
   if iter>99 then
      printf("\nGauss-Seidel method did not converge,change w.\n");
   break;
end if:
for i from 1 to 9 do
  for j from 0 to Pi/3 do
     U[i,j]:=u[i,j];
     u[i,j]:=(10*Pi^2*u[i-1,j]+9*u[i,j-1]+9*u[i,j+1]+2*Pi^2*u[i+1,j])/20;
     u[i,j]:=w*u[i,j]+(1-w)*U[i,j];
  end do:
end do:
c:=max(abs(u[1..9,1..9]-U[1..9,1..9]));
printf("After iteration %2d,the maximum change in u is %7.1e\n",iter,c);
end do:

#Display the final u values if method converged.
if iter<100 then
    printf("\nGauss-Seidel Method\n");
    printf("-------------------\n");
    for j from 10 by -1 to 0 do
      for i from 0 to 10 do
        printf("%6.4f",u[i,j]);
    end do:
    printf("\n");
end do:
end if:

.1

 

(1/30)*Pi

 

0.1e-4

 

1.5

 

Error, bad index into Array

 

Error, final value in for loop must be numeric or character

 

Error, final value in for loop must be numeric or character

 


Gauss-Seidel Method
-------------------
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000

 

NULL

Download Asst_3_Q3c.mw

Hello. I have a problem with the phaseportrait and I hope could help me with this:

I can import maple, but I get an error when importing namespace/symbols:

import maple.namespace as mpl

First 15 16 17 18 19 20 21 Last Page 17 of 31