nm

11353 Reputation

20 Badges

13 years, 19 days

MaplePrimes Activity


These are questions asked by nm

I am using solution given in How-To-Make-Sort-Work-With-Alias which works well.

But on more testing, I found that Latex drops the constant of integration after applying the above solution, when this constant shows at the front of the rhs of the expression.

I have no idea why this happens. I will post two examples. The first shows the problem with the Latex generated, showing the constant is missing from the Latex. The second example is where I moved the constant  to inside the expression keeping everything else the same, and now the Latex generated no longer drops it. 

This is serious problem, since now my solutions are losing constant of integration in Latex display depending on where it is located.

example 1

restart;
assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:

sol:= y(x) = _C1/cosh(x)+(cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x);
sol:=subs(S, sort(sol));

Now watch what happens to the Latex of the above

Latex(sol)

y \! \left(x \right) = 
\frac{1}{\cosh \! \left(x \right)}+\frac{\cosh^{2}x +\cosh \! \left(x \right) \sinh \! \left(x \right)+x}{\cosh \! \left(x \right)}

Which compiles to 

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\[
y \! \left(x \right) = \frac{1}{\cosh \! \left(x \right)}+\frac{\cosh^{2}x +\cosh \! \left(x \right) \sinh \! \left(x \right)+x}{\cosh \! \left(x \right)}
\]
\end{document}

Now will do the same, but move the constant to the second term. Now it shows up

example 2

restart;
assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:

sol:= y(x) = 1/cosh(x)+ _C1*(cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x);
sol:=subs(S, sort(sol));

Now generate the latex

Latex(sol)

y \! \left(x \right) = 
\frac{\left(\cosh^{2}x +\cosh \! \left(x \right) \sinh \! \left(x \right)+x \right) c_{1}}{\cosh \! \left(x \right)}+\frac{1}{\cosh \! \left(x \right)}

Which compiles to 

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\[
y \! \left(x \right) = 
\frac{\left(\cosh^{2}x +\cosh \! \left(x \right) \sinh \! \left(x \right)+x \right) c_{1}}{\cosh \! \left(x \right)}+\frac{1}{\cosh \! \left(x \right)}
\] 
\end{document}

I am using 2020.2 with Physics 893 on windows 10.

Any idea what is going on? And why this happens when constant is at front only?

ps. the Purpose of using the solution in the above link, is to be able to use c[1] instead of _C1 in the final latex, and also have these constants show at front (this is what sort does) which makes the final expression better looking).

Thank you

Edit

In the debugger, going over Latex() function, I found where the problem happen.  There is a call near line 20 which does this

              Latex:-Print(e,':-executeprintroutines');

Where is the input. Which in this case is the sol expression passed to the Latex command.

Removing ':-executeprintroutines' from the above call, the constant remain there and is not lost.

It seems assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)): used before the call to Latex is confusing things.

Here is illustration:

restart;
assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:
sol:= y(x) = _C1/cosh(x)+(cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x);
sol:=subs(S, sort(sol));


Latex:-Print(sol,':-executeprintroutines');
Latex:-Print(sol);

And the output of the last 2 commands is

This shows when using ':-executeprintroutines' the constant is lost. I do not know what ':-executeprintroutines' does or where it is defined to try to modify it.

There is a problem here somewhere. Maple hangs on this ODE. Looking at trace, it hangs in trying homogeneous G

is this a known defect and could be resolved?

restart;
infolevel[dsolve]:=4;
dsolve(x^3*diff(y(x),x)^2+x*diff(y(x),x)-y(x) = 0,y(x))

... hangs

Adding different timelimits, it looks like the function gcd/LinZip is the culprit. Since it always seems to be there each time the timelimit expires (if it expires, sometimes it hangs even with timelimit).  But I noticed the above function many times in timelimit. So it seems the above functions is what causes many of the hangs I see.

Using `Lie` method, dsolved finishes almost instantly.

restart;
dsolve(x^3*diff(y(x),x)^2+x*diff(y(x),x)-y(x) = 0,y(x),'Lie')

This is on Maple 2020.2

It would be useful to know the cause of the hang, as fixing it could solve other problems.

I also notice that on Maple 2019.2 the first example above finished very fast also. So this is an issue that was introduced in Maple 2020.

All on windows 10.

I am having hard time controlling my Latex:-Settings now. The issue is that I do not know what each setting accepts as values, and what each value does.  The way I've been doing it is by collecting what useful ones posted in this forum, and what it does and save it in my cheat sheet. 

But now I see I need to change something, but not sure to what.

Is there a way to find what all the settings are, and description  of what each does and accepts as values? For example, 

            powersoftrigonometricfunctions

Accepts mixed and computernotation  But where are these described in terms of what they do? does it accept anything else?  Notice that ?leavespaceafterfunctionname does not show anything.

If I do 

restart;
Latex:-Settings()

it gives

[cacheresults = true, invisibletimes = " ", leavespaceafterfunctionname = false, 
powersoftrigonometricfunctions = mixed, spaceaftersqrt = true, usecolor = true, 
useimaginaryunit = I, useinputlineprompt = true, userestrictedtypesetting = false, 
usespecialfunctionrules = true, usetypesettingcurrentsettings = false]

But do not know how to obtain full description and possible value of each to see what they mean and do.

I think having Latex:-Settings() is a great idea, as it allows maximum flexibility for user to configure how they want the Latex output to be, but as more options are added, this type of information become more important to know and to keep track of.

I am using 2020.2 and Physics version 893

 

I was trying to find if the type of module wide variable is considered local or global.

I have an exported variable in module. Maple then said it was local . OK

restart;
foo:=module()
   export n::integer;
   export boo:=proc()::integer;
     return n;
   end proc;       
end module;
                   

n:=foo:-boo():
type(n,`local`);

               # true

But when I did this

restart;
foo:=module()
   export n::integer;
end module;

n:=foo:-n;
type(n,`local`)

         #false

Now Maple says it no longer local.

What is the difference? The module wide variable is exported in both cases. So one can access it directly like in the second example above, or via call to a proc inside the module, which returns it.

Why in one case it is local and in the second case it is not?

Ok, I found the issue. It seems when doing return  n; in the first example above, it created and returned a local n to the proc itself (where n was not declared in the example). (even though maplemint did not complain. Strange).

I have assumed when doing return n Maple will know this is the module wide variable n since that is the closest one around.  i.e. the proc is inside the module. And sits inside the module. So return n should referenced this variable. But it did not, because when I changed the code to this

restart;
foo:=module()
   export n::integer;
   export boo:=proc()::integer;
     return foo:-n;
   end proc;       
end module;

n:=foo:-boo():
type(n,`local`);

     #false

Now it returned false. The same as the second example.

But it also returned false when asking if it is global

n:=foo:-boo():
type(n,`global`);

    #false

So the module wide variable in this example is not local and is not global.

Is there another type to use to check if the variable/symbol returned is a module wide type?

Maple 2020.2

I assume the goal is to have the Latex output close to the screen output in Maple. In these examples this is the case.

Example 1

restart;
A:=Matrix([[1,-1,0,2],[1,2,2,-2],[0,2,3,-1]]):
LinearAlgebra:-NullSpace(A)

But the Latex generated for the above, using the Latex() command is

\{ \left[\begin{array}{c}0 \\2 \\-1 \\1 \end{array}\right] \} 

Which when compiled

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\[
\{ \left[\begin{array}{c}0 \\2 \\-1 \\1 \end{array}\right] \} 
\]
\end{document}

gives

The latex should instead be 

\left\{ \left[\begin{array}{c}0 \\2 \\-1 \\1 \end{array}\right] \right\} 

Which compiles to

Example 2

restart;
A:=Matrix([[1,-1,0,2],[1,2,2,-2],[0,2,3,-1]]):
LinearAlgebra:-RowSpace(A)

The Latex of the above is 

[\left[\begin{array}{cccc}1 & 0 & 0 & 0 \end{array}\right], 
\left[\begin{array}{cccc}0 & 1 & 0 & -2 \end{array}\right], 
\left[\begin{array}{cccc}0 & 0 & 1 & 1 \end{array}\right]]

Which when compiled gives

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\[
[\left[\begin{array}{cccc}1 & 0 & 0 & 0 \end{array}\right], 
\left[\begin{array}{cccc}0 & 1 & 0 & -2 \end{array}\right], 
\left[\begin{array}{cccc}0 & 0 & 1 & 1 \end{array}\right]]
\]  
\end{document}

gives

A better Latex would be

\left[\left[\begin{array}{cccc}1 & 0 & 0 & 0 \end{array}\right], 
\left[\begin{array}{cccc}0 & 1 & 0 & -2 \end{array}\right], 
\left[\begin{array}{cccc}0 & 0 & 1 & 1 \end{array}\right]\right]

Which compiles to

Now the size of the [[ is the same on both ends.

example 3

restart;
A:=Matrix([[1,-1,0,2],[1,2,2,-2],[0,2,3,-1]]):
LinearAlgebra:-ColumnSpace(A)

The Latex given for the above is

[\left[\begin{array}{c}1 \\0 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\1 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\0 \\1 \end{array}\right]]

Which when compiled

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\[
[\left[\begin{array}{c}1 \\0 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\1 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\0 \\1 \end{array}\right]]
\]  
\end{document}

gives

A better Latex is

\left[\left[\begin{array}{c}1 \\0 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\1 \\0 \end{array}\right], 
\left[\begin{array}{c}0 \\0 \\1 \end{array}\right]\right]

Which compiles to 

Maple 2020.2 with Physics  891 

First 100 101 102 103 104 105 106 Last Page 102 of 199