nm

11353 Reputation

20 Badges

13 years, 13 days

MaplePrimes Activity


These are replies submitted by nm

@Mariusz Iwaniuk 

 

Thank you, This is very good finding. Actually it only needed t>0 added to solve it.

restart:
pde := diff(u(x, t), t)+u(x, t)*(diff(u(x, t), x)) = mu*(diff(u(x, t), x$2));
ic := u(x, 0) =  PIECEWISE([0,x>=0],[1,x<0]);
sol := pdsolve({pde, ic},u(x,t)) assuming mu > 0,t>0;

Yes, the solution given by Maple contains unresolved integrals, but this is better than before.  I noticed also solution comes out not formatted well.

 

a loop? I see no loop in your "formula".

 

 

@Rouben Rostamian  

Thanks. Can I ask how did you know one needed to separate the variables by sum? Since the standard separation of variables is by HINT=`*` . Was is a trial and error, or is something one should have known before?

If I were to solve this by hand, the normal separation of variables is product not sum. 

But now I wil try `+` when pdsolve failes to solve a PDE.

Thanks

@Kitonum 

Thanks. But I am looking for symbolic solution, not numerical. I know Maple can solve this numerically ofcourse.

Do I understand correctly from the title of your post that I have a syntax error? Where is my syntax error?

 

 

 

@dharr 

Thanks for the hint about the Hint=`*`, but your method does not work for me. I get

Error, (in PDEtools/eval/2) numeric exception: division by zero

I copied/pasted your code as your showe it. I am using Maple 2017.3, using Physics:-Version() of `2018, March 9, 22:54 hours`

Which Maple as you using?

 

 

ALso the solution should be a Fourier series solution, as shown in screen shot in the original question.

@John Fredsted 

Why not just

number := (x::integer) -> length(x):

 

@acer 

 

sorry for the typo in the example code I posted. I corrected that later on my PC but forgot to correct it here. I just did. The warning messages still show up btw. I do not know why, even though the code works now as expected and I see the output written to the file correctly. 

read("proc.mpl");
Warning, incomplete string;  use " to end the string
Warning, incomplete string;  use " to end the string
Warning, incomplete string;  use " to end the string
Warning, incomplete string;  use " to end the string
 

It must be due to the string being on multiple lines.

Sorry you think my question was not clear. I thought It was. The reason I did not explain why I am doing, is because I did not think it is needed to answer the question and will cluter things.

I have good reason for generating Latex as I am doing it from a running program. And the question gave a very small example of the problem I am having.

 

 

@acer

But the whole point is that I do not want to write it as

str:="\n\t\\begin{align*}\n\tA =& B \\\\\n\t=& 3\n\t\\end{align*}\n ";

becuase this is meant to be plain latex code, and I wanted it to appear as it would be inside a Latex editor  or any other plain text editor.

So when I write the latex to generate, I want to write it the same way as I do in plain text editor. No one writes "\n" for carriage-return in an editor, but they hit the carriage return key and start on a new line, like this

str:="
    \\begin{align*}
       A =& B \\\\
          =& 3
    \\end{align*}
  ";

The above looks the same as it would in Latex editor. Only difference is to escape the \ with extra \.

Imagine one is writing 20 lines of Latex like the above.

I do this all the time in Mathematica with no problem. I can use writebytes() now in Maple to bypass this issue. I just find Maple handling of \ at end of line very strange. Multiline strings are widely supported these days in many languages.

Please see

https://en.wikipedia.org/wiki/String_literal#Multiline_string_literals

 

 

@vv 

Thanks again. writebytes() works. So replaced FileTools[Text][WriteString] with writebytes().

Have to rememeber to add " ", as in "\\\\ " each time. But I put a yellow stick on side of my monitor to remind me to add space " " when using Maple strings that ends with "\\".

 

@vv 

Thanks, but this Maple behaviour makes no sense at all:

When a backslash character appears as the last character on an input line, whether typed at the Maple command line, or read from a file, the backslash, and the following line ending, is ignored. In other words, the subsequent line is treated as a continuation of the current line.

So how is a user supposed to write this string in Maple:

str:="This is line 1 \\\\
      This is line 2";

And have it show up in the text file as

This is line 1 \\
This is line 2

If this is not possible, then I will forget about doing this in Maple and stick to Mathematica.

