nm

11483 Reputation

20 Badges

13 years, 83 days

MaplePrimes Activity


These are replies submitted by nm

@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

 

 

@ecterrab 

Thanks for the fast improvement. I will test it tonight on a large PDF file build by generating Latex from Maple that I have of over 12,000 pages. I am sure it will be ok with the new version of Physics:-Latex.

 

@ecterrab 

I just checked one large latex file I have, and yes, it is only used for exp in this file. I thought I might have seen it somewhere else also sometime ago. May be with the old latex command? I am  not sure now. But it is good if it is only used for exp, hopefully this will make it easier to modify in this case.

As for \textrm vs. \mathrm, I would go with \mathrm based on reading the following references

https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm

https://tex.stackexchange.com/questions/19502/is-there-a-preference-of-when-to-use-text-and-mathrm

since e is a symbol meant to be in math mode, then mathrm seems the better choice. There are other subtle differences given in the above links.   

I think you are doing it in no-optimal way.

This is how I do these things. I generate all the plots, each plot in separate image file. I do all this in code. So I export each plot as eps file. (Maple still, in the year 2020, can't export, in code, a plot as PDF, only as eps file, which is really a very strange issue.). But one can export to eps and then convert to PDF after that using script.

Once you are done generating the plots from Maple. Now close Maple. It is not needed any more.

Next, I convert the eps files to pdf files, using script. Which there are number of ways to do.

Next, I generate the table which contains the plots in Latex, using tabular or longtable and using includegraphics commands. Then compile the latex file to PDF. This will generate the table I want, as a PDF file.  

You get much much better quality table this way, with all the plots, much better sizing and control as you want. You can also add caption and get a professional looking output as you see in papers and books.

Again, this is how I do this. The output is much better. All the above can be automated using a Makefile.

You can see this post as an example of how to use tables of images in Latex

https://tex.stackexchange.com/questions/64038/table-of-images-with-captions

 

First 46 47 48 49 50 51 52 Last Page 48 of 91