Maple 2023 Questions and Posts

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

This is something I use a fair bit. I have procedures with alternative spelling options for the colours Red Green and Blue.
Have shown a single example copied from  an overloaded procedure. It there a nicer way of handling this than what I am doing?
There is a section in help under "Procedure Parameter Declarations" on "Indexed Keyword Parameters"  but I don't see how to use it here. These procedures are used inside a package.

restart

 

GeomClr:="Blue";  # can be "Blue", "blue", "B", "b"  or;
                  #        "Green", "green", "G", "g"  or;
                  #        "Red2, "red", "R", "r";

Prntmsg:="y" ; #  or anything that is not"y"

 

"Blue"

 

"y"

(1)

spread:=proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
              p1::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
              clr::`string`:= GeomClr,
              prnt::`string`:=Prntmsg)
           option overload;
           uses LinearAlgebra;
           #print(clr,p0,p1);
           if clr="b" or clr="B" or clr="blue" or clr="Blue" then
              if prnt="y" then
                print("Spread 2 [x,y] Points/Vectors wrt origin Blue");
              end if;
               return 1 - BilinearForm(p0, p1, conjugate = false)^2/(BilinearForm(p0, p0, conjugate = false)*BilinearForm(p1, p1, conjugate = false));
           elif clr="g" or clr="G" or clr="green" or clr="Green" then
              if prnt="y" then
               print( "Spread 2 [x,y] Points/Vectors wrt origin Green");
              end if;
               return -1/4*(p0[1]*p1[2] - p0[2]*p1[1])^2/(p0[1]*p0[2]*p1[1]*p1[2]);
           elif clr="r" or clr="R" or clr="red" or clr="Red" then
              if prnt="y" then
               print( "Spread 2 [x,y] Points/Vectors wrt origin Red");
               end if;
               return -(p0[1]*p1[2] - p0[2]*p1[1])^2/((p0[1]^2 - p0[2]^2)*(p1[1]^2 - p1[2]^2));
          end if;
          end proc:

sb:=spread(<3|2>,<4|-5>);

"Spread 2 [x,y] Points/Vectors wrt origin Blue"

 

529/533

(2)

sg:=spread(<3|2>,<4|-5>,"g");

"Spread 2 [x,y] Points/Vectors wrt origin Green"

 

529/480

(3)

sr:=spread(<3|2>,<4|-5>,"r");

"Spread 2 [x,y] Points/Vectors wrt origin Red"

 

529/45

(4)

1/sb+1/sr+1/sg

2

(5)

sr:=spread(<3|2>,<4|-5>,"r","n");

529/45

(6)

 


 

Download Q_2024-02-09_Alternative_Spelling_in_Proc.mw

For example, given plot f(x)= x^5+x. plot the function given by g(x)= f(x-2)+3

Also, when plotting my graphs they look different than other graphing software.

I was trying this ode with Maple

Do you agree this solution is not correct by Maple?

restart;

ode:=diff(y(t),t)+y(t)=Dirac(t);
ic:=y(0)=1;
sol:=dsolve([ode,ic],y(t),method='laplace');

It gives  y(t) = 2*exp(-t)

But from the discussion in the above link we see this is wrong solution. Maple also does not verify it:

odetest(sol,[ode,y(0)=1])

[-Dirac(t), -1]

Would this be considered a bug I should report or not? Note this result is only when using Laplace method. The default method gives better solution.

ode:=diff(y(t),t)+y(t)=Dirac(t);
ic:=y(0)=1;
sol:=dsolve([ode,ic],y(t));
odetest(sol,[ode,y(0)=1])

 

Maple 2023.2.1

The overloaded  procedure here test returns based on 2 lists or 3 lists entered. The two list has a mixed input type with a default value. The default value of "a" can cause a problem if an explicit value in not entered for "a" in foo1. I not sure is the mixed input type is adding to the problem.
By changing the order of the procedures the problem is avoidable here. But this just a simple example. When there are 6 or so procedures it can be very difficult to select a correct ordering.

Is there a way around this, apart from don't have default values?

I could experiment with changing the input order in each proc but that would break up some logical input sequences on me.

restart

 

foo:=overload([
                        proc(P1::list,P2::list,a::algebraic:=4,$)
                         option overload;
                         print("2 lists");
                          end proc,

                       proc(P1::list,P2::list,P3::list,$)
                         option overload;
                         print("3 lists");
                          end proc
                       ]);

proc () option overload; [proc (P1::list, P2::list, a::algebraic := 4, ` $`) option overload; print("2 lists") end proc, proc (P1::list, P2::list, P3::list, ` $`) option overload; print("3 lists") end proc] end proc

(1)

foo([1,2],[3,4])

"2 lists"

(2)

foo([1,2],[3,4],[4,7])

"3 lists"

(3)

 

 

 

