Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Why do maple not contract over inert differentials ?
The last command just return the defining equation and refuses to contract.

See example below

restart;
with(Physics);
g_[[5, 29, 1]];
eq1 := g_[~mu, ~nu]*Diff(w(r, theta), mu)*Diff(w(r, theta), nu);
SumOverRepeatedIndices(eq1);

-----------------------------------------------------------------------------------
However Check return empty coordinates, which is completely contradictory.

Check(eq1, all);
      The repeated indices per term are: ((...),(...),...)

        , the free indices are: (...)

                    [{}], {~mu, ~nu}

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

 

 

For a system of 8 equations, it takes too long for me to solve it by using solve, but I can only give one solution by using fsolve. If I want solutions in other ranges, I need to provide a general range, but I don't know the range, how can I quickly find all the solutions?question1118.mw

eqs := [a = b, c = d, e = f]:

map(`+`, eqs, 2);
map(`-`, eqs, 2);
map(`/`, eqs, 2);
         [a + 2 = b + 2, c + 2 = d + 2, e + 2 = f + 2]

         [a - 2 = b - 2, c - 2 = d - 2, e - 2 = f - 2]

               [1     1    1     1    1     1  ]
               [- a = - b, - c = - d, - e = - f]
               [2     2    2     2    2     2  ]

These work differently

map(`*`, eqs, 2);
map(`^`, eqs, 2);
               [2 (a = b), 2 (c = d), 2 (e = f)]

Error, non-algebraic base in a power: a = b

(The first one can be dealt with by applying eval to the output)

Why do not all work the same way?

Edit:
Generic work arounds where arithop is one of: + - / * ^

map(eval@`arithop`, eqs, 2);
map(map@`arithop`, eqs, 2);# Update: Maple 2021 and higher
[seq(i arithop 2, i in eqs)];

Hi all,

I successfully typed in some Maple code in the form of a simple minded procedure.

pairs_of_prime_numbers_procedure_with_union_and_isprime.mw

pairs_of_prime_numbers_procedure_with_union_and_isprime.pdf

Hopefully this is useful to someone.

Have a nice day

big Matt

Hello,

I present the rolling of an ellipse along a spatial curve and along curves placed on a surface, also along a Mobius surface.

Attached are the Maple source files.

Best regards.

Source_-_mw.zip






Hi, the below code is the equation of a standard ellipse intersects the line at two points, (x1,y1) and (x2,y2).

I wanna "y1+y2" and "y1*y2" generate by specific code auto, no need to input "k*x1_plus_x2 + 2*b" and "b*k*x1_plus_x2 + k^2*x1_by_x2 + b^2" manually. But I don't know how to edit it? maybe sequence?

Any answer and reply is welcome.

restart

The below code is the equation of a standard ellipse intersects the line at two points, (x1,y1) and (x2,y2).

I wanna "y1+y2" and "y1*y2" generate by specific code auto, no need to input "k*x1_plus_x2 + 2*b" and "b*k*x1_plus_x2 + k^2*x1_by_x2 + b^2" manually. But I don't know how to edit it? maybe sequence?

Error, missing operator or `;`

 

C := x^2/A^2+y^2/B^2-1

x^2/A^2+y^2/B^2-1

(1)

l := y = k*x+b

y = k*x+b

(2)

subs(l, C)

x^2/A^2+(k*x+b)^2/B^2-1

(3)

eq := collect(%, {x, x^2})

(1/A^2+k^2/B^2)*x^2+2*b*k*x/B^2+b^2/B^2-1

(4)

x1_plus_x2 := simplify(-coeff(eq, x)/coeff(eq, x^2))

-2*b*k*A^2/(A^2*k^2+B^2)

(5)

x1_by_x2 := simplify(coeff(eq, x, 0)/coeff(eq, x^2))

(-B^2+b^2)*A^2/(A^2*k^2+B^2)

(6)

