nm

8552 Reputation

19 Badges

12 years, 354 days

MaplePrimes Activity


These are questions asked by nm

Maple generates latex for hbar as  \mathit{hbar}  instead of just \hbar which makes it not render in PDF.  Here is an example

expr:= hbar*x;
latex(expr)

The screen display is correct. But not the latex. When compiling the above in Latex this is the output

\documentclass[12pt]{article}
\usepackage{amssymb}

\begin{document}  

%Maple generated
\[
\mathit{hbar} x
\]

%default
\[
\hbar x
\]

%need amssymb for this
\[
\hslash x
\]
\end{document}

Compiling the above gives

So to use the standard hbar,  \mathit should not be used around it. 

ps. I like \hslash more myself than \hbar , so if there is a choice, will vote for \hslash for latex.

Maple 2021, windows 10. 

 

Physics:-Version()
The "Physics Updates" version in the MapleCloud is 973 and is 

   the same as the version installed in this computer, created 

   2021, May 3, 18:54 hours Pacific Time.


 

I only use latex() to convert Maple solution to Latex. I do not export whole document to Latex.

When I ask Maple to convert this solution of a PDE to latex, it generated strange Latex which is different, from the Latex it generates for same solution, when doing File->Export As->Latex.

The Latex it generated in the export case, is the one I want. The latex it generates from the latex() command, I am not able to use and is completely different. It has things like \mathit{Typesetting} and other different latex.  

Why is that? And how to make it generates the same Latex for this expression as in the export case?

First I show screen shot, then the worksheet to reproduce it

 

But Now when I save this worksheet (with only the expression I want) 

Using File->Export As->Latex, and then look at the latex for the "sol" in the latex file generated, this is what it shows (I am only showing the latex part of the above, not the whole file)

\begin{maplelatex}
\mapleinline{inert}{2d}{}
{\[\mathit{sol} \coloneqq u \left(r ,t \right)=\mathcal{L}^{-1}
\left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right) s}
{\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) \left(s^{2}+1\right)},s ,t \right)
-\mathcal{L}^{-1}\left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right)}
{\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) s},s ,t \right)
-\cos \left(t \right)+1\]}
\end{maplelatex}

The above latex I can compile standalone, and it does not have the problematic constructs found when using latex(sol)

One can see it is very different from the top one given earlier.

Why are the two latex different? Is there an extra setting one needs to adjust?  How make latex(sol) generate the same latex for the expression as found in the file generated by export as latex?

may_2.mw

update 1

Did some debugging. The problem happens when using `:-executeprintroutines`.  Tracing the latex() command in the debugger. At lines 42, it has the call

texlist := [latex:-Print(e,_rest,':-executeprintroutines',':- handleimaginaryunit',':-performonlyoncetasks',opt)];

Where above is the expression to convert to Latex. When I removed ':-executeprintroutines' the problems in latex went away. Here is an example

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol)

Gives

"u ! left(r , t\right)", ` = `, `\\mathit{invlaplace} 
\\! \\left(\\frac{\\mathit{BesselJ}\\! \\left(0, 10 \\sqrt{-s}\\, r \\right) s}
{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)
-\\mathit{invlaplace} \\! \\left(\\frac{\\mathit{BesselJ}\\! 
\\left(0, 10 \\sqrt{-s}\\, r \\right)}{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) s}, s , t\\right)
-\\cos \\! \\left(t \\right)+1`

Now notice what happens when adding ':-executeprintroutines'

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol,':-executeprintroutines')

it gives the problematic latex

"u ! left(r , t\right)", ` = `, `\\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\! 
\\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mi}\\! 
\\left(\\text{\`\`$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq 
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\! 
\\left(\\text{\`\`$-$"}\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\! 
\\left(\`\`1"\\right)\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=\\text{\`\`atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10 
\\sqrt{-s}\\, r \\right) s}{J_{0}\\! \\left(20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)-
\\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\! \\left(\\mathit{Typesetting}\\mcoloneq 
\\mathit{mi}\\! \\left(\\text{\`\`$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq 
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\! \\left(\\text{\`\`$-$"}\\right), 
\\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\! \\left(\`\`1"\\right)\\right), 
\\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=
\\text{\`\`atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10 \\sqrt{-s}\\, r \\right)}
{J_{0}\\! \\left(20 \\sqrt{-s}\\right) s}, s , t\\right)-\\cos \\! \\left(t \\right)+1`

I do not know what :-executeprintroutines does and how one can tell latex() not to call it at the user level. I asked about :-executeprintroutines before here

  https://www.mapleprimes.com/questions/231230-Why-Latex-Removes-Constant-From-Expression

And I could not find any documenation on it.  

I tried to define my own executeprintroutines proc() which does nothing. But it did not help

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
executeprintroutines:=proc()
   NULL;
end proc;
latex(sol)

The Latex was not fixed. It is same. 

May be the above will help find the issue.

 

Using latest TeXLive distribution, and current Maple 2021 maple.sty file, Maple generated Latex uses command called 

             \pdfstringdefDisableCommands

which is unknown. I found this when I was trying to compile latex generated from Student:-Calculus1:-ShowSolution command.

The above latex command is called/used in maple.sty file, but it is not defined anywhere outside. It might have been defined many years ago?  I only see one reference to it in an old posting at tex stackexchange from few years ago.

This is how to reproduce this error (one needs to have latex installed on your PC to compile the file). On windows MikTeX can be used. On Linux, TeXLive.

restart;
the_output:=Student:-Calculus1:-ShowSolution(Int(x^3,x=0..1));
latex(the_output)

