Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Embedded typesetting code in names is still giving me troubles. This is because the functionality and interplay of the characters ", &, #, ; and ` are not documented (appart from some MaplePrimes posts). Sometimes an escape  character (is that term correct?) is required sometimes it can be omitted or replaced by something else. I read somewhere that in former Maple versions strings were composed with back ticks `...` and this has moved to double quotes but both ways work for typesetting (if one knows how to).

Overall, there is allot of guesswork and trial-and-error involved in typesetting.

In the below I discovered a pecularity that prevented me to add certain symbols to the favorite palette.

On the positive side I found anwsers for an older question. On negative side an atomic identity has to be converted to atomic to add it to the favourites. This confuses me.

Maybe someone knows why this has to be done? Does a dragg operation strips of certain characters? Or is it in the case below that the use of the ampersand plays a role which is normally reserved to define neutral operators. Or is it fully unrelated because HTML codes and HTML entities for special symbols start with an ampersand (however an &D entitiy does not seem to exist).

Besides an explanation for the double atomization any insights and guidance with repect to typesetting of names is highly appreciated. Creating an italic captial D as a variable/name has been anwsered to my full satisfaction here. This question is more about a better understanding of typesetting.

Define a symbol with "name quotes" (left single quotes or back ticks)

NULL

`&D;`

`&D;`

(1)

whattype(`&D;`)

symbol

(2)

lprint(`&D;`)

`&D;`

 

type(`&D;`, atomic)

true

(3)

Select and drag the output (1) into the favourites leads to a blue symbol in the favorites .
Clicking on that symbol an executing

D

D

(4)

lprint(D)

D

 

whattype(D)

procedure

(5)

It seems that the drag operation has removed not only the back ticks but also the ampersand and the semicolon. (The purpose of the semi-collon  in this context seems to be the suppression of the ampersand printout (not sure about this)).


Doing the same in 2D (to later on make the symbol atomic using the context menu)

`&D;`

`&D;`

(6)

whattype(`&D;`)

symbol

(7)

lprint(`&D;`)

`&D;`

 

type(`&D;`, atomic)

true

(8)

Now the same input (copied as MathML from the input of (6)) and converted to atomic (by select -> right click -> 2D-Math-> Convert To -> Atomic)

`#mi("\`&D;\`")`

`#mi("\`&D;\`")`

(9)

whattype(`#mi("\`&D;\`")`)

symbol

(10)

lprint(`#mi("\`&D;\`")`)

`#mi("\`&D;\`")`

 

type(`#mi("\`&D;\`")`, atomic)

true

(11)

Seleceting and dragging the output (9) to the favorites leads to a new symbol
Clicking on that symbol an executing

`#mi("&D;")`

`#mi("&D;")`

(12)

whattype(`#mi("&D;")`)

symbol

(13)

lprint(`#mi("&D;")`)

`#mi("&D;")`

 

type(`#mi("&D;")`, atomic)

true

(14)

Removing now  from the favorite palette and adding the output (12) again as before
and clicking on the newly added symbol

`#mi("&D;")`

`#mi("&D;")`

(15)

lprint(`#mi("&D;")`)

`#mi("&D;")`

 

 

In summary`#mi("&D;")` = `#mi("&D;")` and `#mi("\`&D;\`")` = `#mi("\`&D;\`")` (although they are of type atomic) must be converted to atomic to drag their output into the favourite palette.

On the other hand the output "`#mi("\`&D;\`")`" cannot be used as input and converted in the same way. It must be converted to 1D-MathError, invalid neutral operator"`#mi("\`&D;\`")`"

`#mi("\`&D;\`")`;

`#mi("\`&D;\`")`

(16)

before the output can be dragged to the favorite palette.


Download dragging_atomic.mw

Please advise. I have a logarithmic equation.

   E(ν)=E0·ln(1+2·A·ν)+Em+C·ν^2

With constant E0>0, Em<0, C<0 and A>0, and E(ν) of variable ν between [10^4 and 10^13]

I have 3 points, ν1, ν2, and ν3, and the value of the function E(ν) at each point. I want to choose A to obtain the smallest absolute value of Em, preferably ~ -0.00005. The value of ν1, ν2, ν3 and E(ν1), E(ν2), E(ν3) are known.

With what “A” should I start to obtain  Em~ -0.00005?

restart;

 

Digits:=25;

25

(1)

 

E(nu):=Em+E0*ln(1+A*3.7653333333333333333*10^(-18)*nu)+ C*nu^2;

Em+E0*ln(1+0.3765333333333333333300000e-17*A*nu)+C*nu^2

(2)

E1:=subs(nu=5.754173859*10^8,E(nu));