x1 := solve(eq = 0, x)[1]; x2 := solve(eq = 0, x)[2]

-(b*k*A-(A^2*B^2*k^2+B^4-B^2*b^2)^(1/2))*A/(A^2*k^2+B^2)

 

-(b*k*A+(A^2*B^2*k^2+B^4-B^2*b^2)^(1/2))*A/(A^2*k^2+B^2)

(7)

subs(x1, l); subs(x2, l)
I don't know how to make it like y1=k*x1+b and y2=k*x2+b auto in this procedure.

Error, invalid input: subs received -(b*k*A-(A^2*B^2*k^2+B^4-B^2*b^2)^(1/2))/(A^2*k^2+B^2)*A, which is not valid for its 1st argument

 

Error, invalid input: subs received -(b*k*A+(A^2*B^2*k^2+B^4-B^2*b^2)^(1/2))/(A^2*k^2+B^2)*A, which is not valid for its 1st argument

 

Error, missing operator or `;`

 

y1_plus_y2 := simplify(k*x1_plus_x2+2*b)

2*b*B^2/(A^2*k^2+B^2)

(8)

y1_by_y2 := simplify(b*k*x1_plus_x2+k^2*x1_by_x2+b^2)

B^2*(-A^2*k^2+b^2)/(A^2*k^2+B^2)

(9)
 

 

Download ask_ellispe_and_straight_line.mw

I needed to plot a function, using  plot in Maple.

plot(sin(x)*sqrt(1 - (sin(x)/x)^2), x = 0 .. Pi/4)

The graph shown by Maple seems to be identically 0 from x=0 up to some x*. At this point it jumps and for x>x* it looks fine. Of course the function has a singularity at x=0, but even changing the left end of plotting range to something small but positive does not alleviate the problem. Another strange thing is that x* seems to depend on the (end point of) the plotting range.

restart:

 

inte_eq := int(-(sum(B[i]*beta[i]* exp(-beta[i] * (t-tau)),i=1..n)),tau=0..t);

int(-(sum(B[i]*beta[i]*exp(-beta[i]*(t-tau)), i = 1 .. n)), tau = 0 .. t)

(1)

how to solve this ?

Download creep_integral_sol.mw

I experience Maple 2024 not beeing responsive.

It happens often that nothing is happening for 10 to 15 seconds after placing the cursor in an input line.

When the cursor is back, typing is normal for a little while and then again Maple is not reacting to user input.

The worksheets I am working with are between 50 and 100 Mb large in file size (containing plot3d structures, approx 1000 frames distributed across several plots:-display statements). It looks to me that the GUI has to do some house keeping from time to time which keeps it buisy with all the plot structures.

I could delete (plot) output, but this would require execution of the worksheet (before deleting the output) each time I want to continue working normally. This takes several minutes to be ready to work.

Anything else that I can do?

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

Hi all

I would like your help to represent the states of the ODE according to the parameter "a" for t=0..10 and a=0..5.
I can do this for a value of t=200.

enfonction_p_2_cas1.mw

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

How to insert a file inside another file, creating a session, without equations with the same name conflicting?

Is there another way to change the x-axis values other than tickmarks? For example on an interval [0,4*Pi]

restart; with(plots); with(DEtools)

Ode1 := diff(y(t), t, t) = cos(t)

diff(diff(y(t), t), t) = cos(t)

(1)

IC := (D(y))(0) = 0, y(0) = 1

(D(y))(0) = 0, y(0) = 1

(2)

gsol := dsolve(Ode1, y(t))

y(t) = -cos(t)+c__1*t+c__2

(3)

exactsol := dsolve({IC, Ode1}, y(t), numeric, output = listprocedure)

odeplot(exactsol, [t, y(t)], 0 .. 4*Pi, color = blue, title = "Solution to the Differential Equation", labels = ["t", "y(t)"])

 

Download directly_integrable.mw

2 3 4 5 6 7 8 Last Page 4 of 2163