nm

10184 Reputation

19 Badges

12 years, 141 days

MaplePrimes Activity


These are questions asked by nm

Any idea why Maple returns empty string when asked for the latex of the Laplace of x(t)?  Am I doing anything wrong here? I do not see it

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1828 and is the same as the version installed in this computer, created 2024, November 18, 7:25 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

e:=inttrans:-laplace(x(t),t,s)

laplace(x(t), t, s)

latex(e,'output'='string')

""

 

 

Download latex_of_laplace_nov_21_2024.mw

I was expecting something like this using another software

Did Maple always behave this way for Laplace? I do not have earlier version now to check.  Any workaround?

Is this a known error when using PDEtools:-Solve? I get no error using solve on same input, so thought to ask, just in case it should not happen.

For now, I will change my code to use solve for this.

I am basically solving two equations in Laplace domain for Y1(s) and Y2(s). But since there are initial conditions x(0) and y(0) in the equations, and Laplace has L(x(t),t,s)  then PDEtools:-Solve is not happy, as it sees x(t) and x(0) in same input.

But solve has no problem with this. Who is correct? solve or Solve?

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1828 and is the same as the version installed in this computer, created 2024, November 18, 7:25 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

sys:=[s*laplace(x(t),t,s)-x(0) = -3*laplace(x(t),t,s)+4*laplace(y(t),t,s)+1/(s^2+1), s*laplace(y(t),t,s)-y(0) = -2*laplace(x(t),t,s)+3*laplace(y(t),t,s)+1/s^2];
Ys:=[laplace(x(t),t,s), laplace(y(t),t,s)];

[s*laplace(x(t), t, s)-x(0) = -3*laplace(x(t), t, s)+4*laplace(y(t), t, s)+1/(s^2+1), s*laplace(y(t), t, s)-y(0) = -2*laplace(x(t), t, s)+3*laplace(y(t), t, s)+1/s^2]

[laplace(x(t), t, s), laplace(y(t), t, s)]

solve(sys,Ys);

[[laplace(x(t), t, s) = (x(0)*s^5+4*y(0)*s^4-3*x(0)*s^4+x(0)*s^3+4*y(0)*s^2-3*x(0)*s^2+s^3+s^2+4)/((s^4-1)*s^2), laplace(y(t), t, s) = (y(0)*s^5+3*y(0)*s^4-2*x(0)*s^4+y(0)*s^3+3*y(0)*s^2-2*x(0)*s^2+s^3+s^2+s+3)/((s^4-1)*s^2)]]

PDEtools:-Solve(sys,Ys)

Error, (in PDEtools:-Solve) found functions with same name but depending on different arguments in the given DE system: x(0), x(t). Specification of the dependent variables is required

 

 

Download differenece_between_solve_and_Solve_nov_20_2024.mw

I was not expecting odesteps to show steps for this ode, but crash the server each and everytime?

Anyone could find why? I am using Maple 2024.2 on windows 10 with latest Physics. This might indicate serious problem somewhere. Software should not really crash this easily.

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1827 and is the same as the version installed in this computer, created 2024, November 13, 9:16 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

ode:=5*(1+t^2)*diff(y(t),t)=4*t*y(t)*(y(t)^3-1);

5*(t^2+1)*(diff(y(t), t)) = 4*t*y(t)*(y(t)^3-1)

dsolve(ode);

y(t) = 1/((t^2+1)^(6/5)*c__1+1)^(1/3), y(t) = -(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)-((1/2)*I)*3^(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3), y(t) = -(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)+((1/2)*I)*3^(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)

Student:-ODEs:-ODESteps(ode);


 

Download crash_server_nov_18_2024.mw

here is small movie

 

 

I am learning patten matching in Maple. 

Any one could explain why patmatch(1, (x::anything)^(n::'nonunit'(anything)))   gives true but patmatch(2, (x::anything)^n::'nonunit'(anything)); gives false?

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

restart;

patmatch(1, (x::anything)^(n::'nonunit'(anything)))

true

patmatch(2, (x::anything)^n::'nonunit'(anything));

false

Download patmatch_question_nov_16_2024.mw

I was expecting result similar to using this other software

I do not understand Maple's result. How could I change the patmatch so it does not match 1 to the pattern x::anything^n::anything where n is not 1 ?

Update

To give context, I was trying to write this example from the other software  in Maple:

But when I wrote this

expr:=1 + x^2 + x^4;

F:=proc(X::anything,x::symbol)
    local la,y,n;
    if patmatch(X, (y::anything)^(n::'nonunit'(anything)) ,'la') then  
       f(eval(n,la));
     else
        X;
     fi;
end proc;

map(X->F(X,x), expr);

Maple gave 

So I modified the code now to check for explicit 1,  to avoid this bad match, like this

expr:=1 + x^2 + x^4;

F:=proc(X::anything,x::symbol)
    local la,y,n;
    if patmatch(X, (y::anything)^(n::'nonunit'(anything)) ,'la') then  
        if eval(y,la)=1 then #bug in maple?
           X;
        else
           f(eval(n,la));
        fi;
     else
        X;
     fi;
end proc;

map(X->F(X,x), expr);

And now it gives expected result

Given list L:=[3,4,x,x^2,x^3]; return list of all exponents of x (other than 1). So result should be [2,3]

But this has to be done using patmatch, as this is what I am learning. Not using other means. This is my current code that does this.

restart;
L:=[3,4,x,x^2,x^3];
f:=proc(X::anything,x::symbol)
 local la,n;
 if patmatch(X,x^n::nonunit(anything),'la') then
    assign(la);
    RETURN(n);
 else
    RETURN(NULL);
 fi;
end proc;

map(X->f(X,x),L);

Returns [2,3]

I wanted to shorten it using `if` so that no need to call external function f() as shown. So I wrote

L:=[3,4,x,x^2,x^3];
map(X->`if`( patmatch(X,x^n::anything,'la'),[assign(la), n],NULL),L);

But the problem is that on first entry, the assign(la) now assigns value to and hence it is no longer a name for the next element in the list L. This gives error

Error, (in PatternMatching:-AlgStruct:-Match) first operand of `::' must be a name
So I added  unassign('n') like this

restart;
L:=[3,4,x,x^2,x^3];
map(X->[unassign('n'),`if`( patmatch(X,x^n::nonunit(anything),'la'),[assign(la), n],NULL)][],L);

And now this returns 

            [[2], [3]]

How to make it return [2,3]? Why did it add extra []? How can the above be shortened more? and still return [2,3]

edit: I found how to get rid of the extra [], like this

restart;
L:=[3,4,x,x^2,x^3];
map(X->[unassign('n'),`if`( patmatch(X,x^n::nonunit(anything),'la'),[assign(la), n][],NULL)][],L);

Now it returns [2,3] , needed to add extra [] after each closing [.....]

In another system, the code is 

Cases[{3, 4, x, x^2, x^3}, x^n_ -> n]

    {2, 3}
   

I was trying to make the Maple code as short as possible. I know it will not be as short as the above.

The question is: Can above code be made shorter but still use patmatch?

Again, I am looking for only solution using patmatch. I know I can use select and types in Maple to do this also.

Maple 2024.2

1 2 3 4 5 6 7 Last Page 1 of 185