Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How can I organize the KKT conditions I derived into a table format?

Can you confirm whether the substitutions I made for the lower and upper bounds are correct?

KKT_Table_Q-22.mw

When optimizing with constraints, I’m getting an error: ‘NLP no feasible point’.

However, when I plot the graph, it shows a result — there appears to be a point where p1 is positive and s is maximized.

Could you help identify if there’s a syntax issue? Also, what’s the correct syntax to visualize the constraints in the plot?

Sheet: 07.mw

Hello,

I’m trying to solve a problem from Modern Mathematical Methods for Scientists and Engineers using Maple, specifically applying the Fokas method (Unified Transform) to the heat equation on the half-line. The problem setup matches Example 9.1 from the book.

Everything runs fine until I try to plot the solution using plot3d.
 

restart; with(plots); with(LinearAlgebra); with(Student[VectorCalculus]); V := proc (k, x, t) options operator, arrow; -((1/2)*I)*exp(I*k*x-k^2*t)*(1/(k-I)+1/(k+I)-k*(1/(k^2+1)+1/(k^2-1)))/(Pi*k) end proc

proc (k, x, t) options operator, arrow; Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(I, Student:-VectorCalculus:-`*`(2, Pi)^Student:-VectorCalculus:-`-`(1)), Student:-VectorCalculus:-`*`(exp(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(I, k), x), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(k^2, t)))), k^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(k, Student:-VectorCalculus:-`-`(I))^Student:-VectorCalculus:-`-`(1), Student:-VectorCalculus:-`+`(k, I)^Student:-VectorCalculus:-`-`(1)), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(k, Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(k^2, 1)^Student:-VectorCalculus:-`-`(1), Student:-VectorCalculus:-`+`(k^2, -1)^Student:-VectorCalculus:-`-`(1))))))) end proc

(1)

phi1 := (1/8)*Pi; phi2 := 7*Pi*(1/8); k1 := proc (r) options operator, arrow; r*exp(I*phi1) end proc; k2 := proc (r) options operator, arrow; r*exp(I*phi2) end proc; dk1 := proc (r) options operator, arrow; diff(k1(r), r) end proc; dk2 := proc (r) options operator, arrow; diff(k2(r), r) end proc

u1 := proc (x, t) options operator, arrow; evalf(int(Re(V(k1(r), x, t)*dk1(r)-V(k2(r), x, t)*dk2(r)), r = 0 .. 80)) end proc

proc (x, t) options operator, arrow; evalf(Student:-VectorCalculus:-int(Re(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(V(k1(r), x, t), dk1(r)), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(V(k2(r), x, t), dk2(r))))), r = 0 .. 80)) end proc

(2)

u := proc (x, t) options operator, arrow; exp(-x/sqrt(2))*cos(t-x/sqrt(2))+u1(x, t) end proc

proc (x, t) options operator, arrow; Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(exp(Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(x, sqrt(2)^Student:-VectorCalculus:-`-`(1)))), cos(Student:-VectorCalculus:-`+`(t, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(x, sqrt(2)^Student:-VectorCalculus:-`-`(1)))))), u1(x, t)) end proc

(3)

plot3d(u(x, t), x = 0 .. 3, t = 0 .. 2*Pi, axes = boxed, shading = zhue, style = surface, labels = ["x", "t", "u(x,t)"])

NULL


 

Download fokas_method.mw

Has anyone successfully handled similar integrals inside plot3d? Is there a better way to numerically evaluate the Fokas integral so Maple can plot it efficiently?

 

Dear Maple users

I can plot a pin diagram for the binomial distribution for say n = 20 and p = 0.3. It is one-dimensional, since only the number r of successes is relevant. Now I want to plot a diagram for the multinomial distribution for 3 categories. This means a two dimensional distribution. Let's say n = 20, p1 = 0.2, p2 = 0.5 (then p3 = 1 - p1 - p2 = 0.3). How do I make this plot? Pin diagram, but maybe even better: A Bar Chart. 

