Maple 2018 Questions and Posts

These are Posts and Questions associated with the product, Maple 2018

Can you guess what P() produces, without executing it?

P:=proc(N:=infinity) local q,r,t,k,n,l,h, f;
q,r,t,k,n,l,h := 1,0,1,1,3,3,0:
while h<N do 
   if 4*q+r-t < n*t
   then f:=`if`(++h mod 50=0,"\n",`if`(h mod 10=0," ","")); printf("%d"||f,n);   
        q,r,t,k,n,l := 10*q,10*(r-n*t),t,k,iquo(10*(3*q+r),t)-10*n,l
   else q,r,t,k,n,l := q*k,(2*q+r)*l,t*l,k+1,iquo(q*(7*k+2)+r*l,t*l),l+2
   fi
od: NULL
end:

I hope you will like it (maybe after execution).

While using the Physics package in Maple 2018, I am facing a few hurdles. In the file tov.mw ,

1. I have defined a dual-vector with components $u_a$ in step 12, but when I am trying to compute $g(u,u)$ using SumOverRepeatedIndices  in step 15, it is not evaluating the sum.

2. I want to define a tensor $B_{ab}=\nabla_a u_b$. Do I just write Define(B{a,b}=D_[a] u[b]) ?

3. Is there any command to find the symmetric and antisymmetric components and trace of the tensor B or do we evaluate them by writing out the expressions?

Thank you.

restart; with(plots); _EnvHorizontalName := 'x'; _EnvVerticalName := 'y'; para := -2*p*x+y^2 = 0; para1 := -2*p1*x+y^2 = 0; t := y-m*x-p/(2*m) = 0; t1 := y+x/m+(1/2)*p1*m = 0; sol := op(solve([t, t1], [x, y])); eliminate({rhs(sol[1]), rhs(sol[2])}, m); for example : m := 2; p := 1; p1 := -2; PARA := implicitplot(para, x = -3 .. 3, y = -3 .. 3, color = blue); PARA1 := implicitplot(para1, x = -3 .. 3, y = -3 .. 3, color = green); Tang := implicitplot(t, x = -3 .. 3, y = -3 .. 3, color = brown); Tang1 := implicitplot(t1, x = -3 .. 3, y = -3 .. 3, color = aquamarine); NULL; #m is not constant display([PARA, PARA1, Tang, Tang1], view = [-3 .. 3, -3 .. 3], scaling = constrained);#on what curve is the vertex of the angle of 2 tangents ? Thank you.

Hi,

I want to optimize a function f(g(e(x),x))  where g(x) is interpolated and e(x) is not known when the interpolation object is created. I found the intpolation Methods of Maple 2018 very helpful to quickly change the inpterpolation method.

Unfotunately the optimization fails when the interpolation object receives an expression as input.

It works if I just use x. Do you know my the first approach fails?

Is there maybe a way to convert the interpolation object to a piecewise function?

 

Thank you for your help
 

# Optimize with Interpolation Object


points :=  <<0.4000|  10.0000>,
            <0.7000|   10.0000>,
            <1.0000|   10.0000>,
            <0.3000|   30.0000>,
            <0.4000|   30.0000>,
            <0.5000|   30.0000>>;

Data := <0617,0767,0220,0444,0692,0789>*0.001;

intmethod := LinearInterpolation;

g := Interpolation[intmethod](points(1..-1,1),Data):

Matrix(6, 2, {(1, 1) = .4000, (1, 2) = 10.0000, (2, 1) = .7000, (2, 2) = 10.0000, (3, 1) = 1.0000, (3, 2) = 10.0000, (4, 1) = .3000, (4, 2) = 30.0000, (5, 1) = .4000, (5, 2) = 30.0000, (6, 1) = .5000, (6, 2) = 30.0000})

 

Vector[column](%id = 18446884324022199230)

 

LinearInterpolation

(1)

plot(g(x),x=0..1)

 

e := x/sqrt(2);

(1/2)*x*2^(1/2)

(2)

