nm

5701 Reputation

17 Badges

8 years, 300 days

MaplePrimes Activity


These are replies submitted by nm

@tomleslie 

    because you were incapable of formulating the question correctly

Now you are being very rude.

 

@acer 

As I mentioned, I tried to make the input a minimal to address the issue of Maple changing "0" to 0 when using Import with CSV format.

My files are very complicated and very large. So I wanted to make the example file as small as possible for the issue of conversion of string to integer, which I did.

I did not know there could be a solution given which uses a comma option to seperate the fields, which will affect how it works on other string fields when used on my actual larger files.

But thanks again for your suggestion.

 

 

 

@acer 

Thanks for the suggestion, but unfortunately ImportMatrix does not work for my data. The example input file  I showed did not include actual data from my file, since I did not know this will be an issue with the comma (did not know about the option you used to anticipate this).

The data files I have, contains strings of Latex code also as fields.

And these strings contain inside them commas. 

Import(file_name,format="CSV",output=Matrix); handles this OK. But ImportMatrix(file_name, source=delimited, delimiter=","); does not, as it will now split the Latex string apart which breaks things. Here is a better input file example

t.txt

1,2,"0",4
1,2,"1",4
1,2,"A",4
1,2,"\int \frac{(a+b x)^2 (A+B x)}{\sqrt{c+d x} \sqrt{e+f x} \sqrt{g+h x}} \, dx",4

Here is to compare

data1:=ImportMatrix(file_name, source=delimited, delimiter=",");
LinearAlgebra:-Dimension(data1);
data2:=Import(file_name,format="CSV",output=Matrix);
LinearAlgebra:-Dimension(data2);

This is the output

 

why do you care what method Maple uses to solve the PDE? 

Maple just gives final solution anyway. Not step-by-step solution. At least not for pde's.

Would you have a concrete example of an input vector field, and what is the expected output from the gradient of this field?

From what I found, the gradient of vector field is the Jacobian matrix.

https://towardsdatascience.com/step-by-step-the-math-behind-neural-networks-d002440227fb

And

https://www.quora.com/Does-gradient-of-vector-field-exist

In this case, one can use VectorCalculus:-Jacobian  and change the coordinates systems using VectorCalculus:-SetCoordinates

Here is an example

restart;
VectorCalculus:-SetCoordinates( 'cartesian'[x,y,z] );
F:=VectorCalculus:-VectorField(<3*x^2*y,2*x+y^8,z>);
VectorCalculus:-Jacobian(F,[x,y,z]);

VectorCalculus:-SetCoordinates( 'cylindrical'[rho,phi,z] );
F:=VectorCalculus:-VectorField(<3*(rho*cos(phi))^2*(rho*sin(phi)),2*(rho*cos(phi))+(rho*sin(phi))^8,z>);
VectorCalculus:-Jacobian(F,[rho,phi,z]);

VectorCalculus:-SetCoordinates( 'spherical'[rho,theta,phi] );
F:=VectorCalculus:-VectorField(<3*(rho*sin(theta)*cos(phi))^2*(rho*sin(theta)*sin(phi)),2*(rho*sin(theta)*cos(phi))+(rho*sin(theta)*sin(phi))^8,rho*cos(theta)>);
VectorCalculus:-Jacobian(F,[rho,theta,phi]);

 

If you had in mind a different definition of what gradient of vector field other than the Jacobian matrix, may be it will be useful if you could post a link to such definition and an example to make it more clear.

Maple 2021

 

@Carl Love 

Thanks for checking.

The only difference in setting, is that you had interface(prettyprint) set to 2, while my default is 3. But I change it to 2, and it made no difference.

The other non setting difference, is that I have Latest Physics package and you do not?
 

