Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am trying to select from a default list and a modified list to get a third combined list of the unmodified default elements and the mdfified elements plus extra elements. This is for plot data. I have managed to extract the colour data using something I did a couple of years ago. Though at this stage I don't relly know how that works either but it works.

restart

with(ListTools)

[BinaryPlace, BinarySearch, Categorize, Classify, Collect, Deal, DotProduct, Enumerate, FindMaximalElement, FindMinimalElement, FindRepetitions, Flatten, FlattenOnce, Group, Interleave, InversePermutation, Join, JoinSequence, LengthSplit, MakeUnique, Occurrences, Pad, PartialSums, Reverse, Rotate, Search, SearchAll, SelectFirst, SelectLast, Slice, Sorted, Split, Transpose, Unpermute]

(1)

PlotDefaults:=['colour' = ':-blue', symbol = ':-solidcircle', ':-symbolsize' = 8,thickness=2]; #for points and lines

[colour = blue, symbol = solidcircle, symbolsize = 8, thickness = 2]

(2)

Inputs:=['color'=[red, black, blue],symbol=square,':-linestyle'=dash]; #'color'=[red, black, blue],

 

[color = [red, black, blue], symbol = square, linestyle = dash]

(3)

if has(Inputs,{colour,color}) then
Colourlist:=remove(has,remove(has,Flatten(eval([':-color',':-colour'],Inputs)),':-colour'),':-color')
else
Colourlist:=remove(has,remove(has,Flatten(eval([':-color',':-colour'],PlotDefaults)),':-colour'),':-color');
end if

[red, black, blue]

(4)


Make this list

plotdata:=[symbol=square,':-linestyle'=dash,':-symbolsize' = 8,thickness=2]

[symbol = square, linestyle = dash, symbolsize = 8, thickness = 2]

(5)

mx:=max(nops(PlotDefaults),nops(Inputs))

4

(6)

Plotdata:=[];
for i to mx do

end do

 

 

[]

(7)
 

 

Download 2026-05-18_Q_Select_from_Two_Lists_to_get_New_List.mw

Currently I have Maple versions 2023,2025, and 2026 installed on Windows 11. Today I installed a workbook package containing a module that I just completed using the PackageTools installer in Maple 2026.. To my surprise, I found that a package installed from Maple 2026 was also available in Maple 2023 and, conversely, a package installed in Maple 2023 was automatically available in Maple 2026. i noticed that, with the exception of the Maple Customer Support Updates, the toolbox directory is no longer broken down by versions. I also noticed that the directory containing the module installed by Maple 2026 was named by the workbook instead of the module name (ie. hopfwords.maple). As I recall, the toolboxes used to be version dependent. 

The question is to what extent can one assume that a package created in Maple 2026 will be compatible with at least the more recent versions of Maple, I am also wondering why the directory name is now the workbook name instead of the module name. 

The new ribbon style user interface of recent Maple versions is well structured and visually much more appealing than the former user interface. Great for new users. However, I do not use the new Maple version for productive work because it is considerably slower to use: Much more clicks and mouse movements are involved than before, which breaks the flow.