f := 5+g(e)*x^2

"5+(module() ... end module)(module() ... end module,1/2 x sqrt(2)) x^2"

(3)

f_simple := 5+g(x)*x^2

"f_simple:=5+[[["a linear interpolation object"],["with 6 points in 1-D"]]](x) x^2"

(4)

op_f := Optimization[Minimize](f(x),x=0 .. 1);

Error, (in Optimization:-NLPSolve) non-numeric result encountered

 

op_f_simple := Optimization[Minimize](f_simple(x),x=0 .. 1);

[HFloat(4.999979117244145), [x = HFloat(0.028901647183245588)]]

(5)

 

NULL


 

Download convert_interpolation_object.mw

 

 

Dear Sir/Madam, I am new in maple and willing to use an old (yet tested) Maple V code. The program first evaluates two integrals numerically, which depend on the values of "d" and "s" (user-defined), and then computes the values of a cumulative distribution function. The problem is that, when running the code on Maple 2018, the evalf(Int) of the first integrand (named "ex1") results in "Float (undefined)". I would really appreciate your help. Thank you in advance.

 

#Maple V program

assume(x, real, y, real, c1, real, c2, real);
d := 3:
s := .9:
ex1:=(1-exp(-(d-y)*I*x))/I/x*exp(y*I*x/(1-I*x)):
ex1:=simplify(Re(evalc(ex1))):
f1:= unapply(ex1,x,y):
ex2:=(1-exp(-(d-y)*I*x))/I/x*exp(y*I*x/(1-I*x))/(1-I*x):
ex2:=simplify(Re(evalc(ex2))):
f2:=unapply(ex2,x,y):
t1:=evalf(Int(f1(x,s),x=-infinity..infinity));
t2:=evalf(Int(f2(x,s),x=-infinity..infinity));
cumulativeprob:=evalf(subs(c1=1/2,c2=1/2,1-((c1*t1+c2*t2)/(2*Pi)+c1*exp(-s)/2)));

cumulativeprob:=.2503779941

 

How do I simplify KdV equation in Maple by using =fxt))xx)?)


 

``

   I am by using =2*difffxtxx)
    My aim is to get the form
   diff((f*(diff(f, x, t))-(diff(f, x))*(diff(f, t))+f*(diff(f, x, x, x))-4*(diff(f, x, x, x))*(diff(f, x))+3*(diff(f, x, x))^2)/f^2, x) = 0

NULL

``

restart; with(PDEtools); with(DEtools)

``

alias(u = u(x, t)); declare(u(x, t)); alias(f = f(x, t)); declare(f(x, t))

u

 

` u`(x, t)*`will now be displayed as`*u

 

u, f

 

` f`(x, t)*`will now be displayed as`*f

(1)

KdV := diff(u, t)+6*u.(diff(u, x))+diff(u, x, x, x) = 0

diff(u, t)+6*(u.(diff(u, x)))+diff(diff(diff(u, x), x), x) = 0

(2)

KdV_f := eval(KdV, u = 2*(diff(ln(f), x, x)))

2*(diff(diff(diff(f, t), x), x))/f-2*(diff(diff(f, x), x))*(diff(f, t))/f^2-4*(diff(f, x))*(diff(diff(f, t), x))/f^2+4*(diff(f, x))^2*(diff(f, t))/f^3+6*((2*(diff(diff(f, x), x))/f-2*(diff(f, x))^2/f^2).(2*(diff(diff(diff(f, x), x), x))/f-6*(diff(diff(f, x), x))*(diff(f, x))/f^2+4*(diff(f, x))^3/f^3))+2*(diff(diff(diff(diff(diff(f, x), x), x), x), x))/f-10*(diff(diff(diff(diff(f, x), x), x), x))*(diff(f, x))/f^2+40*(diff(diff(diff(f, x), x), x))*(diff(f, x))^2/f^3-20*(diff(diff(diff(f, x), x), x))*(diff(diff(f, x), x))/f^2-120*(diff(diff(f, x), x))*(diff(f, x))^3/f^4+60*(diff(diff(f, x), x))^2*(diff(f, x))/f^3+48*(diff(f, x))^5/f^5 = 0