Em+E0*ln(1+0.2166638263708799999980819e-8*A)+331105167995989518.8100000*C

(3)

E2:=subs(nu=6.338671958*10^8,E(nu));

Em+E0*ln(1+0.2386721281252266666645538e-8*A)+401787621911355537.6400000*C

(4)

E3:=subs(nu=31*10^9,E(nu));

Em+E0*ln(1+0.1167253333333333333323000e-6*A)+961000000000000000000*C

(5)

solve({E1=3.259,E2=3.59});

{A = A, C = 0.1414778271842943053715718e-16*E0*ln(1.+0.2166638263708799999980819e-8*A)-0.1414778271842943053715718e-16*E0*ln(1.+0.2386721281252266666645538e-8*A)+0.4682916079800141507799027e-17, E0 = E0, Em = 4.684403973756333877677291*E0*ln(1.+0.2386721281252266666645538e-8*A)-5.684403973756333877677291*E0*ln(1.+0.2166638263708799999980819e-8*A)+1.708462284686653486488817}

(6)

sol:=solve({E1=3.259,E2=3.59,E3=0},{Em,E0,C,A});

{A = A, C = .1000000000000000000000000*(3259.*ln(1.+0.2386721281252266666645538e-8*A)+331.*ln(1.+0.1167253333333333333323000e-6*A)-3590.*ln(1.+0.2166638263708799999980819e-8*A))/(7068245391536601883.*ln(1.+0.1167253333333333333323000e-6*A)-96066889483200401048119.*ln(1.+0.2386721281252266666645538e-8*A)+96059821237808864446236.*ln(1.+0.2166638263708799999980819e-8*A)), E0 = -31821175830670350532464.09/(7068245391536601883.*ln(1.+0.1167253333333333333323000e-6*A)-96066889483200401048119.*ln(1.+0.2386721281252266666645538e-8*A)+96059821237808864446236.*ln(1.+0.2166638263708799999980819e-8*A)), Em = 0.2000000000000000000000000e-2*(6037915335175266232043.*ln(1.+0.1167253333333333333323000e-6*A)-0.1565949500000000000000000e27*ln(1.+0.2386721281252266666645538e-8*A)+0.1724995000000000000000000e27*ln(1.+0.2166638263708799999980819e-8*A))/(7068245391536601883.*ln(1.+0.1167253333333333333323000e-6*A)-96066889483200401048119.*ln(1.+0.2386721281252266666645538e-8*A)+96059821237808864446236.*ln(1.+0.2166638263708799999980819e-8*A))}

(7)

A:=4.19747*10^6;evalf(sol[4]);#Em

4197470.00000

 

Em = -0.7291335370248713771647314e-1

(8)

Em:=-0.07291335370248713771647314;

-0.7291335370248713771647314e-1

(9)

evalf(sol[3]);#E0

E0 = 373.7014139352964920547905

(10)

E0:=373.7014139352964920547905;

373.7014139352964920547905

(11)

evalf(sol[2]);#C

C = -0.1549823289304468027271168e-18

(12)

C:=-1.549823289304468027271168*10^(-19);

-0.1549823289304468027271168e-18

(13)

E(nu):=Em+E0*ln(1+A*3.7653333333333333333*10^(-18)*nu)+ C*nu^2;

-0.7291335370248713771647314e-1+373.7014139352964920547905*ln(1+0.1580487370666666666652675e-10*nu)-0.1549823289304468027271168e-18*nu^2

(14)

plot(E(nu),nu=10^6..3.1*10^10);

 

evalf(subs(nu=5.754173859*10^8,E(nu)));evalf(subs(nu=6.338671958*10^8,E(nu)));evalf(subs(nu=6.974105195*10^8,E(nu)));

3.258999999999999999999993

 

3.589999999999999999999993

 

3.948288407313424284054632

(15)

evalf(subs(nu=0,E(nu)));evalf(subs(nu=11.4*10^6,E(nu)));evalf(subs(nu=15.9*10^9,E(nu)));#44.5eV @ 15.9Ghz

-0.7291335370248713771647314e-1

 

-0.560769863114429190697634e-2

 

44.52276318342970513246218

(16)
 

 

Download ML.mw

I am starting a new project and I anticipate creating dozens of files along the way. Each file will need the same collection of definitions, procedures, etc. and I would prefer not to have to copy and pace them as a preamble each time I open anew file. I guess I could write some startup code but would that mean every time I open an unrelated Maple file the Startup code would be laoded? I will be using Maple for other things besides this project. Also, while the stratup code would be hidden most of the time I would perhaps like to be able to see what the n1 procedure is; n1(x) would invoke the procedure-I just want to see waht it does. I usually endup up labeling my files in some lazy way so if I want to go back and find something it takes for ever. Any suggestions for improving that?