I am also not looking for reading, I simply want to emit some Latex strings from inside a Maple proc() to try something. But stuck on this first step.

 

@vv 

You can blame this on Maplesoft help pages. I was copying stuff from the web help pages, written in that awful fonts, which is hard to read and not easily copyable. I must have copied that funny looking :: from there to my worksheet.

On my PC,I use worksheet, not the document mode. All my input is plain Maple code.  It happend this time I copied some things from the Maplesoft help web pages. This must have come from there.

 

@Kitonum 

very nice. You should make this as answer. Your method is only one which splits (x^2*y+y)*y^3*exp(-x-y+1)*3^(-x-y)*sqrt(x^2*y-y) 

I tried both other solutions and not able to make them split the above into separated functions.

Your method:

expr:=(x^2*y+y)*y^3*exp(-x-y+1)*3^(-x-y)*sqrt(x^2*y-y):
r:=Splitting(expr):
xPart:=op(r)[1];
            (x^2+1)*sqrt(x^2-1)*exp(-x)*3^(-x)
yPart:=op(r)[2];
             y^(9/2)*exp(-y+1)*3^(-y)

But why I do not get back zero when I do this?

    simplify(xPart*yPart-expr);
I am sure the splitting is correct, but was wondering why it does not simplify to zero.

Also when I tried it on

expr:= -Pi*(1-cos(x)^2)*sin(y)^3/exp(1);
r:=Splitting(expr);
Error, (in Splitting) ambiguous multiple assignment
 

On the other hand, trying Acer solution on the first example above gives

expr:=(x^2*y+y)*y^3*exp(-x-y+1)*3^(-x-y)*sqrt(x^2*y-y);
F( expr, [x,y] );
                   [1/(exp(x)*3^x),  y^3/(exp(y)*3^y),  (x^2*y+y)*exp(1)*sqrt(x^2*y-y)]

I was expecting splitting like your result.

And trying John solution on your example did not seem to split it either

 

restart;
expr:=(x^2*y+y)*y^3*exp(-x-y+1)*3^(-x-y)*sqrt(x^2*y-y):
s,r := selectremove(z -> has(z,x) and has(z,y),expr):
simplify(select(has,r*expand(s),x));
                      exp(-x-y+1)*sqrt(x^2*y-y)*y*(x^2+1)*3^(-x-y)
simplify(remove(has,r*expand(s),x));
                       y^3

The first answer above contains both x and y in it !

It is clear this is functionality that really should be build in Maple itself and it should work for all expressions.

 

 

 

 

 

@acer 

The return result is confusing. It returns a set of 3 items

expr := -(x^2+1)*y^3*exp(-x-y);
F( expr, [x,y] );

   [(x^2+1)/exp(x), y^3/exp(y), -1]
 

But it should be only 2 functions. Yes, the product is correct. Using the Mathematica function posted at the link I showed in my question returns the two searated functions only as follows

expr=-(x^2+1)*y^3*Exp[-x-y];
getGX[ftest[x,y],x,y]

       E^-x (1 + x^2)

getHY[expr, x, y]
      -E^-y y^3

I guess the question if the minus sign should go with the function which depends on x or if the minus sign should go with the function that depends on the y. This is arbitrary.

If the third entry returned by your function will always be -1 when it is there, then this is no problem. I can always handle this case separatly, so it is not an issue.

@Christopher2222 

 

This does not work correctly.   There is a missing minus sign.

expr := -(x^2+1)*y^3*exp(-x-y)
r:=F( expr, [x,y] );
[op(r)][1];

    ``((x^2+1)/exp(x))

[op(r)][2];
    ``(y^3/exp(y))

 

I also do not understand why all these expressions returned has these `` stuck to them.

 

 

 

@acer 

Thanks. But is it possible to modify this slightly in order to make it easier to use by having your function return the 2 separated functions in a list?  So instead of

expr := -(x^2+1)*y^3*exp(-x-y);
F( expr, [x,y] );

Returning this expression 

          ``((x^2+1)/exp(x))*``(y^3/exp(y))*``(-1)

It will return a list

           { -(x^2+1)  ,  - (y^3/exp(y)) }

This way one can more easily pick each function separatly after the call.

 

First 70 71 72 73 74 75 76 Last Page 72 of 91