(3)

df := collect(KdV_f, f)

6*((2*(diff(diff(f, x), x))/f-2*(diff(f, x))^2/f^2).(2*(diff(diff(diff(f, x), x), x))/f-6*(diff(diff(f, x), x))*(diff(f, x))/f^2+4*(diff(f, x))^3/f^3))+(2*(diff(diff(diff(f, t), x), x))+2*(diff(diff(diff(diff(diff(f, x), x), x), x), x)))/f+(-2*(diff(diff(f, x), x))*(diff(f, t))-20*(diff(diff(diff(f, x), x), x))*(diff(diff(f, x), x))-4*(diff(f, x))*(diff(diff(f, t), x))-10*(diff(diff(diff(diff(f, x), x), x), x))*(diff(f, x)))/f^2+(60*(diff(diff(f, x), x))^2*(diff(f, x))+4*(diff(f, x))^2*(diff(f, t))+40*(diff(diff(diff(f, x), x), x))*(diff(f, x))^2)/f^3-120*(diff(diff(f, x), x))*(diff(f, x))^3/f^4+48*(diff(f, x))^5/f^5 = 0

(4)

factor(simplify(df, size))

2*(12*(((diff(diff(f, x), x))*f-(diff(f, x))^2)/f^2.(((diff(diff(diff(f, x), x), x))*f^2-3*(diff(diff(f, x), x))*(diff(f, x))*f+2*(diff(f, x))^3)/f^3))*f^5+f^4*(diff(diff(diff(f, t), x), x))+f^4*(diff(diff(diff(diff(diff(f, x), x), x), x), x))-f^3*(diff(diff(f, x), x))*(diff(f, t))-10*f^3*(diff(diff(f, x), x))*(diff(diff(diff(f, x), x), x))-2*f^3*(diff(f, x))*(diff(diff(f, t), x))-5*f^3*(diff(f, x))*(diff(diff(diff(diff(f, x), x), x), x))+30*f^2*(diff(diff(f, x), x))^2*(diff(f, x))+2*f^2*(diff(f, t))*(diff(f, x))^2+20*f^2*(diff(diff(diff(f, x), x), x))*(diff(f, x))^2-60*(diff(diff(f, x), x))*(diff(f, x))^3*f+24*(diff(f, x))^5)/f^5 = 0

(5)

``

``

``

``


 

Download KdV_simplify

Here is the minimal working example: 

with(Physics):
Setup(noncommutativeprefix={W,V});
simplify(W^(-1)*(-W^(-1)-W*V^(-2)));

 

It gives the result  below, which is wrong. Or am I misinterpreting? (Maple 2018)

 

(-V^2-W^2)*(1/V^2)*(1/W^2)

 

Here's the recurrence equation I'm trying to solve and the weird answer that Maple 2018 gives me on Windows 10.

Out of curiosity, I started my old computer with  Windows 2000 and Maple V release V (1997 version).
I typed the same lines as before. I got the answer I was looking for immediately.
Answer which I easily improved.
What's happening ?     What am I doing wrong ?

I am often excited by the the latest versions of Maple but recently I have been rather surprised by the things it cannot do.
When that happens, I remember the story of the guy who wants to sell a great watch to another guy.
"This watch is full of new gadgets:
 gps, heart rate, body temperature, outside temperature, micro camera, voice recorder, email, internet ...
 
Only one problem . It doesn't tell time . "
 
Best regards .
 
Réjean

Greeting for all members in Mapleprimes

could I have a simple procedure to plot the following figure

See the attached file.

Amr

Squares.mw

Hollo evreyone,

Can you help me to plot the functions given by the pdf attached file.

N.B : One can take theta=pi.

Best regardsplot.pdf