Thanks,

There seems to be a bug in the round function when using units.

a := 6.25*Unit('mm')``

6.25*Units:-Unit(mm)

(1)

round(a)

6*Units:-Unit(mm)

(2)

b := 1.25

1.25

(3)

round(b)

1

(4)

c := 1.25*Unit('mm')

1.25*Units:-Unit(mm)

(5)

round(c)

Units:-Unit(mm)

(6)

NULL

Download round.mw

I am finding many problems using overload in OOP.

But for starter, here is a basic one that does not use Object. Will make separate question for other issues once I figure this basic one out.

I have overload with two procs.

First proc takes 2 arguments of type string, and the second proc one argument also of type string.

When calling the overloaded proc with one argument or two arguments, it always calls the first one which takes 2 arguments.

It never calls the second, even though the call is using one argument only. It always matchs the first proc.

It seems Maple just checks if the first argument match and stops.

I also made sure to use $ for end of arguments flag.

Now when changing the order and putting as the first proc the one that take one argument and the second proc which takes two arguments, now it works. Maple calls the correct proc based on the number of arguments.

How could this be possible? Is order of procs in overload important?? How does one then figure the correct order. It should be based on match of signature of proc, not the order. i.e. match made based on number and type of arguments. 

Is there a way to make the first one work as is without having to worry about order? Or Am I making mistake somewhere?

restart;

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

set_name :=overload(
        [     
            proc(first_name::string,last_name::string,$) option overload;
                print("in proc which takes two arguments");
            end,
       
            proc(the_name::string,$) option overload;
                 print("in proc which takes one argument");
            end          
        ]
    ):

set_name("me"); #why this call the first proc and not the second?

"in proc which takes two arguments"

set_name("me","joe");

"in proc which takes two arguments"

restart;

#change order of procs in list
set_name :=overload(
        [            
            proc(the_name::string,$) option overload;
                 print("in proc which takes one argument");
            end,      

            proc(first_name::string,last_name::string,$) option overload;
                print("in proc which takes two arguments");
            end       
        ]
    ):

set_name("me");

"in proc which takes one argument"

set_name("me","joe");

"in proc which takes two arguments"

 

 

Download why_order_makes_differenence_in_overload_nov_1_2025.mw

For instance, I would like to represent “3^(1/3)” and “4^(1/4)” respectively as elements of the field generated by “3^(1/3) + 2^(1/2) + 1^(1/1)”. 
I think the Algebraic package and the evala procedure should already offer a direct command, but I couldn't find it. The following results are computed by SymPy's `to_number_field` function: 

-48/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^5 + 
 213/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^4 - 
 52/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^3 - 
 174/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^2 - 
 232/755*(3^(1/3) + 2^(1/2) + 1^(1/1)) + 
 277/151: # originally computed by SymPy's `to_number_field`
is(3^(1/3) = %);
                              true

48/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^5 - 
 213/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^4 + 
 52/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^3 + 
 174/755*(3^(1/3) + 2^(1/2) + 1^(1/1))^2 + 
 987/755*(3^(1/3) + 2^(1/2) + 1^(1/1)) - 
 428/151: # originally computed by SymPy's `to_number_field`
is(4^(1/4) = %);
                              true

Does there exist a direct command in Maple to find the above representations? 

I have this code. In the latex file, I get The vertical asymptote of the graph is $x = -{\dfrac{1}{4}}$. How can I get $x = -\dfrac{1}{4}$.

restart;
with(StringTools);
do_my_list := proc() 
    local toX, my_format; 
    toX := e -> latex(e, 'output' = 'string'); 
    my_format := proc(e)::string; 
        local s::string; 
        s := toX(e); 
        s := SubstituteAll(s, "*", " "); 
        s := StringTools:-SubstituteAll(s, "\\frac", "\\dfrac"); 
        s := StringTools:-SubstituteAll(s, "\\sqrt", "\\sqrt{\\,}"); 
        return s; 
    end proc; 
    return my_format; 
end proc;

L := [(x^2 + 3*x - 7)/(3*x - 2), (x^2 - 4*x + 1)/(4*x + 1)];
fmt := do_my_list();

RR := cat(
"\n\\documentclass[12pt,a4paper]{article}",
"\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}",
"\n\\usepackage[utf8]{vietnam}",
"\n\\usepackage{amsmath}",
"\n\\usepackage{amsthm}",
"\n\\usepackage{enumitem}",
"\n\\theoremstyle{definition}",
"\n\\newtheorem{ex}{Example}",
"\n\\begin{document}\n\n"
);

