nm

11413 Reputation

20 Badges

13 years, 72 days

MaplePrimes Activity


These are replies submitted by nm

@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).

@Rouben Rostamian  

Thanks for the hint. But I've been googling and searching for such an option for Maple, and do not see any mention of it, even for Linux. Must be not documented? Would you have a link to a page that mentions it?

I looked at the user guide also and do not see it.   If it works for windows, will see if I can figure how to use it. But wanted first to read a little more about it in Maple docs.

Will the talks given in the conference be recorded and posted somewhere so one can view them afterwords?

How about talks from earlier years conferences?  Is there a website which hosts all recoroding of all conferences made?

This will useful for someone who like to see some of them, but do not want to be there live online at the same time.

Thank you

Yes, it should be more clear. It says first 

both functions return an integer which indicates the position of the first character that matched

May be that should say something like

both functions return an integer which indicates the position (relative to the range given) of the first character that matched

It does say next though The optional range restricts the search to the given positions. but still, I think the first part could have been more clear. 

btw, one could get the position relative to start of string if neeed using something like

from_pos:=5:
to_pos:=-5:
relative_idx:=SearchText("ijklm", "abcdefghijklmnopqrstuvWxy", from_pos..to_pos);
idx_from_start:=relative_idx+from_pos-1

    9

@chenaiier 

I've updated the answer. I assumed you are looking for analytically solution. Mathematica's solution uses NDSolve and not DSolve. This can be solved numerically only.   

btw, you copied the ODE wrong from that link. it is a second order ODE and not first order as you show. But may be you were using different example.

@mapleatha 

This looks like a bug to me. It works in Mathematica

Plot[Sin[x]*Cos[x] + x, {x, -2 Pi, 2 Pi}, 
 Ticks -> {Range[-2 Pi, 2 Pi, Pi/2], Automatic}]

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