foo1:=overload([
                        

                       proc(P1::list,P2::list,P3::list,$)
                         option overload;
                         print("3 lists");
                          end proc,

                        proc(P1::list,P2::list,a::algebraic:=4,$)
                         option overload;
                         print("2 lists");
                          end proc
                       ]);

proc () option overload; [proc (P1::list, P2::list, P3::list, ` $`) option overload; print("3 lists") end proc, proc (P1::list, P2::list, a::algebraic := 4, ` $`) option overload; print("2 lists") end proc] end proc

(4)

foo1([1,2],[3,4]); #incorrect output

"3 lists"

(5)

foo1([1,2],[3,4],4)

"2 lists"

(6)

foo1([1,2],[3,4],[4,7])

"3 lists"

(7)

 

Download 2024-02-3_Q_Overload_proc_.mw

I am trying to plot the following.

it consist of a line and a circle.

if tried doing it as so:

f := x -> piecewise(0 <= x and x <= 1.588125352, (-1)*0.39*x^2 + 1.459*x - y, 1.588125352 <= x and x < 4, (x - 1.81)^2 + (y - 0.42)^2 + (-1)*0.94^2);

implicitplot(f(x), x = 0 .. 3, y = 0 .. 1.5, scaling = constrained);

every time i get this ugly line in the point where the funktion switches and i can't seem to remove it.

I've tried discont = true, but it doesn't seem to work on implicitplots. 

It is &ndash; that is not rendered.

Maple 2023

For comparision Maple 2022.

Can someone reproduce this? Anything I can do about it (some settings maybe)?

Both session directly after restart of Maple.

Hello

I need to share some results with a colleague who is not a user of Maple, and a way to do this is by using the Tabulate (plain command and not from DocumentTools) function to format them. In the worksheet, the output looks good, but when I try to print it or save it as a PDF, only a few lines are printed. It appears that Maple is not able to break the tables into multiple pages for printing.

The output is a table with 77 rows and 30 columns.   

I welcome alternative solutions to the problem of displaying the results. 

Many thanks

This is probably a dummy question. I have a matrix (3 columns, 4 rows). I would like to extract the rows in which the value in the third column matches "2". As long as one has a matrix of 2 columns, this can be easily done by using the Lookup command but it does not allow you to give the row values of multiple columns. Is there another command that allows you to do that?

Thank you in advance for your help.

FindRowInMatrix.mw

I am trying to calculate the line element ds^2, for a de Sitter spacetime in 2+1 dimensions with positive cosmological constant, using the following metric and energy moment tensor:
1- ds² = -A(r) c^2 dt^2 + B(r) dr^2 + r^2d{\theta}^2,
2- T^{\mu \nu} = -(\rho + p) dx^{\mu} dx^{\nu} + p g^{\mu \nu}.

I tried several ways but I can't solve it using Maple 2023, Physics package. Could someone show me step by step how to solve this problem?

Images of the line element we need to find, the metric tensor associated with the problem and the components of the Riemann tensor.
My goal is to calculate the metric tensor, line element and associated components of the Riemann tensor for De Sitter spacetime with positive cosmological constant.

Question deleted since it tagged duplicate. Will go search for the duplicate. I did not know there was duplicate one.

update

Here is original question. If moderator thinks it is duplicate feel free to delete. 

I would like to duplicate this simplification done in Mathematica, but in Maple. Mathematica will cancel the exponential term automatically if told the domain is real, but in Maple it willl not.

My attempts in Maple which all fail

restart;


ode := diff(v(x), x, x)*exp(x^2) = 0;
simplify(ode);
simplify(ode) assuming real; #there is no such type
simplify(ode) assuming x::positive;
simplify(ode,symbolic);
use RealDomain in simplify(ode) end use;

How to cancel the exponential term from the above equation in Maple?

Hi,

How to insert the notation of a vector, with an arrow? thanks

S5VecteurTextPlot.mw

evalf(Pi*int(2*299792458^2*662607015*10^(-8)*10^(-34)/((exp(299792458*662607015*10^(-8)*10^(-34)/(1380649*10^(-6)*10^(-23)*lambda*5772.0)) - 1)*lambda^5), lambda = 0 .. infinity));

returns a complex number for the Solar radiant exitance in watts per square meter with an effective blackbody temperature of "5772.0" kelvins.

Replacing "5772.0" with an exact "5772" gives the correct answer though.  The nominal Solar temperature is defined as exactly 5772 kelvins whereas the physical Solar effective temperature is 5772.0 K (+/-) 0.8 K.

Is there a way to get Maple 2023 to avoid outputting these types of errors when using nonexact quantities?

I tried replacing "5772.0" with "5772.00000000001" and "5771.9999999999" and the error is not duplicated for those kelvin temperatures.

Interestingly, this error does not occur on Maple for Excel, only within the Maple desktop client....

https://scienceworld.wolfram.com/physics/Stefan-BoltzmannLaw.html