for i to nops(L) do
    f := L[i];
    TV := solve(denom(f) = 0, x);
    q := simplify(quo(numer(f), denom(f), x));
    TX := q;
    f_ltx := fmt(f);
    TX_ltx := fmt(TX);
    TV_ltx := fmt(TV);
    RR := cat(
        RR,
        sprintf("\\begin{ex} Let be given a function $\\displaystyle y = %s$. We have:\n", f_ltx),
        "\\begin{enumerate}[label=\\arabic*)]\n",
        sprintf("\\item The vertical asymptote of the graph is $x = %s$.\n", TV_ltx),
        sprintf("\\item The oblique (or slant) asymptote of the graph is $y = %s$.\n", TX_ltx),
        "\\end{enumerate}\n\\end{ex}\n\n"
    );
end do;

RR := cat(RR, "\\end{document}");

fout := fopen("baitap_tiemcan.tex", WRITE);
fprintf(fout, "%s", RR);
fclose(fout);
print("Đã tạo file: baitap_tiemcan.tex");
 

Maple's isolve can solve some but not all of the quadratic equations in two variables describing the conic sections. Here I show that by transforming the equations, Maple can then solve these missing cases.

restart

with(plots)

I was recently surprised that isolve cannot solve the following simple Diophantine equation

isolve(2*x^2+4*x*y+y^2 = 7)

which has the obvious (to a human) solution {x = 1, y = 1}. This led me to think about the case of conic sections, which have the following general equation (= 0 implied), where I assume a, () .. (), f are integers.

P := a*x^2+b*x*y+c*y^2+d*x+e*y+f

a*x^2+b*x*y+c*y^2+d*x+e*y+f

The above equation has discriminant -4*a*c+b^2 positive, indicating that is is a hyperbola.

h_params := {a = 2, b = 4, c = 1, d = 0, e = 0, f = -7}; P__h := eval(P, h_params); disc := -4*a*c+b^2; eval(disc, h_params); plot__h := implicitplot(P__h, x = -10 .. 10, y = -10 .. 10, colour = red)

{a = 2, b = 4, c = 1, d = 0, e = 0, f = -7}

2*x^2+4*x*y+y^2-7

-4*a*c+b^2

8

Here's a parabola case (discriminant = 0) that isolve also has trouble with

p_params := {a = 2, b = 4, c = 2, d = 1, e = 2, f = 7}; eval(disc, p_params); P__p := eval(P, p_params); {isolve(P__p)}; plot__h := implicitplot(P__p, x = -10 .. 10, y = -10 .. 10, colour = red)

{a = 2, b = 4, c = 2, d = 1, e = 2, f = 7}

0

2*x^2+4*x*y+2*y^2+x+2*y+7

{}

But this has at least one solution

eval(P__p, {x = 7, y = -7})

0

Maple seems to do better in the elliptic case (discriminant negative) and finds two solutions. Examination of the plot suggests there are no other solutions.

e_params := {a = 2, b = 4, c = 3, d = 1, e = 2, f = -7}; eval(disc, e_params); P__e := eval(P, e_params); {isolve(P__e)}; plot__e := implicitplot(P__e, x = -10 .. 10, y = -10 .. 10, colour = red)

{a = 2, b = 4, c = 3, d = 1, e = 2, f = -7}

-8

2*x^2+4*x*y+3*y^2+x+2*y-7

{{x = -3, y = 2}, {x = 2, y = -3}}

I show that transformation of the general equation to the form -D*Y^2+X^2 = m, where D is the discriminant, allows Maple to solve the hyperbolic case, as well as the elliptic case it already knows how to solve; another transformation works for the parabolic case. Maple appears to be able to solve all (solvable) cases of the transformed equations, though this is not clear from the help page. The transformation is discussed in Bogdan Grechuk, Polynomial Diophantine Equations: A Systematic Approach, Springer, 2024, Sec. 3.1.7. doi: 10.1007/978-3-031-62949-5

 

A complete classification of the conics, including degenerate cases, is given in https://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections. If the determinant, delta, of the following matrix is zero, we have a degenerate case.

A__Q := Matrix(3, 3, [a, (1/2)*b, (1/2)*d, (1/2)*b, c, (1/2)*e, (1/2)*d, (1/2)*e, f]); delta := LinearAlgebra:-Determinant(A__Q)

Matrix(%id = 36893489963432522084)

a*c*f-(1/4)*a*e^2-(1/4)*b^2*f+(1/4)*b*d*e-(1/4)*c*d^2

The case of a = b and b = c and c = 0 is just the linear case, which Maple can solve, and is one case where D = delta and delta = 0. Other degenerate parabola cases are two coincident lines or two parallel lines. Degenerate hyperbolas are two intersecting lines, and degenerate ellipses are a single point. Maple can solve all these cases, e.g.,NULL