Then copied the latex, and pasted it in my latex file

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{maple}% set the path to reach this in Maple etc/ folder in its installation
\begin{document}

\[
\begin{array}{ccc}
 & {} & \textrm{Integration Steps} 
\\
 {} & {} & \int_{0}^{1}x^{3}d x  
\\
 \textrm{▫} & {} & \textrm{1. Apply the}\textrm{power}\textrm{rule to the term}\int x^{3}d x  
\\
 {} & \textrm{◦} & \textrm{Recall the definition of the}\textrm{power}\textrm{rule, for n}\textrm{≠}\textrm{-1} 
\\
 {} & {} & \int x^{n}d x =\frac{x^{n +1}}{n +1} 
\\
 {} & \textrm{◦} & \textrm{This means:} 
\\
 {} & {} & \int x^{3}d x =\frac{x^{3+1}}{3+1} 
\\
 {} & \textrm{◦} & \textrm{So,} 
\\
 {} & {} & \int x^{3}d x =\frac{x^{4}}{4} 
\\
 {} & \textrm{◦} & \textrm{Apply limits of definite integral} 
\\
 {} & {} & \frac{x^{4}}{4}{\raisebox{-0.36em}{$\Big |$}}{\mstack{}{_{x \hiderel{=}1}}}-\left(\frac{x^{4}}{4}{\raisebox{-0.36em}{$\Big |$}}{\mstack{}{_{x \hiderel{=}0}}}\right) 
\\
  & {} & \textrm{We can rewrite the integral as:} 
\\
 {} & {} & \frac{1}{4} 
\end{array}
\]

\end{document}

And now when compiling the above using the latex compiler, it gives this error

(base) >pdflatex foo5.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./foo5.tex
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-12-07> xparse <2020-03-03> (/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2020/texmf-dist/tex/latex/tools/array.sty) (/mnt/g/public_html/styles/maple.sty
Package: maple 2005/03/17 v1.16
Defining Maple Utility Macros
Defining Maple Plot Environemnts
 ...Defaults to "dvips" Driver
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/epsfig.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/dvips.def))))
Defining Automatic Style Generation Macros
Defining Maple Spreadsheet Environments
Maple Spreadsheet and Table Support
! Undefined control sequence.
l.3248 \pdfstringdefDisableCommands
                                   {\let\(\fakemath}    % 2.
?

The above command is on line 3248 in maple.sty file

 

I tried to workaround it, but do far could not find a way.

Is there a way to fix this problem in Maple 2021 latex?

I have found few PDE's so far  that timeout in Maple 2021 which did not do that in Maple 2020.2. Using same amount of time out, on same PC.

After some debugging, I found that that cause is calling latex:-Settings(....) before calling  timelimit(pdsolve(...))  causes the timeout.

At first, I thought this must be coincidence. Why would calling latex make pdsolve timeout?

So I tried again and again and again. Each time, removing the call to latex makes pdsolve not time out. Putting latex call back in, now pdsolve times out. Each time restart is always called (in new cell) before.

The timeout is 10 minutes.  Without latex called before, pdsolve took about about 5 minutes on my PC to solve the PDE.  

Any one could see if they can reproduce this?

Why would calling latex:-Settings(....)  causes pdsolve now use all 10 minutes and then timeout? This is very strange.

Maple 2021. Latex Physics package. Windows 10.

attached is worksheet showing this with many tries.

restart;
latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= mixed, ## computernotation,
      leavespaceafterfunctionname = true,
      cacheresults = false,
      spaceaftersqrt = true  
);

pde :=  a*ln(lambda*x)^n*diff(w(x,y),x)+ b*ln(mu*x)^m*diff(w(x,y),y) = c*ln(nu*x)^k*w(x,y)+p*ln(beta*y)^s+q;
timelimit(60*10,pdsolve(pde,w(x,y)));

#Error, (in expand) time expired
#OR 
#Error, (in evala/Divide/heuristic) time expired


restart;
pde :=  a*ln(lambda*x)^n*diff(w(x,y),x)+ b*ln(mu*x)^m*diff(w(x,y),y) = c*ln(nu*x)^k*w(x,y)+p*ln(beta*y)^s+q;
timelimit(60*10,pdsolve(pde,w(x,y)));

#no problem solution found.

 

why_time_out_with_latex_march_23_2021.mw

When inside a section, why typing a command or any Maple expression, makes the cursor jump to outside the section after that?

Is it possible to create a new cell (i.e. >) and jump to that, so to remain inside the section?

Currently, I have to do CTRL-J to make new exection group, i.e. >, below the current one and remain inside the section, which is too much work. 

This is using worksheet mode. I see an option in tools->options->display to do that automatically. Which is great. But it does not work inside a SECTION. 

This is how to reproduce

1. set  tools->options->display->always insert new execution group after executing

2. In worksheet, click on insert->section to make new section.

3. in the first cell inside the section, type any Maple command or statement. Now you will see the cursor jumps outside the section, and makes new exection group (i.e. >).  But my cursor is now outside the section. So I have to move it back to inside the section.

I want to remain inside the section and have ">" be created inside the section.

Is this possible?

Maple 2021, windows. Worksheet mode.

I will make small movie to illustrate.

 

sometimes when I see such things, I get the feeling that the folks who develop the interface at Maplesoft, do not use it too much themselves. Else they would have noticed this annoyance in using sections. 

When inside a section, one would expect that a new exection cell to be created inside the section itself and not outside. 

 

First 53 54 55 56 57 58 59 Last Page 55 of 164