Hello
    In this example, we have the KdV equation    
         t] - 6 uux] + xxx] = 0                
    I would like to find the Lax pair for the KdV equation, which are    
               Lψ=λψ                
               ψ[t] = Mψ                
        
              Lt+ML-LM = 0  called a compatibility condition               
    So, I will start from this purpose    
    Then we will assume M in the form   
    will assume M in the form   
              M := a3*Dx^3+a^2+a1*Dx+a0              
    thenb using M and L in the for L[tL-LM = 0can find   
      Dx^5+( ) Dx^4+( ) Dx^3+( ) Dx^2+( ) Dx+( )=0              
    then wean find a_i =0,1,2,3   
  In the following maple code to do that 
  my question is    
   .How I canoue the soluo get a_i2,3 usinmaple code  
    any maple packge to find Lax pair for PDE -  


 

restart; with(DEtools); with(PDEtools)

     in this exampile we have KdV equation

      u[t]-6*uu[x]+u[xxx] = 0

    I would likeind the Lax pair for the KdV equation, which are

       Lψ=λψ

    psi[t] = M*psi

   where``

    L[t]+ML-LM = 0    called  apatibility  condition

    So, I  will start this purpose

     L:=-Dx^2+u;

    then we will assume M the m

    Ma3*Dx^3+a2*Dx^2+Dx+a0

    then busing in the form L[t]+ML-LM = 0 can find

  ( ) Dx^5+( ) Dx^4+( ) Dx^3+( ) Dx^2+( ) Dx+( )=0

 then we can find a_i ;i=,2,3

  

the fllowile code to

 my queion is ;

  1) How I can continue the solution  to get a_i ;i=0,1,2,3 using maple code  ?

  2) isir any maple packge to find  Lax pair for PDE ?

 

alias(u = u(x, t)); declare(u(x, t)); alias(a3 = a3(x, t)); declare(a3(x, t)); alias(a2 = a2(x, t)); declare(a2(x, t)); alias(a1 = a1(x, t)); declare(a1(x, t)); alias(a0 = a0(x, t)); declare(a0(x, t))

u

 

` u`(x, t)*`will now be displayed as`*u

 

u, a3

 

` a3`(x, t)*`will now be displayed as`*a3

 

u, a3, a2

 

` a2`(x, t)*`will now be displayed as`*a2

 

u, a3, a2, a1

 

` a1`(x, t)*`will now be displayed as`*a1

 

u, a3, a2, a1, a0

 

` a0`(x, t)*`will now be displayed as`*a0

(1)

_Envdiffopdomain := [Dx, x]

[Dx, x]

(2)

L := -Dx^2+u

-Dx^2+u

(3)

M := Dx^3*a3+Dx^2*a2+Dx*a1+a0

a3*Dx^3+a2*Dx^2+a1*Dx+a0

(4)

 

 

 

LM := expand(mult(L, M))

-a3*Dx^5-2*Dx^4*(diff(a3, x))-a2*Dx^4+Dx^3*u*a3-Dx^3*(diff(diff(a3, x), x))-2*Dx^3*(diff(a2, x))-Dx^3*a1+Dx^2*u*a2-Dx^2*(diff(diff(a2, x), x))-2*Dx^2*(diff(a1, x))-Dx^2*a0+Dx*u*a1-Dx*(diff(diff(a1, x), x))-2*Dx*(diff(a0, x))+u*a0-(diff(diff(a0, x), x))

(5)

ML := expand(mult(M, L))

-a3*Dx^5-a2*Dx^4+Dx^3*u*a3-Dx^3*a1+3*Dx^2*a3*(diff(u, x))+Dx^2*u*a2-Dx^2*a0+3*Dx*a3*(diff(diff(u, x), x))+2*Dx*a2*(diff(u, x))+Dx*u*a1+a3*(diff(diff(diff(u, x), x), x))+a2*(diff(diff(u, x), x))+a1*(diff(u, x))+u*a0

(6)

Commutator := simplify(ML-LM)