expand((2*x+3*y+1)*(2*x+3*y)); {isolve(%)}; expand((2*x+3*y)*(2*x+3*y)); {isolve(%)}; expand((x-2)*(y-3)); {isolve(%)}; x^2+y^2 = 0; {isolve(%)}

4*x^2+12*x*y+9*y^2+2*x+3*y

{{x = -3*_Z1, y = 2*_Z1}, {x = -2-3*_Z1, y = 1+2*_Z1}}

4*x^2+12*x*y+9*y^2

{{x = -3*_Z1, y = 2*_Z1}}

x*y-3*x-2*y+6

{{x = _Z1, y = 3}}

x^2+y^2 = 0

{{x = 0, y = 0}}

(The intersecting lines case above only finds one of the lines.) The transformation will consider only the case where at least one of a or c is non-zero. This misses hyperbolas with a = c and c = 0; Maple seems to handle these bilinear equations, e.g.,

bl_params := {a = 0, b = 2, c = 0, d = 1, e = 1, f = 2}; P__bl := eval(P, bl_params); {isolve(P__bl)}

{a = 0, b = 2, c = 0, d = 1, e = 1, f = 2}

2*x*y+x+y+2

{{x = -2, y = 0}, {x = -1, y = 1}, {x = 0, y = -2}, {x = 1, y = -1}}

Transformation for non-zero discriminant
At least one of a or c must be non-zero; if necessary exchange x and y to ensure a is non-zero.

We multiply P by -4*a*(-4*a*c+b^2) and change to new variables X and Y.

itr := {X = (-4*a*c+b^2)*y+b*d-2*a*e, Y = 2*a*x+b*y+d}; tr := solve(itr, {x, y})

{X = (-4*a*c+b^2)*y+b*d-2*a*e, Y = 2*a*x+b*y+d}

{x = (1/2)*(4*Y*a*c-Y*b^2+2*a*b*e-4*a*c*d+X*b)/((4*a*c-b^2)*a), y = -(2*a*e-b*d+X)/(4*a*c-b^2)}

The transformed equation has the form -D*Y^2+X^2-m = 0 or -D*Y^2+X^2 = m, where D is the discriminant.

Q := collect(normal(eval(-4*P*a*(-4*a*c+b^2), tr)), {X, Y}); m := -coeff(coeff(Q, X, 0), Y, 0)

X^2+(4*a*c-b^2)*Y^2+16*a^2*c*f-4*a^2*e^2-4*a*b^2*f+4*a*b*d*e-4*a*c*d^2

-16*a^2*c*f+4*a^2*e^2+4*a*b^2*f-4*a*b*d*e+4*a*c*d^2

For positive discriminant D, this is a general Pell's equation, -D*Y^2+X^2 = m, which Maple knows how to solve. (The definition of Pell's equation requires that D is not a square, but Maple can also solve the simpler case where D is a square.) For the hyperbola above, we have an infinite number of solutions, parameterized by an arbitrary integer _Z1.

Q__h := eval(Q, h_params); solXY__h := {isolve(Q__h)}

X^2-8*Y^2+448

{{X = -12*(1+2^(1/2))^(1+2*_Z1)-12*(1-2^(1/2))^(1+2*_Z1)-4*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), Y = -3*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))-2*(1+2^(1/2))^(1+2*_Z1)-2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1/2))^(1+2*_Z1))-2*(1+2^(1/2))^(1+2*_Z1)-2*(1-2^(1/2))^(1+2*_Z1)}, {X = 12*(1+2^(1/2))^(1+2*_Z1)+12*(1-2^(1/2))^(1+2*_Z1)+4*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), Y = -3*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))-2*(1+2^(1/2))^(1+2*_Z1)-2*(1-2^(1/2))^(1+2*_Z1)}, {X = 12*(1+2^(1/2))^(1+2*_Z1)+12*(1-2^(1/2))^(1+2*_Z1)+4*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), Y = 3*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))+2*(1+2^(1/2))^(1+2*_Z1)+2*(1-2^(1/2))^(1+2*_Z1)}}

Transforming back to the original coordinates

sol__h := {seq(eval(eval(tr, h_params), solXY), `in`(solXY, solXY__h))}