I hope someone can help.

Erik

Hi,

look at this Maple code.

short_list_prime_factorization_fun.mw

short_list_prime_factorization_fun.pdf

Have a good day

Matthew

I want to solve my PDE using Homotopy Perturbation Method. I have error while solving i dont know why it is showing error. If anyone knows the what mistake i have done in the code, kindly correct me. I want to find the equation of W(r,z) . dp/dz is a pressure terms which is independent of r. And the initial guess is taken as w0 := (-eta^2 + r^2)/2.  Help me to solve this.

 

 

restart;
PDEtools[declare](w(r, z));
               w(r, z) will now be displayed as w

N := 1;

w0 := (-eta^2 + r^2)/2:
w(r,z) := sum(p^i*w[i](r, z), i = 0 .. N)
                   w[0](r, z) + p w[1](r, z)

HPMEq := (1 - p)*diff(w(r, z), r $ 2) + p*(diff(w(r, z), r $ 2) + diff(w(r, z), r)/r - (1 + lambda)*(dp/dz + A2*M^2*w(r, z) + A1*w(r, z)/Da - m^2*UHS*BesselI(0, m*r)/BesselI(0, m*eta) + A3*sin(Phi))/A1);
                                                                /
                                                                |
        // d  / d            \\     / d  / d            \\\     |
(1 - p) ||--- |--- w[0](r, z)|| + p |--- |--- w[1](r, z)||| + p |
        \\ dr \ dr           //     \ dr \ dr           ///     \

  / d  / d            \\     / d  / d            \\
  |--- |--- w[0](r, z)|| + p |--- |--- w[1](r, z)||
  \ dr \ dr           //     \ dr \ dr           //

     / d            \     / d            \                       
     |--- w[0](r, z)| + p |--- w[1](r, z)|      /             /  
     \ dr           /     \ dr           /   1  |             |dp
   + ------------------------------------- - -- |(1 + lambda) |--
                       r                     A1 \             \dz

         2                            
   + A2 M  (w[0](r, z) + p w[1](r, z))

                                       2                    
     A1 (w[0](r, z) + p w[1](r, z))   m  UHS BesselI(0, m r)
   + ------------------------------ - ----------------------
                   Da                   BesselI(0, m eta)   

                  \
                \\|
                |||
   + A3 sin(Phi)|||
                ///


for i from 0 to N do
    equ[1][i] := coeff(HPMEq, p, i) = 0;
end do;
                     d  / d            \    
                    --- |--- w[0](r, z)| = 0
                     dr \ dr           /    

                           d                                   
                          --- w[0](r, z)      /             /  
 / d  / d            \\    dr              1  |             |dp
 |--- |--- w[1](r, z)|| + -------------- - -- |(1 + lambda) |--
 \ dr \ dr           //         r          A1 \             \dz

                                          2                    
          2              A1 w[0](r, z)   m  UHS BesselI(0, m r)
    + A2 M  w[0](r, z) + ------------- - ----------------------
                              Da           BesselI(0, m eta)   

                 \\    
                 ||    
    + A3 sin(Phi)|| = 0
                 //    


NULL;
cond[1][0] :=  D*w[0](0,z) = 0, w[0](eta,z) = 0;
for j to N do
    cond[1][j] := D*w[j](0,z) = 0,w[j](eta,z) = 0;
end do;
               D w[0](0, z) = 0, w[0](eta, z) = 0

               D w[1](0, z) = 0, w[1](eta, z) = 0


for i from 0 to N do
    dsolve({cond[1][i], equ[1][i]}, {w[i](r,z)});
    w[i](r,z) := rhs(%);
end do;
w(r,z) := evalf(simplify(sum(w[n](r,z), n = 0 .. N)));
convert(w(r,z), 'rational');
w(r,z) := subs(r = 0, w(r,z));
Error, invalid input: rhs expects 1 argument, but received 2
                    w[0](r, z) + w[1](r, z)

                    w[0](r, z) + w[1](r, z)

                    w[0](0, z) + w[1](0, z)


 