https://iopscience.iop.org/article/10.3847/0004-6256/152/2/41/

I'm currently addressing a problem related to modified Bessel functions using an older version of Maple (the specific version escapes my memory). In an attempt to resolve issues, I've experimented with the trial version of Maple 2023, but I've encountered an unusual phenomenon. Expressions that were previously simplifiable in Maple now resist simplification. The specific expression provided below, which should equate to 1, fails to be recognized as such by Maple. This poses a concern as it could lead to overly complex expressions in subsequent steps, considering this expression is only an intermediate stage. Is there a recommended approach to overcome this challenge?

f := (BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

(BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

simplify(f)

(BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

eval(f, alpha = .25)

1.000000000

NULL

Download question.mw

Hello

I could not come up with a better title, so I apologize for that.  Let me explain what I am trying to implement using an example. 

Consider the following list of monomials (a 3D model,  4 monomials altogether):

model := [x^2*y*alpha[1, 11], x*z^2*alpha[2, 15], y^2*z*alpha[3, 17] + y*z*alpha[3, 8]]

The idea is to generate the set of all models by adding a non-repetitive monomial from the following list to model.

[alpha[i, 0], alpha[i, 1]*x, alpha[i, 2]*y, alpha[i, 3]*z, alpha[i, 4]*x^2, alpha[i, 5]*y*x, alpha[i, 6]*z*x, alpha[i, 7]*y^2, alpha[i, 8]*z*y, alpha[i, 9]*z^2, alpha[i, 10]*x^3, alpha[i, 11]*y*x^2, alpha[i, 12]*z*x^2, alpha[i, 13]*y^2*x, alpha[i, 14]*z*y*x, alpha[i, 15]*z^2*x, alpha[i, 16]*y^3, alpha[i, 17]*z*y^2, alpha[i, 18]*z^2*y, alpha[i, 19]*z^3]

where i indicates the coordinate where the monomial will be included.  Example: if alpha[i, 2]*y is to be added to the second coordinate of model it goes as alpha[2,2]*y. Note that alpha[i, 15]*z^2*x cannot be added to coordinate 2 since it is already there.  

The result will be a list of 56 models with 5 monomials. 

How can I do that efficiently?  

Many thanks

Ed.

PS. I have implemented something similar to the problem above, but I have used too many 'for' loops. 

[Right-click on image and open in new tab to see larger]

To Scan Math with the Maple Calculator and show solution steps in Maple:

1. first scan some math with the calculator

2. Maple calculator immediately shows the solution if that is what you are looking for:

3. Calculator gives options to show the solution steps in the calculator itself ( footprint button in top-right) 

4. Or to upload the math to the MapleCloud (cloud icon with up arrow)

5. Once the math is uploaded, MapleCloud can be loaded on a desktop computer and the file opened from your account's Maple Calculator group of files:

6. Again, the solution and some more details are visible on Maple Cloud:

7. To open this math in Maple, click the blue button to Download the file.

The downloaded file can then be loaded in Maple:

8. The Maple commands to solve this math are shown, and the result. 

To show steps in Maple at this point, convert the math to inert form, then run the Student:-Calculus1:-ShowSolution() command on it:

Ex := Int(3.(x^2), x = 0 .. 7)

Int(3*x^2, x = 0 .. 7)

(1)

Integrate

 

The solution to this integral is:

int(3*x^2, x = 0 .. 7)

343

(1.1)

Student:-Calculus1:-ShowSolution(Ex)

"[[,,"Integration Steps"],[,,(&int;)[0]^73 x^2 &DifferentialD;x],["&EmptyVerySmallSquare;",,"1. Apply the" "constant multiple" "rule to the term" &int;3 x^2 &DifferentialD;x],[,"?","Recall the definition of the" "constant multiple" "rule"],[,,&int;[] f(x) &DifferentialD;x=[] (&int;f(x) &DifferentialD;x)],[,"?","This means:"],[,,&int;3 x^2 &DifferentialD;x=3 (&int;x^2 &DifferentialD;x)],[,,"We can rewrite the integral as:"],[,,3 ((&int;)[0]^7x^2 &DifferentialD;x)],["&EmptyVerySmallSquare;",,"2. Apply the" "power" "rule to the term" &int;x^2 &DifferentialD;x],[,"?","Recall the definition of the" "power" "rule, for n" "<>" "-1"],[,,&int;x^[] &DifferentialD;x=[]],[,"?","This means:"],[,,&int;x^2 &DifferentialD;x=[]],[,"?","So,"],[,,&int;x^2 &DifferentialD;x=(x^3)/3],[,"?","Apply limits of definite integral"],[,,[]-([])],[,,"We can rewrite the integral as:"],[,,343]]6""

(2)

Download MapleCalculatorMathCloudUpload.mw

5 6 7 8 9 10 11 Last Page 7 of 30