{{x = -2*(1+2^(1/2))^(1+2*_Z1)-2*(1-2^(1/2))^(1+2*_Z1)-(5/4)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), y = (3/2)*(1+2^(1/2))^(1+2*_Z1)+(3/2)*(1-2^(1/2))^(1+2*_Z1)+(1/2)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))}, {x = -2*(1+2^(1/2))^(1+2*_Z1)-2*(1-2^(1/2))^(1+2*_Z1)+(5/4)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), y = (3/2)*(1+2^(1/2))^(1+2*_Z1)+(3/2)*(1-2^(1/2))^(1+2*_Z1)-(1/2)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))}, {x = -(1+2^(1/2))^(1+2*_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/2))^(1+2*_Z1)+(1/2)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))}, {x = 2*(1+2^(1/2))^(1+2*_Z1)+2*(1-2^(1/2))^(1+2*_Z1)+(5/4)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1)), y = -(3/2)*(1+2^(1/2))^(1+2*_Z1)-(3/2)*(1-2^(1/2))^(1+2*_Z1)-(1/2)*2^(1/2)*((1+2^(1/2))^(1+2*_Z1)-(1-2^(1/2))^(1+2*_Z1))}}

Evaluate for some _Z1 values, say _Z1=0 and _Z1=5.
It is evident from tr above that integer solutions in X, Y may transform to non-integer solutions in x, y but that doesn't occur for these two cases

sol__h0 := evala(eval(sol__h, _Z1 = 0)); sol__h5 := evala(eval(sol__h, _Z1 = 5))

{{x = -9, y = 5}, {x = -3, y = 1}, {x = -1, y = -1}, {x = -1, y = 5}, {x = 1, y = -5}, {x = 1, y = 1}, {x = 3, y = -1}, {x = 9, y = -5}}

{{x = -61181, y = 35839}, {x = -21979, y = 12875}, {x = -10497, y = 35839}, {x = -3771, y = 12875}, {x = 3771, y = -12875}, {x = 10497, y = -35839}, {x = 21979, y = -12875}, {x = 61181, y = -35839}}

Check they are solutions to P__h

map2(eval, P__h, `union`(sol__h0, sol__h5))

{0}

For negative discriminant and negative m, the equation -D*Y^2+X^2 = m has no solutions. In the classification scheme for the conics, the "imaginary ellipse" case (no real solutions) occurs when (a+c)*delta > 0. For negative discriminant, we must have a and c the same sign, and this is the case of negative m.

factor(expand((16*(a+c))*delta)); factor(-m)

4*(a+c)*(4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)

4*a*(4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)

. In this case Maple returns NULL for both the untransformed and transformed case, which can mean no solutions or just that isolve couldn't find any.

ie_params := {a = 3, b = 0, c = 5, d = 0, e = 0, f = 8}; P__ie := eval(P, ie_params); {isolve(P__ie)}; Q__ie := eval(Q, ie_params); {isolve(Q__ie)}

{a = 3, b = 0, c = 5, d = 0, e = 0, f = 8}

3*x^2+5*y^2+8

{}

X^2+60*Y^2+5760

{}

For negative discriminant and positive m or (a+c)*delta < 0, the ellipse is real, and there are a finite number of solutions. Maple solves the untransformed and transformed equations.
Here we need to filter out non-integer solutions

P__e; {isolve(P__e)}; Q__e := eval(Q, e_params); solXY__e := {isolve(Q__e)}; {seq(eval(eval(tr, e_params), solXY), `in`(solXY, solXY__e))}; sol__e := select(proc (q) options operator, arrow; eval(x::integer, q) and eval(y::integer, q) end proc, %)

2*x^2+4*x*y+3*y^2+x+2*y-7

{{x = -3, y = 2}, {x = 2, y = -3}}

X^2+8*Y^2-472

{{X = -20, Y = -3}, {X = -20, Y = 3}, {X = 20, Y = -3}, {X = 20, Y = 3}}

{{x = -3, y = 2}, {x = 2, y = -3}, {x = -3/2, y = 2}, {x = 7/2, y = -3}}

{{x = -3, y = 2}, {x = 2, y = -3}}

Transformation for zero discriminant
For the case of zero discriminant (parabola), we need a different transformation.

itr0 := {X = 2*a*x+b*y+d, Y = y}; tr0 := solve(itr0, {x, y})

{X = 2*a*x+b*y+d, Y = y}

{x = (1/2)*(-Y*b+X-d)/a, y = Y}

The transformed equation is of the form A*Y+X^2+B = 0

Q0 := collect(normal(eval(4*a*P, tr0)), {X, Y})

X^2+(4*a*c-b^2)*Y^2+(4*a*e-2*b*d)*Y+4*f*a-d^2

We consider the parabolic example above, for which Maple finds no solutions without transformation.

P__p; {isolve(P__p)}

2*x^2+4*x*y+2*y^2+x+2*y+7

{}

For the transformed problem, Maple finds an infinite number of solutions

Q__p := eval(Q0, p_params); solXY__p := {isolve(Q__p)}; sol__p := {seq(eval(eval(tr0, p_params), solXY), `in`(solXY, solXY__p))}

