nm

8552 Reputation

19 Badges

12 years, 353 days

MaplePrimes Activity


These are replies submitted by nm

@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

 

@ecterrab 

So I suppose this does what you want for the ODE case? The use of Suppress is necessary for this to work - is that an issue?

Great. Yes, that is exactly. I did not try Typesetting:-Suppress since I did not use it before. But it works. I could always later use Typesetting:-Unsuppress.

restart;
ic:={y(0)=0,D(y)(0)=1,(D@@2)(y)(0)=4};
Typesetting:-Settings(typesetprime=true);
Typesetting:-Suppress(y(x));
Physics:-Latex(ic);

ode:=diff(y(x),x)=sin(x);
Typesetting:-Unsuppress(y(x));
Physics:-Latex(ode);

This takes care of the ODE case.

For PDE's

Yes, I like this also and I used it also when writing latex by hand.

But how do did you get Maple to generate the above Latex? Was the above generated by Maple? It is a good Latex. What is the exact code you used? I can't get the ToJet to accept the initial/boundary  conditions in N and R you show above. I keep getting errors.

About the ""not commas": in Jet notation. Yes, I see your point. May be a User option to suppress comma might be useful?.   

I only use single variable x,y,t,z etc.. for indepenent variables, that is why. But I uderstand your point.

But for ODE's, issue is now closed. Thanks for help.

 

 

@ecterrab 

there is always the issue of who is the prime variable

I think for ode's initial conditions, this is not needed to know? The input for ode IC is (using the D notation) is D(y)(x0)=y0 this can be translated to y'(x0)=y0 without the need to know the independent variable.  Isn't this correct? When using eval() notation, no need to change that at all. For second order, the same, (D@@2)(y)(x0)=y0 can be translated to y''(x0)=y0 and so on. For non-integer order, such as nth order (D@@n)(y)(x0)=y0 is translated to y^(n)(x0)=y0

For PDE's, I did not know about ToJet. Thanks for the link. But that only works for the actual PDE, not for initial/boundary conditions. I could not make it translate PDE initial or boundary conditions.

For example, 

pde  := diff(u(x, y, t), t) = diff(u(x, y, t), x$2)+diff(u(x, y, t), y$2) -  u(x,y,t);
Physics:-Latex(PDEtools:-ToJet(pde,u(x,y,t)));

works and gives  