a3*(diff(diff(diff(u, x), x), x))+(3*Dx*a3+a2)*(diff(diff(u, x), x))+diff(diff(a0, x), x)+Dx*(diff(diff(a1, x), x))+Dx^2*(diff(diff(a2, x), x))+Dx^3*(diff(diff(a3, x), x))+(3*Dx^2*a3+2*Dx*a2+a1)*(diff(u, x))+2*Dx^4*(diff(a3, x))+2*Dx^3*(diff(a2, x))+2*Dx^2*(diff(a1, x))+2*Dx*(diff(a0, x))

(7)

sol := diff(L, t)-Commutator = 0

diff(u, t)-a3*(diff(diff(diff(u, x), x), x))-(3*Dx*a3+a2)*(diff(diff(u, x), x))-(diff(diff(a0, x), x))-Dx*(diff(diff(a1, x), x))-Dx^2*(diff(diff(a2, x), x))-Dx^3*(diff(diff(a3, x), x))-(3*Dx^2*a3+2*Dx*a2+a1)*(diff(u, x))-2*Dx^4*(diff(a3, x))-2*Dx^3*(diff(a2, x))-2*Dx^2*(diff(a1, x))-2*Dx*(diff(a0, x)) = 0

(8)

collect(sol, [Dx, x])

-2*Dx^4*(diff(a3, x))+(-(diff(diff(a3, x), x))-2*(diff(a2, x)))*Dx^3+(-3*a3*(diff(u, x))-(diff(diff(a2, x), x))-2*(diff(a1, x)))*Dx^2+(-2*a2*(diff(u, x))-3*a3*(diff(diff(u, x), x))-(diff(diff(a1, x), x))-2*(diff(a0, x)))*Dx-a1*(diff(u, x))-a2*(diff(diff(u, x), x))-a3*(diff(diff(diff(u, x), x), x))-(diff(diff(a0, x), x))+diff(u, t) = 0

(9)

 

 

 

 

``

NULL


 

Download find_lax_pair.mw

I want to find the numbers a, b, c, d, t, m, n of this equation. I tried
 

restart:
 k := 0:
 for a to 10 do
for b to 10 do 
for c to 10 do 
for d to 10 do 
for t to 2 do 
for m to 10 do
for n to 10 do 
if a > c and igcd(a, b, c, d, t, m, n) = 1 and abs(b)+abs(d)-n <> 0 then X := [solve(abs(a*x+b)+abs(c*x+d)-t*x^2+m*x-n = 0)]; if nops(X) = 6 and type(X[1], integer) and type(X[2], integer) and type(X[3], integer) and type(X[4], integer) and type(X[5], integer) and type(X[6], integer) then k := k+1; L[k] := [a, b, c, d, t, m, n, X[]] 
end if end if
end do end do end do end do end do end do end do; 
L := convert(L, list); 
k; 
L;

I can not get the result for along time. How can I get the result and reduce the time?

I want to define the co-ordianates (phi, PI, ....)  as functions of some variable eg:- x,y.

 

,Hello dears

I have the following function

where L=10 and I want to plot this function, so I use 

But it does not work.

Is there any help.

Amr

I am trying to find six integer numbers a, b, c, d, n, p so that this equation
abs(a*x+b)+abs(c*x+d)+x^2+n*x+p = 0
has 6 integer solutions are 1, 2, 3, 4, 5, 6. I tried
f:=x-> abs(a*x+b)+abs(c*x+d)+x^2+n*x+p;
solve([f(1) = 0, f(2) = 0, f(3) = 0, f(4) = 0, f(5) = 0, f(6) = 0], [a, b, c, d, n, p])


This equation has no solution. Is there six integer numbers a, b, c, d, n, p so that this equation has 6 integer solutions?

I have just found one solution is
solve(abs(-2*x+5)+abs(-2*x+9)-x^2+7*x-16 = 0, x);

With Mathematica, I see at here 
https://mathematica.stackexchange.com/questions/212808/find-integers-a-b-c-d-m-n-p-so-equation-has-six-distinct-solutions

4 5 6 7 8 9 10 Last Page 6 of 49