Maple 2020 Questions and Posts

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

Dear all,
I would like to get the Null Vectors of some matrix B but not those which are returned by NullSpace(B), i would like to get specific structure of the Kernel, i mean, i want to get the following structure of the Kernel when the matrix B is 10*10 for example:

Kernel= {
Vector[column](10, [0, 0, 0, 0, 0, 0, 0, 0, 0, alpha]),
Vector[column](10, [0, 0, 0, 0, 0, 0, 0, 0, alpha, beta]),
Vector[column](10, [0, 0, 0, 0, 0, 0, 0, alpha,beta, gamma]),
Vector[column](10, [0, 0, 0, 0, 0, 0, alpha, beta, gamma, delta])
              }
Is it possible to do that with Maple ? Have you some ideas ? 
In other words,  could you help me please ?

Best regards

What do folks think about adding \, space automatically after Maple's Latex output for sqrt command?

This is all using the new Latex command. Not the orginal latex() command.

For me, it looks much better. I did some tests, and see no negative effect by always adding \, at the end of \sqrt{}

The reason is this: If there is a symbol after sqrt(.....)<HERE> then the math looks like the symbol is almost inside the integral, when it should be out. By adding \, this makes it more clear and better looking.

It is possible to write macro in Latex to do this in preamble I suppose. But if it can be done in the source, then that will be much better as it will always be there without the need to write complicated macro to change it later in Latex. 

Here are 4 expressions to compare

One can see the current problem area and the effect of adding \, automatically. The space was added for each case above in the second column, even for those where it was needed (second and third expressions) to show that adding space has no negative side-effect even when not needed.

Here is the above raw latex used, compiled on Tex Live 2020 on Linux,  and the Maple worksheet below that.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage{mleftright}  
\mleftright

\begin{document}

\begin{longtable}{|p{3in}|p{3in}|}\hline
Default. No space after & With space added after\\\hline 
\[
\sqrt{\left(3+x \right)^{2}+1} a +\sin \left(x \right)
\]
&
\[
\sqrt{\left(3+x \right)^{2}+1}\, a +\sin \left(x \right)
\]\\\hline 
\[
\frac{\sqrt{\left(3+x \right)^{2}+1}}{5}+b
\]
&
\[
\frac{\sqrt{\left(3+x \right)^{2}+1}\,}{5}+b
\]\\\hline 
\[
\frac{\sqrt{x}}{5}+b
\]
&
\[
\frac{\sqrt{x}\,}{5}+b
\]
\\\hline 
\[
\frac{\sqrt{x^{2}+6} c}{5}+b
\]
&
\[
\frac{\sqrt{x^{2}+6}\, c}{5}+b
\]\\\hline 
\end{longtable}

\end{document}


 

interface(version);
Physics:-Version();

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