Hi,

check out this maple code

positive_odd_integer_factorization_data.pdf

positive_odd_integer_factorization_data.mw

that is all

Regards,

Matthew

In the attached file, (6) is stated as "false." However, it is possible to prove with pen and paper that term1 = term2. In (5), the limit function is sought but not determined.
What am I doing wrong?test1.mw
 

restart

term1 := (2*cos(2^n*x)+1)/(2*cos(x)+1)

(2*cos(2^n*x)+1)/(2*cos(x)+1)

(1)

term2 := product(2*cos(2^k*x)-1, k = 0 .. n-1)

product(2*cos(2^k*x)-1, k = 0 .. n-1)

(2)

term3 := term1*(2*cos(2^n*x)-1)/(2*cos(x)-1)

(2*cos(2^n*x)+1)*(2*cos(2^n*x)-1)/((2*cos(x)+1)*(2*cos(x)-1))

(3)

simplify(term3)

(1+2*cos(2^(1+n)*x))/(1+2*cos(2*x))

(4)

limit((1+2*cos(2^(1+n)*x))/(1+2*cos(2*x)), n = infinity)

limit((1+2*cos(2^(1+n)*x))/(1+2*cos(2*x)), n = infinity)

(5)

is(term1 = term2)

false

(6)

NULL


 

Download test1.mw

 

Why can't the sys0 extracted using the convertsys command be processed with collect? However, when I extract its amplitude and then perform collect again, it works. Why is this happening? Is there a good method to handle this? I feel that copying it out is inconvenient for subsequent modifications.

nature_frequency_question.mw

Hi,

have some Maple code to share.

prime_triplet_0_4_6.mw

prime_triplet_0_4_6.pdf

Enjoy

Matthew

ps Prime numbers are fun

see https://t5k.org/

 

We are a week away from the submission deadline for the Maple Conference!  
Presentation proposal applications are due July 25, 2025.

We are inviting submissions of presentation proposals on a range of topics related to Maple, including Maple in education, algorithms and software, and applications. We also encourage submission of proposals related to Maple Learn. You can find more information about the themes of the conference and how to submit a presentation proposal at the Call for Participation page.

We hope to see there.

I want to define a multivariate function f(x1,x2) and its gradient f1(x1,x2) in order to calculate

f(X)=f(X[0])+grad(f(X[0])*(X-X[0])

I try in this way:

with(LinearAlgebra);
f := x -> x[1]^2 + x[2]^2
f1 := x -> <diff(f(x), x[1]), diff(f(x), x[2])>
A := <2,3>
f(A)
     13
f1(A)
     Error, (in f1) invalid input: diff received 2, which is not valid for its 2nd argument
 

What is wrong and how could I define f1(x) in order to write f1(A) for the gradient of f calculated  at A?
Thanks

I intend to use LinearAlgebra package to do some calculations. I want to compute the basis for large Matrices. My discovery is that the linalg[kernel] command, which the document claims is deprecated, could do such computation significantly faster than the LinearAlgebra[NullSpace] command. For a 200 x 500 large random matrix, linalg[kernel] clocked 33 secs, while the LinearAlgebra[NullSpace] takes 200 secs, as shown in the worksheet NullSpace_vs_kernel.mw.

I wanna know what makes the difference, or is there a misuse for LinearAlgebra[NullSpace].

Hi,

Don't laugh.

Some of you are not familair with Wagstaff Prime Numbers

see Wolfram Math World

also, this Maple code is esentially, a loop and the isprime() function

for your edification

b

have a look

just wanted to contribute my two cents to the Maple community

good day

Hi everyone,

I am trying to solve a system of coupled ODEs numerically. My worksheet runs and produces results, but when I look at the graphs, it seems that the boundary conditions are not being satisfied correctly. Could anyone help me identify the issue and  fix my implementation?

BCs_help.mw

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