X^2+8*Y+55

{{X = 1+8*_Z1, Y = -8*_Z1^2-2*_Z1-7}, {X = 3+8*_Z1, Y = -8*_Z1^2-6*_Z1-8}, {X = 5+8*_Z1, Y = -8*_Z1^2-10*_Z1-10}, {X = 7+8*_Z1, Y = -8*_Z1^2-14*_Z1-13}}

{{x = 17/2+8*_Z1+8*_Z1^2, y = -8*_Z1^2-6*_Z1-8}, {x = 29/2+16*_Z1+8*_Z1^2, y = -8*_Z1^2-14*_Z1-13}, {x = 8*_Z1^2+4*_Z1+7, y = -8*_Z1^2-2*_Z1-7}, {x = 8*_Z1^2+12*_Z1+11, y = -8*_Z1^2-10*_Z1-10}}

Two of the general solutions will not give integer solutions, so could be filtered out, but it is easier to filter after choosing some specific _Z1 values.

eval(sol__p, _Z1 = 0); sol__p0 := select(proc (q) options operator, arrow; eval(x::integer, q) and eval(y::integer, q) end proc, %); eval(sol__p, _Z1 = 5); sol__p5 := select(proc (q) options operator, arrow; eval(x::integer, q) and eval(y::integer, q) end proc, %)

{{x = 7, y = -7}, {x = 11, y = -10}, {x = 17/2, y = -8}, {x = 29/2, y = -13}}

{{x = 7, y = -7}, {x = 11, y = -10}}

{{x = 227, y = -217}, {x = 271, y = -260}, {x = 497/2, y = -238}, {x = 589/2, y = -283}}

{{x = 227, y = -217}, {x = 271, y = -260}}

Check they are solutions to P__p

map2(eval, P__p, `union`(sol__p0, sol__p5))

{0}

NULL

Download DiophantineConics2.mw

There is still time to register for Maple Conference 2025, which takes place November 5-7, 2025.

The free registration includes access to three full days of presentations from Maplesoft product directors and developers, two distinguished keynote speakers, contributed talks by Maple users, and opportunities to network with fellow users, researchers, and Maplesoft staff.

The final day of the conference will feature three in-depth workshops presented by the R&D team. You'll get hands-on experience with creating professional documents in Maple, learn how to solve various differential equations more effectively using Maple's numerical solvers, and explore the power of the Maple programming language while solving interesting puzzles.

Access to the workshops is included with the free conference registration.

We hope to see you there!

Kaska Kowalska
Contributed Program Co-chair

How can I use an if statement inside a do - loop in maple and then plot a figure based on the conditional results? I need help with the correct syntax for combining the do-loop, `if` condition, and plotting command.

Sheet attached below:
Algorithmm.mw

Hi,
I want to have a colorbar aside the curve, but I can't. (My Maple version is 2018).

restart:
with(plots):

# --- constants ---
qc := 0.4:
qh := 0.64:
alpha := 0.8:

# --- parameter ranges ---
deltac_min := 0.01: deltac_max := 0.99:
Tch_min := 0.1:     Tch_max := 1.1:

# --- numerical safety ---
epsDen := 1e-12:
Mcap := 3.0: # cap to avoid infinity

# --- denominator ---
Den := (deltac, Tch) ->
       -2*Tch*deltac*qh - 2*Tch*deltac + 2*Tch*qh
       + 2*deltac*qc + 2*Tch + 2*deltac:

# --- safe functions ---
M1safe := (deltac, Tch) ->
    piecewise(Den(deltac,Tch) > epsDen,
              min(2/sqrt(Den(deltac,Tch)), Mcap),
              Mcap):

M0safe := (deltac, Tch) ->
    piecewise(Den(deltac,Tch) > epsDen,
              min(2*alpha/sqrt(Den(deltac,Tch)), Mcap),
              Mcap):

# --- density plots ---
p1 := densityplot(
       M1safe(deltac,Tch),
       deltac = deltac_min .. deltac_max,
       Tch   = Tch_min .. Tch_max,
       grid  = [200,200],
       style = patchnogrid,
       colorstyle = HUE,
       axes = boxed,
       labels = ["δ_c", "T_ch"],
       title = sprintf("M1(δ_c, T_ch)  (capped at %.2f)", Mcap)
     ):

p2 := densityplot(
       M0safe(deltac,Tch),
       deltac = deltac_min .. deltac_max,
       Tch   = Tch_min .. Tch_max,
       grid  = [200,200],
       style = patchnogrid,
       colorstyle = HUE,
       axes = boxed,
       labels = ["δ_c", "T_ch"],
       title = sprintf("M0(δ_c, T_ch)  (capped at %.2f)", Mcap)
     ):