restart:
Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 972 and is the same as the version installed in this computer, created 2021, April 30, 20:23 hours Pacific Time.`

interface(version);

`Standard Worksheet Interface, Maple 2021.0, Windows 10, March 5 2021 Build ID 1523359`

interface(typesetting);

extended

interface(prettyprint);

3

latex:-Settings();

[cacheresults = true, commabetweentensorindices = false, copyaslatexinput = false, invisibletimes = " ", leavespaceafterfunctionname = false, linelength = 66, powersoftrigonometricfunctions = mixed, spaceaftersqrt = true, usecolor = true, usedisplaystyleinput = true, useimaginaryunit = I, useinputlineprompt = true, userestrictedtypesetting = false, usespecialfunctionrules = true, usetypesettingcurrentsettings = false]

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(sol);

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

interface(prettyprint=2);

3

interface(prettyprint);

2

latex(sol);

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

 


 

Download may_3.mw

@ecterrab 

THanks. I included the packages that I thought I needed. After all, I am only exporting some math and text, so I thought that is what needed is. 

\usepackage{amsmath}
\usepackage{array}
\usepackage{maple}

But now I exported the latex file itself. i.e. I typed in new worksheet the following

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

Then did file->export as->Latex after evaluating the above.    

Two issues:  The latex file does not compile. it gives error

>pdflatex t.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./t.tex
.............
! Undefined control sequence.
<argument> \[\begin {array}{ccc} & & \textrm {Integration Steps} \\ & & \int _{0}^{1}x^{3}dx \\ \textrm {▫} & & \textrm {1. Apply the}\boldsymbol {\textrm {power}}\textrm {rule to the term}\intx
                                                                                                                                                                                                     ^{3}dx \\ & \textrm {◦} & \textrm {Recall the defini...
l.75 \end{array}\]}

?

I am using current texlive.  

Second issue: Maple generates \usepackage{breqn}

This package breqn is known to cause massive problems as it redfined many things. I stopped using it long time ago as it could break latex compilation due to conflict with other package. There are many post about this in tex forum. It will be best if Maple latex export does not use this package at all.

Please see worksheet attached.  I wonder if the above latex file generated compiles OK for others. Here is the latex file generated by Maple. 

 

%% Created by Maple 2021.0, Windows 10
%% Source Worksheet: t
%% Generated: Sun Mar 28 15:07:48 CDT 2021
\documentclass{article}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{mathtools}
\usepackage{maple}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{amsmath}
\usepackage{breqn}
\usepackage{textcomp}
\begin{document}
\lstset{basicstyle=\ttfamily,breaklines=true,columns=flexible}
\pagestyle{empty}
\DefineParaStyle{Maple Bullet Item}
\DefineParaStyle{Maple Heading 1}
\DefineParaStyle{Maple Warning}
\DefineParaStyle{Maple Heading 4}
\DefineParaStyle{Maple Heading 2}
\DefineParaStyle{Maple Heading 3}
\DefineParaStyle{Maple Dash Item}
\DefineParaStyle{Maple Error}
\DefineParaStyle{Maple Title}
\DefineParaStyle{Maple Ordered List 1}
\DefineParaStyle{Maple Text Output}
\DefineParaStyle{Maple Ordered List 2}
\DefineParaStyle{Maple Ordered List 3}
\DefineParaStyle{Maple Normal}
\DefineParaStyle{Maple Ordered List 4}
\DefineParaStyle{Maple Ordered List 5}
\DefineCharStyle{Maple 2D Output}
\DefineCharStyle{Maple 2D Input}
\DefineCharStyle{Maple Maple Input}
\DefineCharStyle{Maple 2D Math}
\DefineCharStyle{Maple Hyperlink}
\begin{lstlisting}
> interface(version);
Physics:-Version();
\end{lstlisting}
% \mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{}
{\[\mathit{Standard\,Worksheet\,Interface,\,Maple\,2021.0,\,Windows\,10,\,March\,5\,2021\,Build\,ID\,1523359\,} \]}
\end{maplelatex}
% \mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{}
{\[\mathit{The\,``Physics\,Updates"\,version\,in\,the\,MapleCloud\,is\,938\,and\,is\,the\,same\,as\,the\,version\,installed\,in\,this\,computer,\,created\,2021,\,March\,27,\,12:39\,hours\,Pacific\,Time.\,} \]}
\end{maplelatex}
\begin{lstlisting}
> restart;

\end{lstlisting}
\begin{lstlisting}
> Student:-Calculus1:-ShowSolution(Int(x^3,x=0..1));
\end{lstlisting}
% \mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{}
{\[\begin{array}{ccc}
 &  & \textrm{Integration Steps} 
\\
  &  & \int_{0}^{1}x^{3}dx  
\\
 \textrm{▫} &  & \textrm{1. Apply the}\boldsymbol{\textrm{power}}\textrm{rule to the term}\intx^{3}dx  
\\
  & \textrm{◦} & \textrm{Recall the definition of the}\boldsymbol{\textrm{power}}\textrm{rule, for n}\textrm{≠}
\\
\textrm{-1} 
\\
  &  & \intx^{n}dx =\frac{x^{n +1}}{n +1} 
\\
  & \textrm{◦} & \textrm{This means:} 
\\
  &  & \intx^{3}dx =\frac{x^{3+1}}{3+1} 
\\
  & \textrm{◦} & \textrm{So,} 
\\
  &  & \intx^{3}dx =\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{maplelatex}
\begin{lstlisting}
> 
\end{lstlisting}
\begin{lstlisting}
> 
\end{lstlisting}
\end{document}

t.mw

 

@KiviKnuuti 

where when you type a bracket, it creates a grey closing bracket and the cursor stays between them.

Ok, this explains it a little more clearly.

But this is trivial to do.  I do this all the time. I always type () myself to start with, then go back to fill the stuff in between the brackets. I guess it is by habit I do this all the time.   

So what you are asking for, is for maple to automatically add   )  when you first type  ( but leaving the mouse after the first (

The difference between this and manually typing () first yourself, is that you do not need to move the mouse back to the front of the first (

I myself do not like this. I've seen it in other text editors. I turn this feature off in every editor I use which does this automatically.

Since I like to add () explicitly myself each time, I find I get   (  ))  if I keep this feature on. But this a preference ofcourse.

 

 

 

when I type "sin(pi" it would automatically create a closing bracket

I must be missing something. How is Maple supposed to know you want to put closing after you typed Pi ?

What if someone wanted to type  sin(Pi+2) ?  Then the code will come out sin(Pi)+2 instead?

Maple has auto bracket matching already. So all what you have to do, is insert ) and maple will flash quickly the corressponding on the line, which is very useful. 

@Kitonum 

Thanks for checking. In Maple 2020.2 it also shows the dots, just like in Maple 2021. So this seems to have changed sometime after Maple 2018?

 

@johan162 

Thanks. I just checked. I have no Maple profile and I do not use any startup code at all.

I also updated Physics package to latest now, and copy as latex still does not work. Copies nothing. the clipboard is empty.

May be something with the window 10 version I have. oh well. I could always just do latex() and then copy the output of the command. That always worked. 

@johan162 

"that I had som custom startup profile code and in that code I had re-bounded the latex command to the physics package version of the command and the consequence was that latex now was inert and gave the behaviour you are seeing where "Copy as latex" does nothing."

I do not have any of the above. I never changed latex command myself. latex() works find in the worksheet. But not as "save as".

But I will loolk. Where is this start up profile file that I should look for? Where would be it located in the systems? I am using windows 10.

@ecterrab 

Hello;

libname gives
     "C:\Program Files\Maple 2021\lib", "C:\Users\me\maple\toolbox\DirectSearch\lib",        "C:\Users\me\maple\toolbox\OrthogonalExpansions\lib"

I have not changed anything with libname after installing Maple 2021 a week or so ago.

I have not had chance to install Physics package yet. So Maple is still in same state as installed.

I updated the movie also to show the above. I made sure window clipboard is clear. Then did the above copy as latex, but window says clip board is empty and I get beep when pasting.

Will play more with it to see why. I tried few times, restarted maple few times. it is not working for me. Do not know why.


 

I can't even get copy as latex to work. (First time I tried it also in Maple 2021)

Could you show step by step what you did? I tried in worksheet and in document.