(although a better notation is not to use the comma there and just have it as

But can't use ToJet for initial/boundary conditions

bc:=(D[1](u))(0, y, t) = 0;
Physics:-Latex(bc);

But

PDEtools:-ToJet(bc,u(x,y,t));

gives error, since dependent variable now does not work

Error, (in PDEtools:-ToJet) found functions to be rewritten in jet notation, {u(0, y, t)}, having different dependency than the indicated in [u(x, y, t)]
 

And can not use PDEtools:-ToJet(bc,u(0,y,t)); it gives error.

The notation I like for initial/boundary conditions for PDE's are the standard ones as shown in Haberman PDE's books. Here is an example

But for non-initial conditions, for pde's, I like ToJet notations. (Just wish there was no comma in there)

Thank you

@vv 

Yes, manually trying to convert it using string tools is always a possibility.

But need to be carefull to make sure it covers all cases and forms possible.

For example, your method only works for first order. Not higher.

restart;
ic:=[y(0)=0,D(y)(0)=1,(D@@2)(y)(0)=3];
s:=Physics:-Latex(ic, output=string);
s1:=StringTools:-SubstituteAll(s, "D\\left(y \\right)", "y'"); 

gives

But I am sure with more string manipulation this could be overcome. (need to figure the derivative order, and add as many '' as needed and so on.

Or I could simply add more cases. Like this

restart;
ic:=[y(0)=0,D(y)(0)=1,(D@@2)(y)(0)=3];
s:=Physics:-Latex(ic, output=string);
s1:=StringTools:-SubstituteAll(s, "D\\left(y \\right)", "y'"); 
s1:=StringTools:-SubstituteAll(s1, "D^{\\left(2\\right)}\\left(y \\right)", "y''");

I do not expect to have more than third order initial conditions. So this could work. I could add 2 additional string replacements.

I was hoping to avoid doing it manually by hand. But may be for now, this might be only option to get better Latex for this. I need to test this more in my code to see if it covers all the problems I have, as I have thousands of them.

 

 

@ecterrab 

However, the computer still handles (sin@@2)(x) and also the (operator form) "sin^2 * x" and we need a representation for those too.

This is the first time I see that one can write sin^2 * x in Maple as input. I have no idea what this represents or mean. I also did not know one can do (sin@@2)(x)  and that seems to have different semantics from sin(x)^2. I have no idea why one would actually use these in Maple for as I never used them.

In this case, I do not know what to suggest.

I was simply talking about the single argument trig/hyper trig functions, which are the familar ones such as sin(x)^n.

If the Latex conversion can somehow internally distiguish these functions only from the other forms you show and convert only these to \sin^n x, then will cover the majority of cases in normal practical usage of Maple, I would think, while leaving everything else the same as it is now.

If this is not possible, then I do not know what to suggest,.

I tried these two cases in Mathematica: sin(x)^3 (standard) vs. sin^3*x  to see how Mathematica Latex output is different:

So in Mathematica, it knew that the first case is the standard usage and used \sin for the output, but for sin^3*x (which you call operator form), it used \text{Sin} there. and those will typeset slightly different in output. 

I did not know how to translate your other example of sin(@@3)(x) to Mathematica to try it. 

Btw, having the latex for sin(x)^3 be  \sin^3 x  vs. \sin^3 (x)  is not as important as the location of exponent. I myself perefer the first one above. But the second one is also fine if it makes the conversion easier.

Only when the argument contains 2 or more symbols, then adding an explicit () is better. So sin(x+y)^3 translate to \sin^3(x+y) instead of \sin^3 x+y to remove ambiguity. 

But any way, thanks for considering this and looking at it. I was only suggesting something to help make the latex better looking and I did not know about these other forms. 

I made this table FYI. Only suggestion I could offer now, is to use \texttt for those functions when in operator form while using standard \sin or \cos, etc.. for the normal usages. This will make the latex output a little different. Not sure what else to think of at this time.

Here is the raw latex

documentclass{article}%
\usepackage{amsmath}
\usepackage{array}%
\usepackage{longtable}
\usepackage{listings,lstautogobble}
\renewcommand{\arraystretch}{2}
\usepackage[left=.5in,right=.5in]{geometry}
\begin{document}

\footnotesize
\begin{longtable}[c]{|p{.6in}|p{2.5in}|p{.6in}|p{2.5in}|p{.6in}|}\hline       
Input & current Latex & render & suggested change & render \\\hline 
\verb|sin(x)^3| & \verb|\sin \left(x \right)^{3}|& $\sin \left(x \right)^{3}$ & \verb|\sin^3 x| & $\sin^3 x$  \\\hline 
\verb|sin^3*x| & \verb|\sin^{3} x|& $\sin^{3} x$ & \verb|\texttt{sin}^{3} x| & $\texttt{sin}^{3} x$  \\\hline
\verb|(sin@@3)(x)| & \verb|\sin^{\left(3\right)}\left(x \right)|& $\sin^{\left(3\right)}\left(x \right)$ & \verb|\texttt{sin}^{\left(3\right)}\left(x \right)| & $\texttt{sin}^{\left(3\right)}\left(x \right)$  \\\hline
\end{longtable}

\end{document}

 

And attached is the PDF file also.

foo4.pdf

Another possibility could be to use `\textbf` for those trig function names that are meant to be "operators". This makes them a little more distinguishable than using \textttt or just \text as Mathemtica does.

This table uses the same latex code above, but changed \texttt to \textbf, that is all.

@Preben Alsholm 

A common way of solving this kind of ode is to multiply by diff(y(x),x) on both sides and integrate 

Yes, that is exactly how I solved it. But you did a smart middle of the road substituion. I solved the whole ODE first to get 

And only then plugged the two initial conditions to obtain 2 equations and tried to solve them simultaneously. But this results in no solution.  This is the standard text book method. Get first the general solution, and set up one equation for each IC. I need to see if I can implement your method somehow. 

I am doing all of this in code without the benifit of being able to see the equation or the solution on the screen and then decide what to do. This makes it harder. Any logic I do, have to be done in code. That is why the standard textbook method is simpler to implement.  

On a side note, I still do not know how Maple got the general solution using tan instead of my solution using tanh. But both solution are correct.  This is another mystery I need to figure out. But this is for another day to look more at it.

 

 

@ecterrab 

And it will be great if you could get a chance to look at

https://www.mapleprimes.com/questions/230824-Improvements-In-Latex-For-Trigxn-Expressions

This will go along way towards making the Latex generated by Maple more better looking. I hope it will not take too much effort  and time to make this change.

Thanks

 

 

@ecterrab 

Thank you very much for the improvement. Glad it did not take too much of your time.

The software I use is Scientific workplace , version 5.5. It is a GUI software which can read latex files and show the latex as GUI on the screen. It also generates standard Latex from GUI.

Yes, it is not CTAN.  But it seems to interpret the extra "\\" at end as new blank row in the matrix, so when I save the file again, I get a new empty row. 

TexLive itself does not do that as you say. I use this software alot.

Thanks for the help.

@cicoats 

 

We got different answers though for the mass.

Well' I used your original expression which is 

ln(r^2 + theta^2 + phi^2 +1)

while you are multiplying the above now with r^2*sin(varphi)

Maybe that is why there is a difference.

evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1)*r^2*sin(phi),r=0..2),theta=0..2*Pi),phi=0..Pi))

92.3012729000

@cicoats 

They look ok to me. Just need to decide which angle convention to use. This is always the confusing part with spherical coordinates.  And if these distances you are getting should come out to be negative.

 

@Thomas Richard 

You are right, I just tried it and it worked. This is very strange that I did not notice this. Was this always the case with Maple? I could swear before it used to be that once worksheet is busy, I could not use Maple.

But this really helps. I could just use second worksheet, while the first one is busy now.

Thanks

edit: 

I think I now know what happend. I used to have the "share one engine among all documents"  set sometime ago, which is the default.   

When this is the case, then when one worksheet is busy, one can't use Maple when opening new worksheets until the first one complete.

I remember recently changing this open to make it use new engine for each document but still thought that Maple keeps busy when one worksheet is busy and did not think to try it again, that is why I asked.

 

 

@Kitonum 

Interesting solution. But how did you know to use 3=() in there? I mean, how did you know it is the third entry which needs to beremoved? This is meant to be used inside a program, so need a way first to determine which entries to change. If there is an easy way to find first the position of such entries, then yes, this method will work.

@Rouben Rostamian  

Thanks. I've tried it on windows and it worked. Now when I do start->Maple 2020, it seems to start new separate instance indeed. This is what I did

Right-click on the Maple 2020 icon, click on Properties, then edit the command to start Maple and change it to become

"C:\Program Files\Maple 2020\bin.X86_64_WINDOWS\maplew.exe" -standalone

Click OK. Windows will ask that need to be an admin to do this, clicked OK. That is all.

I had no idea that such an option existed. Very useful. Will use it all the time from now. (it should really be the default after installation).

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