nm

8552 Reputation

19 Badges

12 years, 354 days

MaplePrimes Activity


These are replies submitted by nm

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

 

@Scot Gould 

 

I do not use math mode and will never do. math mode i.e. document mode, 2D input, etc.. all of this is not the Maple language.

I only write pure Maple code.  Something that will show as is in plain text file.

Maplesoft wants everyone to switch to clickable things and use 2D math fonts and such and not use the Maple programming language as it was originally. That is why I do not use Maple any more as my main tool. There is basically now two languages/systems packages into one.

 

it works for me. Maple 2017.2 on windows

 

@Seb1123 

if it is any help, mathematica also can't solve it. It gives warning message

ode=y''''[t]+10*y''[t]+169*y[t]==0
bc={y[0]==0,y'[0]==1,y[Infinity]==0};
DSolve[{ode,bc},y[t],t]

   {}

 

DSolve::bvlim: For some branches of the general solution, unable to compute the limit at the given points. Some of the solutions may be lost.

In Maple, you can see something similar as follows

restart;
diffeq := diff(y(t),t$4)+10*diff(y(t),t$2)+169*y(t)=0;
bc:=y(0)=0, D(y)(0)= 1;
sol:=dsolve({diffeq,bc},y(t));
limit(rhs(sol),t=infinity);

Which gives  "UNDEFINED"

 

@Seb1123 

A 4th ODe does not need 4 boundary conditions

At school the teacher told us that an nth order ODE needs n boundary/or initial conditions for complete solution. If you do not provide these, the solution will contain constants of integrations instead. Since you have 4th order ODE, but you only supplied 3 conditions. That is why I said you probably need another conditions to fully satisfy the ODE.

btw, I do not see anything wrong with the syntax you used. When maple returns nothing it means it can't figure how to solve the ODE with these boundary conditions.

 

4th order ODE needs 4 boundary conditions?

dsolve({diffeq,y(0)=0,D(y)(0)=1,D(y)(infinity)=0},y(t)) 
Returns nothing.

May be becuase the boundary conditions at infinity makes Maple not able to find a solution?

 

@vv 

Thanks but Iam little confused about how is this suposed to be used. Does one have to supply value at which these function evaluate? How does one know which x,y values to use? For example

facxy(1/(x-1)*y,x=1,y=1);

Here it is separable. {  1/(x-1)  , y }   I picked say x=1,y=1 but this gives

    Error, (in facxy) numeric exception: division by zero

How is user supposed to figure what x,y to use? if I pick x=0, but later do

facxy(1/x * y,x=0,y=1);

Same problem shows up. I do not know in advanced what the functions are.

 

 

@Mac Dude 

"It isn't quite clear to me why you would want to do that, but of course there maybe perfectly valid reasons I just haven't encountered yet. "

In cases when a proc() wants to construct a mathematical expression, which uses symbol not passed by user. Consider for example dsolve. It returns constant of integration. Maple calls that _C1, _C2. etc... These symbols were not passed in by user.

One can carry this for more symbols than just _C1...

Thanks for the hint about exporting the symbols. This is useful. I only use simple proc() now and not advanced enough to use modules yet.

First 50 51 52 53 54 55 56 Last Page 52 of 71