`The "Physics Updates" version in the MapleCloud is 882. The version installed in this computer is 881 created 2020, November 21, 11:11 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2020\Physics Updates\lib\`

restart;

Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true,
      cacheresults = false
);

`* Partial match of  '`*UseImaginaryUnit*`' against keyword '`*useimaginaryunit*`' `

`* Partial match of  '`*UseColor*`' against keyword '`*usecolor*`' `

[powersoftrigonometricfunctions = computernotation, leavespaceafterfunctionname = true, cacheresults = false, useimaginaryunit = i, usecolor = false]

expr1:=sqrt((3+x)^2+1)*a+sin(x);
Latex(expr1)

((3+x)^2+1)^(1/2)*a+sin(x)

\sqrt{\left(3+x \right)^{2}+1} a +\sin \left(x \right)

expr2:=sqrt((3+x)^2+1)/5+b;
Latex(expr2)

(1/5)*((3+x)^2+1)^(1/2)+b

\frac{\sqrt{\left(3+x \right)^{2}+1}}{5}+b

expr3:=sqrt(x)/5+b;
Latex(expr3)

(1/5)*x^(1/2)+b

\frac{\sqrt{x}}{5}+b

expr4:=(sqrt((3+x^2)+3)*c)/5+b;
Latex(expr4)

(1/5)*(x^2+6)^(1/2)*c+b

\frac{\sqrt{x^{2}+6} c}{5}+b

 


(typo, should be sqrt, not int)

Download space_after_int.mw

I am having hard time understanding why Maple does this.

I have an integral, which maple could not integrate. So it returns int(....,x). Which is all fine. Then I used subsindets to force all terms in form e^(ln()+ln()+...) to expand in order to simplify the integrand, just for display purposes. 

subsindets returns back the integral unevaluated (as expected) but with integrand a little simpler, again as expected.

All is well so far.  

Then I find to my surprise, if I type the result back one more type, now the the integral actually evaluates.

Why? 

I have 2 questions on this.

1) If the original integral did not evaluate, why simplifying e^(ln()+ln()+...) makes it now evaluate? Did not Maple know this allready?

2) Why result back from subsindets remained unevaluated integral, and I had to type it again to see it now evaluates?

I found this after long time debugging, since this was done in code, not looking at screen. 

What happened is this: I store the result  of subsindets in a variable, and when I look at it in the debugger, I see int() still there, as expected.

I call a function to return back this result. I now see int() is gone!   So the act of just returning the result back, caused it to evaluate. Even though the orginal variable still had int() in it as. So returning the expression back, was equivalent to typing it again on the screen in the example below, which caused it to evaluate. 


Please see worksheet below.

interface(version);

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 882. The version installed in this computer is 881 created 2020, November 21, 11:11 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2020\Physics Updates\lib\`

restart;

expr:=int(-1/2*exp((ln(a+cos(1/2*x)^2)+(-2*a-2)*ln(cos(1/2*x)))/a)*(-1+cos(x))/sin(1/2*x)/cos(1/2*x)/(a+cos(1/2*x)^2),x);

int(-(1/2)*exp((ln(a+cos((1/2)*x)^2)+(-2*a-2)*ln(cos((1/2)*x)))/a)*(-1+cos(x))/(sin((1/2)*x)*cos((1/2)*x)*(a+cos((1/2)*x)^2)), x)

#try again
expr;

int(-(1/2)*exp((ln(a+cos((1/2)*x)^2)+(-2*a-2)*ln(cos((1/2)*x)))/a)*(-1+cos(x))/(sin((1/2)*x)*cos((1/2)*x)*(a+cos((1/2)*x)^2)), x)

expr:=subsindets(expr,'specfunc( anything, exp )',f->(`if`(has(op(1,f),'ln'),expand(f),f)));

int(-(1/2)*(a+cos((1/2)*x)^2)^(1/a)*(-1+cos(x))/(cos((1/2)*x)^3*(cos((1/2)*x)^(1/a))^2*sin((1/2)*x)*(a+cos((1/2)*x)^2)), x)

#notice, the above is still int. Why is typing expr again, now makes it evaluate??
expr

-((4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*(2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*Pi*csgn(I*cos((1/2)*x))^3+2*Pi*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-Pi*csgn(I*exp(I*x))^3+2*Pi*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-Pi*csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2-Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))+Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3-Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-4*x*a)/a)/((exp(I*x)+1)^(1/a))^2-2*(4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*(2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*Pi*csgn(I*cos((1/2)*x))^3+2*Pi*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-Pi*csgn(I*exp(I*x))^3+2*Pi*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-Pi*csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2-Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))+Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3-Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-2*x*a)/a)/((exp(I*x)+1)^(1/a))^2+(4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*Pi*(2*csgn(I*exp(I*x)+I)*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*csgn(I*cos((1/2)*x))^3+2*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-csgn(I*exp(I*x))^3+2*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2+csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))-csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3)/a)/((exp(I*x)+1)^(1/a))^2)/((a+1)*(exp(I*x)+1)^2)

 


 

Download why_it_now_evaluates.mw

Another simpler example, is just doing assignment to new variable. This causes evaluation.

restart;
expr:=int(-1/2*exp((ln(a+cos(1/2*x)^2)+(-2*a-2)*ln(cos(1/2*x)))/a)*(-1+cos(x))/sin(1/2*x)/cos(1/2*x)/(a+cos(1/2*x)^2),x);
expr:=subsindets(expr,'specfunc( anything, exp )',f->(`if`(has(op(1,f),'ln'),expand(f),f)));
#the above still has int() in it.

#this assignment, also causes evaluation
A:=expr;

 

What is the logic behind this. 

restart;
expr:=int(f(x),x);
lprint(algsubs(int=Int,expr));
lprint(subs(int=Int,expr));

gives


   int(f(x),x)

   Int(f(x),x)

So algsubs failed to replace int by Int

Looked at help. and see nothing. But I might have overlooked something. It says

It is a generalization of the subs command, which only handles syntactic substitution.

Generalization? If so, I expected it to work here. But may be there is a subtle reason why it did not? May be with algsubs, the replacement has to be algebraic expression and "int" is not, it is just a name.

Maple 2020.2
 

Hello Maple experts.

According to our teacher class notes, the ODE   y'=2*sqrt(y) with IC  y(0)=0 has 2 solutions. y(0)=0 and sqrt(y)=x

I am not able to get Maple to give the second solution,. It only gives y(0)=0.

Is there an option I am overlooking to make it give the other solution sqrt(y)=x ?

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=0;
sol:=dsolve([ode,ic],y(x));

One can see the other solution by doing this

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=A;
sol:=dsolve([ode,ic],y(x));
subs(A=0,sol)

I tried this in Mathematica. Mathematica does not give y=0 but it gives the second solution

I tried the singsol=all also, but it had no effect. Maple only shows the y(0)=0 solution.

Any suggestions?

Maple 2020.2

 

Hello everyone,

I have a question about adding references to a non executable math in a document. Namely, If we use an executable math there is a label that appears on the right of a formula. We can use it as a reference. However, there is no label when we use non-executable math. I wonder how can I refer to that, the point is to create a document with a references to formulas.

To illustrate the point I would like to create a text like the following :

...

X=2 (equation 1)

X=3 (equation 2)

.....Some text here......

From the (equation 2) we can achieve that ....

Regards

Hello everybody,

 

Being a beginner in maple, I tried to make some animations involving geometrical objects.

I haven't been through any problems for typical 2-variables or 3-variables functions.

However, I couldn't get to making 3d-objects like spheres/cylinders.... to grow in link with a parameter (radius, axes...)

I've found lots of procedures to get sphere to rotate but I didn't succeed in adapting them to, for example, an animation showing a growing zero-centered sphere from radius zero to a radius n (variable entered by the user).

Thank you for your reading, your patience and your kindness.

 

inside a local proc, when calling a  function such as map using the syntax map(x->x^2, target) does one need to declare as local inside the proc?

Same for other Maple calls, which uses something similar. For example 

subsindets(expr,'specfunc( anything, csgn )', f->simplify(f));

does one need to declare local to the proc where the above call is made?

Which one of these two example is more correct?

restart;
foo:=proc(expr)
  local x;
  map(x->x^2,expr);
end proc;

foo([x,y])

vs.

restart;
foo:=proc(expr)
    map(x->x^2,expr);
end proc;
foo([x,y])

In Mathematica for example, such symbols used by similar functions of the system (for example, Plot command, and others) are automatically localized to the system call itself avoiding any conflict with user own symbols.

I am not sure how Maple handles this. Should one always declare these symbols?

Maple 2020.2

 

 

I have an expression with number of csgn(arg) in it.

I'd like to scan this expression, telling Maple to assume arg is positive, in order to replace csgn(arg) by 1.

I am trying to do this using subsindets. But I do not know why it is not working. I am doing this in code, without looking at the expression. So I do not know what the arg's are and how many such cases could be.

Here is an example

expr:=(1+csgn(a)*a)/(3*csgn(b)*b);

To get to each csgn(arg), I am using the type 'specfunc( anything, csgn )'. I checked this is correct type by doing

type(csgn(a),'specfunc( anything, csgn )');

           true

Then

subsindets(expr,'specfunc( anything, csgn )', f->simplify(f) assuming positive);

But this does not change anything. 

I also tried

subsindets(expr,'specfunc( anything, csgn )',f->simplify(f) assuming op(1,f)::positive);

No change, But if I do 

simplify(csgn(a)) assuming positive;

it works. And Maple returns 1. Also this works

simplify(expr) assuming a>0,b>0;

But since I am do not before hand what the arguments to csgn() in the expression are, I can't do the above. I do not know even if expression has csgn() in it even. I am trying to simplify a result I obtain inside the program by doing the above.

What is wrong with my use of  subsindets above?

I think the problem is with using assumptions inside subsindents. As this below works

subsindets(expr,'specfunc( anything, csgn )',f->1);

So the call to subsidents was OK, it is just that the assumptions do not seem to be somehow effective inside.  May be name scoping issue?

Maple 2020.2

edit:

For now and as workaround, I am doing this

restart;
expr:=(1+csgn(a)*a)/(3*csgn(b)*b):
fun:=selectfun(expr,'csgn'); #find csgn if any

if numelems(fun)>0 then
    the_args:= op~(1,fun);
    simplify(expr) assuming map(x->x::positive,the_args)[];
fi;

 

The worksheet below mimics some of the construction in the web site https://www.geogebra.org/m/d4k6SjFX.

This seems a crude and limiting way to display a pencil of ellipses tangent in a quadrilateral.

Please provide references (textbooks, articles, etc.) to the mathematics which produces this kind of display.

Pencil_in_quad.mw

Sorry, I was not able to change the displays to inline.

Hello to everyone!

I should MINIMIZE a function called α that is a function of the variable h (0 < h < 2.2), therefore I should find the h value that gives the minimum value of α. Here follows the α function:

alpha= ((W1*t/2)+(W2+N)*(t+t/2*h/(h_TOT-h)))/(W1*h/2 + W2*h/2)

 The terms W1 and W2 are constant and assume precise values as a function of h. Simplifying (I will use very simple condition, in reality, the statement is more complicated):

  • if 0<h<1, then W1:=1; W2:=3
    elif 1<h<2.2, then W1:=2, W2:=4
    end if;

How do I collect the IF statements inside the MINIMIZE optimization to obtain a final h value?

I hope I was clear! 

Thanks you all,

Michele

I am still checking output using latest Latex and Maple 2020.2. I noticed a small problem.

Current Latex uses \mathrm{ln} instead of as before, which is just \ln this casues the space before the operator now to be lost, cause hard to read math.

It is better not to use \mathrm on ln

Here is an example

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
expr:= 4*exp(3*x)+3*ln(x);
Latex(expr)

                       4 {\mathrm e}^{3 x}+3 \mathrm{ln}\left(x \right)

It should be

4 {\mathrm e}^{3 x}+3 \ln\left(x \right)

Without even \, between the letter before \ln as old latex() did:

latex(expr)

           4\,{{\rm e}^{3\,x}}+3\,\ln  \left( x \right)

As the Latex engine itself takes care of the spacing around math operators best.

Here is the difference when the Latex is compiled. The use of mathrm with exponential is not an issue, since it is one letter operator, but not with ln.

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{mleftright} 
\mleftright

\begin{document}
This is how it is now
\[
4 {\mathrm e}^{3 x}+3 \mathrm{ln}\left(x \right)
\]
                      
This is what it is better to be
\[
4 {\mathrm e}^{3 x}+3 \ln\left(x \right)
\]                                         
\end{document}

Compiled with lualatex compiler gives

The above shows the space problem.

Using Maple 2020.2 and Physics   879

 

There might be a setting for this. I do not know.

I  noticed, once I call Latex() first time, if I then later issue Typesetting:-Settings(prime=x,typesetprime=true); and after that, call Latex() again, it has no effect.  The derivative does not change.

But calling Typesetting:-Settings(prime=x,typesetprime=true); before calling Latex() the first time, works.

Since I do not want to do restart() in a running program, and I would like to call Typesetting:-Settings(prime=x,typesetprime=true); may be different times to change the letter and after having called Latex earlier, is there a way to make this work without having to do restart? I do not rememebr now if this was the case in earlier version or not. I looked at Latex:-Settings() and see no setting for this inside Latex itself to use in place of the above global Settings.

Please see worksheet below.


 

interface(version);

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 879 and is the same as the version installed in this computer, created 2020, November 19, 20:10 hours Pacific Time.`

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
ode:=2*diff(y(x),x)*x=(1+x-6*y(x)^2)*y(x):
#This works, since setting is called BEFORE calling Latex first time
Typesetting:-Settings(prime=x,typesetprime=true):
ode;
Latex(ode)

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 y^{\prime}\left(x \right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
ode:=2*diff(y(x),x)*x=(1+x-6*y(x)^2)*y(x);
Latex(ode);

#This does not work, since setting is called AFTER calling Latex.
#The latex generated remains the same.
 
Typesetting:-Settings(prime=x,typesetprime=true);
ode;
Latex(ode)

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 \left(\frac{d}{d x}y \left(x \right)\right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

x, false

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 \left(\frac{d}{d x}y \left(x \right)\right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

 

 

Download how_to_change_setting.mw

 

 

After doing 

A:=tan(3*x);
B:=expand(A)

How to get A back from B? I tried

combine(B);
simplify(B,size);
simplify(B,trig);
simplify(B);

They do not give A back. tried few conversions to exp() and back and forth. Can't get original expression back.  trigsubs() does not help here.

This is all need to be done in code, assuming one can not look at the expression and decide what to do on any A/B pair. But I am mainly now looking at trig expressions.

Any suggestions?

Maple 2020.2

I am testing Maple 2020.2 with new Latex with Physics version latest 879.

The latex generated now issues \! between the symbol and the () next to it to improve the spacing. This post is just to let anyone using the package mleftright in Latex, that this will cause a problem. So it is better to remove this package if you are allready using it.

Here is an example

eq:=y(x)=exp(x/2);
Latex(eq)

              y \! \left(x \right) = {\mathrm e}^{\frac{x}{2}}

In earlier version of Physics:-Latex (now it is just Latex), the above generated this

             y  \left(x \right) = {\mathrm e}^{\frac{x}{2}}

Notice, no \! in earlier version.

If you happen to be using \usepackage{mleftright} to improve the spacing for \left and \right, which I was using, you'll get negative side effect. A solution is to remove this package. Here is an example showing the above Latex compiled with this package added, and without it, so you can see the differerence.

\documentclass[12pt]{book}
\usepackage{amsmath} 
\usepackage{mleftright}
\mleftright
\begin{document}

With the package mleftright loaded

which gives using latest Latex V 879. Maple 2020.2
\[
  y \! \left(x \right) = {\mathrm e}^{\frac{x}{2}}
\]
            
And which gives using earlier Physics Latex. Using Maple 2020.1
\[
  y \left(x \right) = {\mathrm e}^{\frac{x}{2}}
\]
\end{document}

This is the output without using this package. by removing the inlcude command in the above Latex code and not calling mlfright. Now the problem is gone: