nm

8552 Reputation

19 Badges

12 years, 352 days

MaplePrimes Activity


These are replies submitted by nm

@dondomingo 

I've added 2 examples. I've used solve() here. There is also PDEtools:-Solve() command you might want to look at.

@ecterrab 

Thank you very much for this new setting.  I removed the macro. Not needed any more. This setting is even better, as it seems somehow smart enough to know when \, is needed and when not needed. I do not know how it does this.

Here is the result for example. One can see \,  is added only in the places where it was a problem. In the case of the macro I had, the \, was added everywhere after \sqrt even when is not needed.

This is why I said fixing things at the source of generation is always better than afterwords.

Thanks for this fix.


 

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 884 and is the same as the version installed in this computer, created 2020, November 25, 16:49 hours Pacific Time.`

restart;

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

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

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

[powersoftrigonometricfunctions = computernotation, leavespaceafterfunctionname = true, cacheresults = false, spaceaftersqrt = true, 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

expr5:=diff(y(x),x)=sqrt(x+y)*a;
Latex(expr5)

diff(y(x), x) = (x+y)^(1/2)*a

\frac{d}{d x}y \left(x \right) = \sqrt{x +y}\, a

 


 

Download improved_space_after_sqrt.mw

 

I get an error in Maple 2020.2

 

 

@ecterrab 

Thanks for the new setting. But this will have a global adverse effect, as it affects all products spacing, which I did not want. 

I was only looking for space after sqrt. But good to have this new setting there, in case someone could use it.

I ended up just adding a small macro for the \sqrt, to redefine it, to add space. Please see below. I added this to my Maple latex preamble. And it seem to work OK. (But I need to test this more on my main Latex file)

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

%change \sqrt to add \, after. Use letltxmacro package (safer)
\usepackage{letltxmacro}
\LetLtxMacro{\oldsqrt}{\sqrt}
\renewcommand{\sqrt}[1]{\oldsqrt{#1}\,}
%end patch

\begin{document}
\begin{longtable}{|p{3in}|p{3in}|}\hline
\[
y'(x)=\sqrt{x+y}a
\]\\\hline 
\[
\sqrt{\left(3+x \right)^{2}+1} a +\sin \left(x \right)
\]
\\\hline 
\[
\frac{\sqrt{\left(3+x \right)^{2}+1}}{5}+b
\]
\\\hline 
\[
\frac{\sqrt{x}}{5}+b
\]
\\\hline 
\[
\frac{\sqrt{x^{2}+6} c}{5}+b
\]
\\\hline 
\end{longtable}
\end{document}

Gives

Without this macro, the output will look like this (which is what one will get from Maple now)

Thanks.

@itsme 

you mention \int, but do you really mean \sqrt? or did i miss something?

opps, sorry that was a typo. I was talking about sqrt. I do not know why I wrote int.  it was very late.

There is no such issue with int. Since int will either evaluate automatically and if not, then Maple Latex automatically puts a () around it, which avoids the issue with  the spacing in the case of the sqrt as you can see below
 

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:=Int((3+x)^2+1,x)*a;
Latex(expr1)

(Int((3+x)^2+1, x))*a

\left(\int \left(\left(3+x \right)^{2}+1\right)d x \right) a

expr2:=int(f(x),x)*a;
Latex(expr2)

(int(f(x), x))*a

\left(\int f \left(x \right)d x \right) a

expr3:=int((3+x)^2+1,x)*a;
Latex(expr3)

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

\left(\frac{\left(3+x \right)^{3}}{3}+x \right) a

 

 

Download space_after_int.mw

Often latex is excellent at doing the formatting/typesetting just right, although I agree that in some circumstances one might like to do some tweaking.

Yes, sure. 99% of the Latex questions at tex.stackexchange.com are about this kind of tweeking. And only Latex experts who know Latex very well (which I am not one of them) can craft such macros, since some can be complicated. 

So if these tweeks can be automated and fixed at the Latex generation source, all the better, as it will benefit everyone.

Having this in settings options is good idea also, in case one wants to turn on/off, using Latex:-Settings(....).

ps. I generate lots of Latex, 10'000 of pages of PDF's each time. All automated from CAS, so having good Latex quality is very important. 

 

Was something wrong with the reply I gave earlier for your deleted question

?

If so, why not reply to that post instead? Now my reply is lost.

 

You said

Eliminate hangs when using timelimit(). On long runs, random hangs happen when timelimit() do not expire as requested. Posted about this before.

I thought to post a typical example of this most annoying problem for me in Maple. Since it cause hangs in a script at places I have no control over. So when I run a script, I never know if it will hang or not and where as it seems to be random and it depends on the amount of timeout used.

I hope this gets fixed in next version of Maple. I have many many more such examples.

restart;
ode:=diff(y(t),t) = 1+y(t)+y(t)^2*cos(t);
sol:=dsolve(ode,y(t)):
timelimit(60,odetest(sol,ode));

And now it hangs. I waited for over 15 minutes, even though the time out is 60 seconds.

I know the solution is very complicated. But Maple should never hangs in a timelimit, in spite of what help says.

Note: In some cases, the execution may not abort at exactly the time limit imposed, but will abort as soon as it can do so safely.  This can happen when execution is in critical sections of certain built-in routines.

I am not asking for exact timeout ofcourse, but it should not be much more than 60 seconds, give and take few seconds.

I am sorry, but the above is just not acceptable for a software that has been around for more than 30 years now.

I worked on the development of the internals of a major operating system before. I know timeouts could always be implemented, no matter what the circumstances are, even if code is running inside a critical section. 

In Mathematica for example, this never happens. https://reference.wolfram.com/language/ref/TimeConstraint.html and timeouts there always timeout. Each time and everytime. 

Maple 2020.2 on windows 10.

Thank you

edit

After few more minutes, the above example did time out finally.  But took much much longer than the actual timelimit given. Waiting for say 20 minutes, when the timelimit is 1 minute is not right. As I said, it is not determistic. So each time it seems to behave differently.

 

 

@ecterrab 

thanks, I did not know about Latex:-Settings(leavespaceafterfunctionname = true).

I ended up actually using the above option after more testing. It turns out that \! does not work too well in mathjax.

I compile the latex to html using tex4ht, using mathjax mode. And notice the space between the function name and () is all gone now, in HTML. Not PDF. It seems this is not handed well by mathjax. 

So I went back to using mleftright with the above option in place.

I think it might be a little more preferable to have the default Latex generated be as it was before, i.e. NO \! and have the user issue an explicit setting as above in order to add \! if they wanted to, instead of the other way around as it is now. 

If you have TexLive installed and like to see this your self, here is a latex generated by Maple and the command to compile it to HTML under mathjax. This will work if you have TexLive 2020 

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

Let the constant of integration be called $c_2$ instead. Hence the above solution becomes
\[
          w \! \left(x \right) = \frac{x}{3}+\frac{2}{3}+\frac{c_{2}}{\left(x +2\right)^{2}}
\]    
Now, since $v^{\prime}\! \left(x \right) = w \! \left(x \right)$, then this 
gives a new first order ODE to solve for $v \! \left(x \right)$
\[
            v^{\prime}\! \left(x \right) = \frac{x}{3}+\frac{2}{3}+\frac{c_{2}}{\left(x +2\right)^{2}}
\]
                                                                                                              
\end{document}

THe command is

make4ht -ulm default -a debug foo3.tex "mathjax,htm"

This will create a file called foo3.htm in the same folder. If you view the HTML in browser, you'll see the problem.

Again, this might be a mathjax overcorrection for \! I do not know.  Removing \!  and compiling again, the problem is gone and the spacing is back to normal as it was before.

 

resolves issues with the installation of the Maplesoft Physics Updates

What was the cause of the issues?

I think that will be useful to know. Was it with windows itself?

@vv 

great. thanks. I did not think of select at all. Much better than messing with op().  Now I can do

ode:=x^2*diff(y(x),x$2)-(x-3/16)*y(x)=0:
ode:=expand(algsubs( y(x)=v(x)*x^(1/4)*exp(2*sqrt(x)),ode));
ode:=factor(ode);
if type(lhs(ode),`*`) then 
  ode_part  :=select(has, lhs(ode), diff);
  rest_part :=remove(has, lhs(ode), diff) 
fi;

it is a good idea to learn the Maple debugger. It is really very useful.

There are commands there to stop at errors, and then you can examin variables and issue any Maple command while inside the debugger.

Learning how to debug is part of learning programming.  To step into the debugger, just so "stopat name_of_proc" and then call the proc. Now you are inside the debugger in new window. The help page gives all the commands that can be used in the debugger.

 f uses a 2nd argument, y, which is missing

from the error message, it looks like you are not calling "f" correctly.  

@Carl Love 

How do you actually use the code you posted? I am getting an error trying it

foo:=proc( ic::(function(name)=algebraic) )
local y,x0,y0;

y:=op(0,lhs(ic));
x0:=op(1,lhs(ic));
y0:=rhs(ic);
   
print("y(x0) = y0 is", y(x0)=y0);
end proc;

And now called it as

foo( y(2)=0)

I also tried it exactly as you have

restart;
IC:= (ic::(function(name)=algebraic)) -> op~([[1,0..1], 2], ic);
ic:=y(0)=2;
IC(ic)

I am using Maple 2020.1 on windows 10

ps. I am trying not to use patmatch as much, and each time I found a way not to use it, I do.

 

@ecterrab 

I am really confused now. I tried Latex:-Settings(powersoftrigonometricfunctions = computernotation); but it had no effect. Please see worksheet below.

I thought also I am supposed to use textbooknotation in order to get cos(x)^3 to come out as \cos^{3}x. I must have been wrong. I am still trying to learn which option to use as this is all new.

So if computernotation will do both, that is good. But why it is not working for me? I am using 870. I restarted Maple few times. No change.  May be there is another setting that needs to be added somewhere to get same output as on you are getting?

 

interface(version)

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

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

#do I need to do something else other than this?
Latex:-Settings(powersoftrigonometricfunctions = computernotation);

[powersoftrigonometricfunctions = computernotation]

expr:=arccos(x);              
Physics:-Latex(expr)

arccos(x)

\cos^{-1}x

expr:=cos(x)^3;              
Physics:-Latex(expr)

cos(x)^3

\cos^{3}x

 


 

Download latex_notation_871.mw

 

 

@ecterrab 

Thanks for the fix for the run-time error. Yes, It is fixed in 870.

But now with 870, arccos() generates latex \cos^{-1} which is not a good notation at all and very confusing and no modern textbook uses this notation for inverse trig. This notation for inverse trig should not be even considered for any one of the options. 

The standard is to keep it \arccos as it was before, as in V 865 for example. 

When you say

There is option 2: textbook notation only for trig (so cos(x)^2 is tex-translated as cos^2(x), but arccos(x) remains arccos, not cos^(-1)). 

Which is good and the ideal case. But this is not what I am seeing. I added this option, but it is still generating cos^{-1} for arccos? What Am I doing wrong?

Why is the textbooknotation  not doing what you are saying it is supposed to do and keep using arccos?

Thank you


 

interface(version)

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

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

restart;

Latex:-Settings()

[invisibletimes = ` `, powersoftrigonometricfunctions = textbooknotation, usecolor = true, useimaginaryunit = I, useinputlineprompt = true, userestrictedinputtranslation = false, usespecialfunctionrules = true, usetypesettingcurrentsettings = false]

Latex:-Settings();
Physics:-Latex:-UseImaginaryUnit:=i:
Physics:-Latex:-UseColor := false:  
Latex:-Settings(powersoftrigonometricfunctions=textbooknotation):
Latex:-Settings(usetypesettingcurrentsetting=true):
Latex:-Settings();

[invisibletimes = ` `, powersoftrigonometricfunctions = textbooknotation, usecolor = true, useimaginaryunit = I, useinputlineprompt = true, userestrictedinputtranslation = false, usespecialfunctionrules = true, usetypesettingcurrentsettings = true]

`* Partial match of  '`*usetypesettingcurrentsetting*`' against keyword '`*usetypesettingcurrentsettings*`' `

[invisibletimes = ` `, powersoftrigonometricfunctions = textbooknotation, usecolor = true, useimaginaryunit = I, useinputlineprompt = true, userestrictedinputtranslation = false, usespecialfunctionrules = true, usetypesettingcurrentsettings = true]

expr:=sin(x)^3+arccos(1/x);              
Physics:-Latex(expr)

sin(x)^3+arccos(1/x)

\sin^{3}x +\cos^{-1}\left(\frac{1}{x}\right)

expr:=sin(x)^3+arccos(x);              
Physics:-Latex(expr)

sin(x)^3+arccos(x)

\sin^{3}x +\cos^{-1}x

 


ps. does one need to call Latex:-Settings(usetypesettingcurrentsetting=true): after changing a setting? I tried not calling it, and it made no difference. It is not clear what this option means exactly. So I tried both cases to find out.

Download latex_notation_870.mw

 

 

First 25 26 27 28 29 30 31 Last Page 27 of 71