# --- Contour Den = 0 (to mark physical boundary) ---
cont := contourplot(
          Den(deltac,Tch),
          deltac = deltac_min .. deltac_max,
          Tch   = Tch_min .. Tch_max,
          contours = [0],
          color = black,
          thickness = 2
        ):

# --- Overlay contour ---
p1_final := display(p1, cont):
p2_final := display(p2, cont):

# --- Display side by side ---
display(array([p1_final, p2_final]), scaling = constrained);

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

restart;
with(plots):

# === Constants ===
qc := 0.4:
qh := 0.64:
alpha := 0.8:

# === Denominator ===
Den := (deltac, Tch) ->
     -2*Tch*deltac*qh - 2*Tch*deltac + 2*Tch*qh
     + 2*deltac*qc + 2*Tch + 2*deltac:

# === M1 and M0 ===
M1 := (deltac, Tch) -> piecewise(Den(deltac,Tch)>0, 2/sqrt(Den(deltac,Tch)), undefined):
M0 := (deltac, Tch) -> piecewise(Den(deltac,Tch)>0, 2*alpha/sqrt(Den(deltac,Tch)), undefined):

# === Domain ===
deltac_min := 0.05:  deltac_max := 0.95:
Tch_min := 0.01:     Tch_max := 1.10:   # Physically realistic range

# === 3D Plots ===
p1 := plot3d(M1(deltac,Tch),
             deltac=deltac_min..deltac_max,
             Tch=Tch_min..Tch_max,
             grid=[80,80],
             axes=boxed,
             orientation=[-130,45],
             scaling=constrained,
             style=surfacecontour,
             color=green,
             labels=["δ_c", "T_ch", "M1"],
             labelfont=[TIMES,12],
             title="M1(δ_c, T_ch) for qc=0.4, qh=0.64"):

p2 := plot3d(M0(deltac,Tch),
             deltac=deltac_min..deltac_max,
             Tch=Tch_min..Tch_max,
             grid=[80,80],
             axes=boxed,
             orientation=[-130,45],
             scaling=constrained,
             style=surfacecontour,
             color=blue,
             labels=["δ_c", "T_ch", "M0"],
             labelfont=[TIMES,12],
             title="M0(δ_c, T_ch) for α=0.8, qc=0.4, qh=0.64"):

# === Display vertically (M1 above M0) ===
display(Array(1..2, [p1, p2]), insequence=true, scaling=constrained);
display(Array([[p1], [p2]]));

I am using S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);

restart;
n := 0:
L := []:

for a from 3 to 100 do
    for b from 3 to a do
        c2 := a^2 - a*b + b^2;
        c := isqrt(c2);
        if c^2 = c2 then
            if c < a + b and a < b + c and b < c + a then
                if igcd(a, b, c) = 1 then
                    x2 := (-a^2 + b^2 + c^2)/2;
                    y2 := (a^2 - b^2 + c^2)/2;
                    z2 := (a^2 + b^2 - c^2)/2;
                    if 0 < x2 and 0 < y2 and 0 < z2 then
                        S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);
                        x := S[1]; 
                        y := S[2]; 
                        z := S[3];
                        n := n + 1;
                        L := [op(L), [x, y, z, sqrt(x^2 + y^2), sqrt(y^2 + z^2), sqrt(x^2 + z^2)]];
                    end if;
                end if;
            end if;
        end if;
    end do;
end do;

n;
L;
 

But I get the result. How can I get the correct result of sort? 

After Maple 2025 start-up (with disabled start-up page) and closing the blank worksheet (note the dark grey workspace) there is still one mserver running (highlighted in yellow).

I have not seen a difference when I kill this process and open a new worksheet which starts a new mserver.exe task (and run Maple code).

The task seems to be inactive (no processor load and memory allocation visible).

Is it a task only used by the interface task (javaw.exe)?
What might be the purpose of this mserver.exe? 

 

Update: The task is inactive in a sense that it does not show immetiate activity when annother mserver.exe task runs (i.e. exceuting a worksheet). However, after a day memory allocation shows changes. When exactly these changes happend is unclear.

Has anyone had any success in turning off the scrollable matrix feature on Mac? I found the post

 https://www.mapleprimes.com/questions/238061-How-To-Disable-The-New-Scrollable-Matrices

and tried to follow the steps outlined by Acer, but I cannot get it to work. Specifically, I greated a preference file at the location:

 //Users/$USER/Library/Preferences/Maple/<version>/Maple preferences which has the statement 

ScrollableMathTableOutput=false

Any success stories, or tips, will be greatly appreciated. 

Thanks. 

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