nm

8552 Reputation

19 Badges

12 years, 354 days

MaplePrimes Activity


These are replies submitted by nm

I would never export complete maple worksheet to Latex as the quality is not good at all. This is well known for years.

The best solution is to write the latex directly to a file, but one expression at a time (by converting the math expressions to latex using the latex() command, which for the most part works ok but could be better) and write, to the same file, any needed in-between Latex on the fly as the code runs.

At the end of the run, you have a latex file ready to compile.

This way you get best results. It is a little bit more work, but not too much, and with few helper functions it is not too much extra effort. But this assumes one knows some Latex themselves. This gives best results.

This is how I do everything when I want to export some work done using CAS to Latex. Been doing it for years and years using this method.

The hard stuff, which is converting math to Latex is done by CAS itself using its latex() command. The rest is just Latex formating which one can do themselfs. This way you control the actual formating in Latex instead of letting Maple do it.

 

I could give you an answer, but it will be deleted like the last question I answered which is very similar to yours. So will not bother wasting my time.

The command is called pdsolve. Someone below just asked for solution to 1D wave PDE in infinite domain. You can use the code posted there and modify it to fit your specific PDE. You can also look up help for pdsolve for more examples.

 

What are the PDE specification?

There are infinite number of combinations depending on what initial conditions, boundary conditions, domain type and so on.

So it will be a little hard to guess what you have in mind.

@Kros 

it works for me. Updated worksheet.

@Kros 

 

I put the worksheet. As you see, no errors.

@Katherina von Bulow 

Thank you!  I just downloaded version 633 of Physics package  and now Maple is able to solve this PDE as expected. Good job.

 

@vv 

I do not think there is ambiguity. The file is comma delimited. Mathematica can read the above using it as having 8 fields.

data = First@Import["data2.txt", "Table", "FieldSeparators" -> {","}, "Numeric" -> True]

           {1, 2, 3, "x+y, algorithm=[", 123, "]", "OK", 5}

 

 

 

@tomleslie 

thanks but It does not work for me on Maple 2020 on windows 10

a:=[parse(readline( "data.csv"))];

Error, incorrect syntax in parse: unexpected number (near 27th character of parsed string)
 

data.csv is 

 

 

@tomleslie 

thanks for the try. But I can't modify or edit the input files. There have to remain as is, used in other places and generated before and there are 1000's of them. 

@tomleslie 

Sorry, I meant to write "worksheet mode". I never use document mode. I was tried and wrote the wrong one.

Worksheet mode with 1D for input (i.e. classical Maple) and 2D for output.

@ecterrab 

"that this integral is uncomputable; "

Yes, that is correct. This problem is from the book  Handbook of first order partial differential equations, Volume 1, by Polyanin, Zaitsev, Moussiaux (2002).

This is problem  2.6.1.12  at page 38

The book gives only the principal integral to each pde. The the principal integral for this PDE is

So the general solution is an arbitrary function of the above principal integral. The integral can be left unevaluated since it has no antiderivative. This is how the book gives solutions to all the PDE's in this chapter. Here is from the introduction

And in general, Maple does a good job in finding the principal integral for many PDE's and gives solutions as arbitrary function of it, when it can't compute it. Actually the PDE right after this one from the same page, problem 2.6.1.13 Maple solves that way:

And this is what Maple gives for the above

restart;
pde := x*diff(w(x,y),x)+(a*sin(lambda*x)^m*y^2 + k*y + a*b^2*x^(2*k)*sin(lambda*x)^m)*diff(w(x,y),y) = 0;
timelimit(60*10,CodeTools[Usage(assign('sol',pdsolve(pde,w(x,y))),output='realtime'));

Which is the general solution as an arbitrary function of the principal integral. So even though the above integral is not computable, this is the correct solution and can be left as is.

For some reason, for problem 12, it could not find the principal integral as shown in the book.  Otherwise, Maple would have solved this also.

 

@ecterrab 

Thank you for the quick fix. I verified it does not hange any more and now it times out OK:

@Carl Love 

Yes, This worked. Strange that help under readline() does not even mention this.

In other languages, what happens is that when main() returns, all files are automatically closed.

#include <stdio.h>
int main ()  {
    FILE* file = fopen("input.txt", "r");
    return 0;
}

So I was mapping the call to main as the call to a proc() in Maple. Since that is the closest I had to compare with even if they are not exactly the same. 

But issue resolved for me.

Thanks

 

@Samir Khan 

" By the way, Maple 2020's new LaTeX export is better."  Yes, it is better for this example, but it is still does not produce nice latex for basic operations. Consider

expr:=-1/x + 6;

Maple produces

latex(expr);

         -{x}^{-1}+6

Which when compiled looks like

For some reason Maple does not use \frac here. Compare to Mathematica:

expr = -1/x + 6;
TeXForm[expr]

             6-\frac{1}{x}

Which compiles as

Which is better and the ideal output.

I see some bugs are fixed in Maple Latex which is good. But it will be great if the above can also be fixed in Maple 2020.1? as it affects many places.

It seems to me this should not take too much effort or time to fix, but I would not know for sure because I do not know how the latex conversion is implemented inside Maple. If Maple could make the latex conversion code public, that will allow others to help improve it which will  benefit everyone.

btw, adding

_LatexSmallFractionConstant:=0;

has no effect on this. Same latex is generated.

Thank you

 

First 37 38 39 40 41 42 43 Last Page 39 of 71