To improve this situation, I thought about customizing the quick access toolbar with menu items that I need all the time. With Maple 2026 this suggestion has become a less viable solution because the quick access toolbar shrunk in size and moved to a screen location with low mouse activity (to get there fast, the mouse has to move back and forth like Speedy Gonzales). The tiny buttons in the toolbar are hard to distinguish and to hit in one go (a golfer might say “it's rare like an eagle”). If you disagree, try to write text and switch to non-executable math (to enter a symbol) and switch back to text and continue writing. Do the same with the former user interface (e.g. Maple 2024) and compare.

As a new suggestion I thought about adding a new tab "My Tab" to the ribbon that is customizable by the user. Here is what I would pick from the current ribbon items

(A subset from 4 out of 10 tabs: The Home, Insert, Edit and Help tab. The latter is less important)

I would probably also add these two items

although they do not fully replace the former buttons from the contextual tool bar

.

I use the above buttons from the former user interface allot in text passages to toggle between text and non-executable math. They are also useful to change the input mode of an empty document block (instead of inserting a new line with the desired input mode and deleting unwanted input lines). These buttons were introduced with Maple 2021 to improve usability, now they are gone and with it the ease of integrating math into text. With Maple 2026, I have to go back to using F5, which now “toggles” between three states (with the drawback that now in 1-D Math no indication of the state of the input mode is available on the user interface).

The above selection of menu items is my selection to work efficiently on textbook style Maple documents composed of explanatory text passages (including non-executable math) and Maple input and output. Other users would probably customize differently according to their needs.

A final remark about the undo function. Most software has undo on a top level. I do not understand why undo is not in the current quick access toolbar.

I strongly hope for productivity improvements that I can stop using Maple 2025.2 for Screen Readers (having the former user interface). Please do something to reduce mouse movements and clicks of frequently used interface functions. There is too much tab switching between the 3 most important tabs (Home, Insert, Edit) and too little functionality and ease of use of the quick access toolbar.

I would be interested to know which menu items other users would select.

restart;

with(plots): with(LinearAlgebra):

 

# TFSB Coefficients (symbolic in u)

beta0 := u -> (sin(u)*u^3 - 12*u^2 - 24*cos(u) + 24)/(12*(sin(u)*u + 2*cos(u) - 2)*u^2):

beta1 := u -> (5*sin(u)*u^3 + 12*cos(u)*u^2 + 24*cos(u) - 24)/(6*(sin(u)*u + 2*cos(u) - 2)*u^2):

beta2 := u -> beta0(u):

rho0 := u -> ((-u^2-12)*cos(u) - 5*u^2 + 12)/(12*(sin(u)*u + 2*cos(u) - 2)*u^2):

rho1 := u -> (-7*cos(u)*u^3 + 27*sin(u)*u^2 + 120*sin(u) - 120*u)/(60*u^2*(cos(u)*u + 2*u - 3*sin(u))):

rho2 := u -> -rho0(u):

 

# Secondary coefficients (simplified versions)

beta00 := u -> 13/42 - 9*u^2/7840:

beta10 := u -> 1/6 + u^2/720:

beta20 := u -> 1/42 - 17*u^2/70560:

beta01 := u -> 187/1680 + 611*u^2/705600:

beta11 := u -> 11/30 - 29*u^2/25200:

beta21 := u -> 37/1680 + 67*u^2/235200:

beta02 := u -> 11/70 + 491*u^2/352800:

beta12 := u -> 9/10 - 31*u^2/8400:

beta22 := u -> 31/70 + 811*u^2/352800:

 

rho01 := u -> 2/105 + 407*u^2/1058400:

rho11 := u -> -19/210 + 41*u^2/105840:

rho21 := u -> -1/168 - 101*u^2/529200:

rho02 := u -> 53/1680 + 1633*u^2/2116800:

rho12 := u -> 8/105 - 4*u^2/6615:

rho22 := u -> -101/1680 - 2273*u^2/2116800:

 

# Problem definition

omega := 1:

epsilon := 3*Pi/2:

phi := x -> 3*sin(x) - 5*cos(x):  # history function

 

f := (x, v, vp, vd) -> -v - vd + 3*cos(x) + 5*sin(x):

g := proc(x, v, vp, vd, vdp)

    local fx, fv, fvp, fvd;

    fx := -3*sin(x) + 5*cos(x);

    fv := -1;

    fvp := 0;

    fvd := -1;

    return fx + fv*vp + fvp*0 + fvd*vdp;

end proc:

 

# Initial conditions

a := 0: b := 10:

v0 := -5: vp0 := 3:

 

# Variable step-size parameters

tol := 1e-10:

h_min := 0.01:

h_max := 0.5:

h_init := Pi/8:

 

# Store results

X := [a]: V := [v0]: Vp := [vp0]:

h_curr := h_init:

x_curr := a:

v_curr := v0:

vp_curr := vp0:

 

# For history: need v at x-epsilon

get_v_delayed := proc(xx)

    if xx < a then return phi(xx);

    else

        # Interpolate from stored solution

        idx := 1;

        while idx < nops(X) and X[idx] < xx do idx := idx+1; end do;

        if idx = 1 then return phi(xx);

        elif X[idx] = xx then return V[idx];

        else

            # Linear interpolation

            return V[idx-1] + (V[idx]-V[idx-1])*(xx-X[idx-1])/(X[idx]-X[idx-1]);

        end if;

    end if;

end proc:

 

# Newton solver for block

solve_block := proc(x0, v0, vp0, h, omega)

    local u, bet0, bet1, bet2, rho0, rho1, rho2, bet00, bet10, bet20, bet01, bet11, bet21, bet02, bet12, bet22,

          rho01, rho11, rho21, rho02, rho12, rho22, F, J, V0, V1, V2, Vp0, Vp1, Vp2, tolN, iter, dv, dV;

   

    u := omega*h;

    bet0 := beta0(u); bet1 := beta1(u); bet2 := beta2(u);

    rho0 := rho0(u); rho1 := rho1(u); rho2 := rho2(u);

    bet00 := beta00(u); bet10 := beta10(u); bet20 := beta20(u);

    bet01 := beta01(u); bet11 := beta11(u); bet21 := beta21(u);

    bet02 := beta02(u); bet12 := beta12(u); bet22 := beta22(u);

    rho01 := rho01(u); rho11 := rho11(u); rho21 := rho21(u);

    rho02 := rho02(u); rho12 := rho12(u); rho22 := rho22(u);

   

    # Initial guesses

    V1 := v0 + h*vp0;

    V2 := v0 + 2*h*vp0;

    Vp1 := vp0;

    Vp2 := vp0;

   

    tolN := 1e-12;

    for iter from 1 to 10 do

        # Compute delayed values

        vd0 := get_v_delayed(x0 - epsilon);

        vd1 := get_v_delayed(x0 + h - epsilon);

        vd2 := get_v_delayed(x0 + 2*h - epsilon);

        vdp0 := (get_v_delayed(x0 - epsilon + 1e-8) - vd0)/1e-8;

        vdp1 := (get_v_delayed(x0 + h - epsilon + 1e-8) - vd1)/1e-8;

        vdp2 := (get_v_delayed(x0 + 2*h - epsilon + 1e-8) - vd2)/1e-8;

       

        # Compute gamma and g

        gam0 := f(x0, v0, vp0, vd0);

        gam1 := f(x0+h, V1, Vp1, vd1);

        gam2 := f(x0+2*h, V2, Vp2, vd2);

        g0 := g(x0, v0, vp0, vd0, vdp0);

        g1 := g(x0+h, V1, Vp1, vd1, vdp1);

        g2 := g(x0+2*h, V2, Vp2, vd2, vdp2);

       

        # Residuals

        F1 := h*vp0 - (V1 - v0 + h^2*(bet00*gam0 + bet10*gam1 + bet20*gam2)

              + h^3*(rho01*g0 + rho11*g1 + rho21*g2));

        F2 := h*Vp1 - (V1 - v0 + h^2*(bet01*gam0 + bet11*gam1 + bet21*gam2)

              + h^3*(rho01*g0 + rho11*g1 + rho21*g2));

        F3 := h*Vp2 - (V1 - v0 + h^2*(bet02*gam0 + bet12*gam1 + bet22*gam2)

              + h^3*(rho02*g0 + rho12*g1 + rho22*g2));

        F4 := V2 - (2*V1 - v0 + h^2*(bet0*gam0 + bet1*gam1 + bet2*gam2)

              + h^3*(rho0*g0 + rho1*g1 + rho2*g2));

       

        F := Vector([F1, F2, F3, F4]);

        if LinearAlgebra:-Norm(F) < tolN then break; end if;

       

        # Approximate Jacobian (finite differences)

        J := Matrix(4,4);

        delta := 1e-6;

        for j from 1 to 4 do

            V_pert := Vector([V1, V2, Vp1, Vp2]);

            V_pert[j] := V_pert[j] + delta;

            V1p := V_pert[1]; V2p := V_pert[2]; Vp1p := V_pert[3]; Vp2p := V_pert[4];

            gam1p := f(x0+h, V1p, Vp1p, get_v_delayed(x0+h-epsilon));

            gam2p := f(x0+2*h, V2p, Vp2p, get_v_delayed(x0+2*h-epsilon));

            g1p := g(x0+h, V1p, Vp1p, get_v_delayed(x0+h-epsilon),

                     (get_v_delayed(x0+h-epsilon+1e-8)-get_v_delayed(x0+h-epsilon))/1e-8);

            g2p := g(x0+2*h, V2p, Vp2p, get_v_delayed(x0+2*h-epsilon),

                     (get_v_delayed(x0+2*h-epsilon+1e-8)-get_v_delayed(x0+2*h-epsilon))/1e-8);

           

            F1p := h*vp0 - (V1p - v0 + h^2*(bet00*gam0 + bet10*gam1p + bet20*gam2p)

                   + h^3*(rho01*g0 + rho11*g1p + rho21*g2p));

            F2p := h*Vp1p - (V1p - v0 + h^2*(bet01*gam0 + bet11*gam1p + bet21*gam2p)

                   + h^3*(rho01*g0 + rho11*g1p + rho21*g2p));

            F3p := h*Vp2p - (V1p - v0 + h^2*(bet02*gam0 + bet12*gam1p + bet22*gam2p)

                   + h^3*(rho02*g0 + rho12*g1p + rho22*g2p));

            F4p := V2p - (2*V1p - v0 + h^2*(bet0*gam0 + bet1*gam1p + bet2*gam2p)

                   + h^3*(rho0*g0 + rho1*g1p + rho2*g2p));

           

            Fp := Vector([F1p, F2p, F3p, F4p]);

            J[1..4, j] := (Fp - F)/delta;

        end do;

       

        dV := LinearAlgebra:-LinearSolve(J, -F);

        V1 := V1 + dV[1]; V2 := V2 + dV[2]; Vp1 := Vp1 + dV[3]; Vp2 := Vp2 + dV[4];

    end do;

   

    return [V1, V2, Vp1, Vp2];

end proc:

 

# Main variable step-size loop

printf("Variable step-size integration for Example 1\n");

printf("tol = %e, h_init = %f\n", tol, h_init);

 

while x_curr < b - 1e-12 do

    # Try current step

    sol := solve_block(x_curr, v_curr, vp_curr, h_curr, omega);

    V1 := sol[1]; V2 := sol[2]; Vp1 := sol[3]; Vp2 := sol[4];

   

    # Compute with two half-steps

    sol_half1 := solve_block(x_curr, v_curr, vp_curr, h_curr/2, omega);

    V_mid := sol_half1[2]; Vp_mid := sol_half1[4];

    sol_half2 := solve_block(x_curr + h_curr/2, V_mid, Vp_mid, h_curr/2, omega);

    V2_half := sol_half2[2];

   

    # Error estimate

    err := abs(V2 - V2_half) / (2^6 - 1);

   

    if err < tol then

        # Accept step

        x_next := x_curr + 2*h_curr;

        X := [op(X), x_curr + h_curr, x_next];

        V := [op(V), V1, V2];

        Vp := [op(Vp), Vp1, Vp2];

        x_curr := x_next;

        v_curr := V2;

        vp_curr := Vp2;

        printf("x = %7.4f, h = %8.5f, err = %12.5e\n", x_curr, h_curr, err);

       

        # Adjust step size

        if err < tol/2 then

            h_curr := min(2*h_curr, h_max);

        end if;

    else

        # Reject step, reduce h

        h_curr := max(h_curr/2, h_min);

        printf("  Rejecting, new h = %8.5f\n", h_curr);

    end if;

end do:

 

# Exact solution for comparison

exact := x -> 3*sin(x) - 5*cos(x);

errors := [seq(abs(V[i] - exact(X[i])), i=1..nops(X))];

 

# Visualization

p1 := pointplot([seq([X[i], errors[i]], i=1..nops(X))], color=red, symbol=circle,

                title="Example 1: Variable Step-Size TFSB - Absolute Errors",

                labels=["x", "Error"], labeldirections=[horizontal,vertical]);

p2 := plot([[x_curr, h_curr]], x=a..b, style=point, color=blue,

            title="Step-size evolution", labels=["x", "h"]);

display(p1);

display(p2);

 

printf("\nFinal results for Example 1:\n");

printf("Number of steps: %d\n", nops(X)-1);

printf("Maximum error: %e\n", max(errors));

printf("Final step-size: %f\n", h_curr);

Since Maple version 2026, I have noticed that the orientation option with the contourplot3d command has no effect.

It is easy to control by using the example provided in the online help and adding, for example, orientation=[20,10,10].

Thank you for your help.

Best regards.

...the essence of plane geometry is hidden within the following puzzle:
Given is a closed curve C. It is assumed to be non-self-intersecting, convex, and continuously differentiable everywhere (a closed Jordan curve). Let line segment AB be a chord of this curve, having a fixed length l. A point P lies on this chord at a fixed distance a from A and b from B, such that l = a + b. An orientation (or direction of circulation) is now assigned to the curve. The chord is then moved continuously along the closed curve in this assigned direction of circulation. As it moves, point P traces out a so-called locus curve O, which—upon completion of one full revolution of the chord—also forms a closed curve lying entirely within C.
The task is to calculate the area of ​​the region between C and O (i.e., the area lying inside C but outside O). Divide the result by the product of a and b, and then apply the "identify" function to the outcome.

Hi again Maple community, and others,

want to share
tiwn_and_cousin_prime_numbers.mw
tiwn_and_cousin_prime_numbers.pdf
(spelling error in file name)

~

just want to share,
some successful code

The lesser of the twin primes are listed
{3,5,11,17,29,41,59,71}
https://oeis.org/A001359
Prime numbers p such that p+2 is also a prime number

also, the lesser of the cousin primes are listed
{3,7,13,19,37,43,67,79,97}
https://oeis.org/A023200
prime numbers p such that p+4 is also a prime number

good fun

also, my webpage has more details
https://mattanderson.fun
okay

regards,
Matt

On my system (Windows 11) I can only remove an entry from the favorites when a document is open. With all documents closed removing does not work.

Can someone confirm?

Would it be possible to include the file path in $File for the proposed header/footer insertions.

Thanks in advance

Peter

I was using pdsolve to solve for a 1-D longitudinal wave equation.  My particular problem added an external stimulus that is not mechanical in original, so the acoustic wave velocity has to be modeled as a variable c(H) and I also have to add a du/dx term in the model.  You can see my question posted on April 17, 2026.  I was told that pdsolve does not handle such a problem.  The suggestion in the posting is to use a finite difference method.  

I am verifying that approach by solving a simplier problem where c is constant but with an initial uniformly stretched material.  The solution does not seem to be physical.  The material should relax throughout the whole length of the material, but the solution shows relaxation at the end and stay uniformly stretched at the center.  I ran the problem with pdsolve and get a different result that I think is more realistic.

Is there something I can tweak in the finite difference approach to overcome that issue?

pde_finite_difference_method_linear_ic.mw

pdsolve_exercise_damping_ini_linear_a.mw

Is there a workaround to being able to call object method inside the debugger? I use Objects everywhere and hard to debug things when not able to try calls inside the debugger.

Here is an example.

This worksheet below has the code to reproduce this. Ofcourse the code works when I run it in the debugger using "continue" button, or using the "next" or "step". But I need sometimes to check something before doing this.

interface(version);

`Standard Worksheet Interface, Maple 2026.1, Windows 10, April 28 2026 Build ID 2011354`

restart;

kernelopts('assertlevel'=2):

module person_type()
    option object;
    local _name::string:="";    
    export ModuleCopy::static := proc( _self::person_type, proto::person_type, name::string)
      _name:=name;
      NULL;
    end proc;

    export get_name::static:=proc(_self)
       _self:-_name;
    end proc;
end module;

module person_type () local _name::string; option object; end module

foo:=proc(o::person_type)::string;
  local name;
  DEBUG();
  name:=o:-get_name();
  name;
end proc;

proc (o::person_type)::string; local name; DEBUG(); name := o:-get_name(); name end proc

o:=Object(person_type,"me");

module person_type () local _name::string; option object; end module

o:-get_name();

"me"

#run this. Debugger will now open
foo(o);

 

 

Download why_calling_object_fail_in_debugger.mw

Please see the attached worksheet:

Question 1:  How to plot a partial portion of an array s2 using "dataplot," say the first 50 elements.

Question 2:  I have also tried to use "plot" to plot the first 50 elements s2 and keep on getting errors or strange looking plot with horizontal lines.  I have tried plot(s2,1..50), plot(s2,x=1..50), plot(s2,m=1..50), plot(s2[m],m=1..50), plot(s2[1..50],1..50], plot(1..50,s2[1..50]).

plot_exercise_a.mw

How i can apply this transfromation which is special and i can't undrestand how from that solution he did thus changes  and get the solution of ode  ,  i reached untill eq(3.5) but after that i can't  figure out what he did   and how we get eq(3.7)-(3.9) (3.12),(3.13) and how we can   tranform solution  for the  eq(3.5)

fp.mw

To get better acquainted with "plot3d," I browsed through the help documentation. I was surprised to discover not only "Polyhedraplot," but—via "Polyhedra Sets" and "DualSet"—the very tools needed to tackle a classic subject: The duality of Platonic solids.
This reminded me of the following puzzle:
Consider the unit cube (edge ​​length = 1) and, situated within it, its dual polyhedron (the octahedron). As is well known, the dual polyhedron of the octahedron is, in turn, a cube. Now, let us continue this dual construction indefinitely, starting from the unit cube (cube containing octahedron containing cube containing octahedron...). This generates a sequence of nested polyhedra—alternating between cubes and octahedra.
1.) For each of the infinite subsequences—that of the cubes and that of the octahedra—calculate the sum of all volumes and surface areas.
2.) What is the maximum volume an octahedron (regardless of its orientation) can have while being completely contained within the unit cube?

I am very pleased to announce the publication of my new book written together with Nic Fillion, "Perturbation Methods Using Backward Error", which uses Maple heavily throughout.

You can find it at

the SIAM bookstore

and I hope that you find it useful and interesting.

You can also find a paper in Maple Transactions, written with Michelle Hatzel, that explains how we generated the image that was chosen for the cover.  Exploring Cover Designs for an Upcoming Book  In the end, the SIAM design people chose a different one than we had thought, but they did pick one of the ones we generated!  

This was fun to do.

 

a rainbow-hued image with many levels; two dark blue spots connected by a horizontal and a vertical blue line from each that intersect; alarming red spots in the upper and lower left corner
 

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