Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I need to plot this piecewise function

Maple plots it correctly but its sampling seems to use the points between and hence it also shows vertical asymptotes, like this

Is there a way to tell plot not to show the vertical asymtotes? These should not show. Here is the same exact function in Mathematica, and this is what I want in Maple

f[x_] := Piecewise[{
   {2*x - Tan[x], -7/4*Pi < x < -3/2*Pi},
   {2*x - Tan[x], -3/2*Pi < x < -5/4*Pi},
   {2*x - Tan[x], -3/4*Pi < x < -1/2*Pi},
   {2*x - Tan[x], -1/2*Pi < x < -1/4*Pi},
   {2*x - Tan[x], 1/4*Pi < x < 1/2*Pi},
   {2*x - Tan[x], 1/2*Pi < x < 3/4*Pi},
   {2*x - Tan[x], 5/4*Pi < x < 3/2*Pi},
   {2*x - Tan[x], 3/2*Pi < x < 7/4*Pi},
   {True, None}}]

Plot[f[x], {x, -2 Pi, 2 Pi}]

 

Here is Maple worksheet with all the maple code. I tried adding 'adaptive'=true,'discont'=true but these made no difference.

f_decreasing := x -> piecewise(-7/4*Pi < x and x < -3/2*Pi, 2*x - tan(x), -3/2*Pi < x and x < -5/4*Pi, 2*x - tan(x), -3/4*Pi < x and x < -1/2*Pi, 2*x - tan(x), -1/2*Pi < x and x < -1/4*Pi, 2*x - tan(x), 1/4*Pi < x and x < 1/2*Pi, 2*x - tan(x), 1/2*Pi < x and x < 3/4*Pi, 2*x - tan(x), 5/4*Pi < x and x < 3/2*Pi, 2*x - tan(x), 3/2*Pi < x and x < 7/4*Pi, 2*x - tan(x),true,[])

f_decreasing := proc (x) options operator, arrow; piecewise(-(7/4)*Pi < x and x < -(3/2)*Pi, 2*x-tan(x), -(3/2)*Pi < x and x < -(5/4)*Pi, 2*x-tan(x), -(3/4)*Pi < x and x < -(1/2)*Pi, 2*x-tan(x), -(1/2)*Pi < x and x < -(1/4)*Pi, 2*x-tan(x), (1/4)*Pi < x and x < (1/2)*Pi, 2*x-tan(x), (1/2)*Pi < x and x < (3/4)*Pi, 2*x-tan(x), (5/4)*Pi < x and x < (3/2)*Pi, 2*x-tan(x), (3/2)*Pi < x and x < (7/4)*Pi, 2*x-tan(x), true, []) end proc

plot(f_decreasing(x),x=-2*Pi..2*Pi,'adaptive'=true,'discont'=true,'color'="blue");

 

 

Download plot_piecewise_march_25_2026.mw

when getting sequence of RealRange, I'd like to convert this to normal list. Currently I have to use map twice on the result, but I think there should be simpler way.

Below is what I do. I was wondering if there is a better way in Maple to do this, may be a built in command?

Basically, if the input is

RealRange(-2*Pi,Open(-7/4*Pi)), RealRange(Open(-5/4*Pi),Open(-3/4*Pi)), 
RealRange(Open(-1/4*Pi),Open(1/4*Pi)), RealRange(Open(3/4*Pi),Open(5/4*Pi)), 
RealRange(Open(7/4*Pi),2*Pi)

I want to change the above to normal list like this (without any Open, etc.. in it) to make it easier to post process (say for plotting and so on)

[[-2*Pi, -7/4*Pi], [-5/4*Pi, -3/4*Pi], [-1/4*Pi, 1/4*Pi], [3/4*Pi, 5/4*Pi], [7/4*Pi, 2*Pi]]

This is what I do now on an example that generates sequence of RealRange

restart;

f:=x->2*x-tan(x);
the_intervals:=solve(diff(f(x),x)>0 and x>=-2*Pi and x<= 2*Pi,x);

proc (x) options operator, arrow; 2*x-tan(x) end proc

RealRange(-2*Pi, Open(-(7/4)*Pi)), RealRange(Open(-(5/4)*Pi), Open(-(3/4)*Pi)), RealRange(Open(-(1/4)*Pi), Open((1/4)*Pi)), RealRange(Open((3/4)*Pi), Open((5/4)*Pi)), RealRange(Open((7/4)*Pi), 2*Pi)

lprint(the_intervals);

RealRange(-2*Pi,Open(-7/4*Pi)), RealRange(Open(-5/4*Pi),Open(-3/4*Pi)),
RealRange(Open(-1/4*Pi),Open(1/4*Pi)), RealRange(Open(3/4*Pi),Open(5/4*Pi)),
RealRange(Open(7/4*Pi),2*Pi)

map(X->convert(X,list),[the_intervals]);
map(X1->map(X2->`if`(has(X2,Open),op(X2),X2),X1),%);

[[-2*Pi, Open(-(7/4)*Pi)], [Open(-(5/4)*Pi), Open(-(3/4)*Pi)], [Open(-(1/4)*Pi), Open((1/4)*Pi)], [Open((3/4)*Pi), Open((5/4)*Pi)], [Open((7/4)*Pi), 2*Pi]]

[[-2*Pi, -(7/4)*Pi], [-(5/4)*Pi, -(3/4)*Pi], [-(1/4)*Pi, (1/4)*Pi], [(3/4)*Pi, (5/4)*Pi], [(7/4)*Pi, 2*Pi]]

lprint(%);

[[-2*Pi, -7/4*Pi], [-5/4*Pi, -3/4*Pi], [-1/4*Pi, 1/4*Pi], [3/4*Pi, 5/4*Pi], [7/
4*Pi, 2*Pi]]

 

 

Download convert_realrange_to_list.mw

In the attached file test1, two terms are to be compared using the "is" function. Theoretically, these terms are equal. A plot is provided for illustration. However, regardless of which symbol ("equal," "not equal," etc.) is used in "is," the result is always "false." What am I doing wrong?

restart

simplify(exp(u)/(1+exp(u))^2)

exp(u)/(1+exp(u))^2

(1)

is(exp(u)/(1+exp(u))^2 = 1/(4*cosh((1/2)*u)^2))

false

(2)

plot([exp(u)/(1+exp(u))^2, 1/(4*cosh((1/2)*u)^2)], u)

 

NULL

Download test1.mw

Any idea why plot fail when adding legend and using {1} instead of [1] ? Since both have one curve.

Maple 2026 and 2025.2. searched help but do not see anything on this so far.

restart;

plot({1},x = -10 .. 10,'legend'="A");

Error, (in plot) the legend option cannot be used when plotting a set of objects

plot([1],x = -10 .. 10,'legend'="A");

 

 

Download plot_legend_problem_march_25_2026.mw

Can someone explain what the meaning of "visible character width" for e.g. TextArea components is?

My understanding is that the width should correspond to the number of characters that are visible in the TextArea. But apparently this is not the case.

A definition of 4 allows at least 8 characters. A definition of 6 at least 12, 8 gives 16 and 10 gives 20.

Test_visible_character_width.mw

Mathematics often feels precise and deterministic. We solve equations, follow logical steps, and do our best to arrive at exact answers. But sometimes, surprisingly, randomness can also lead us to deep mathematical truths. One of the most famous examples of this idea is a problem from the 18th century known as Buffon’s Needle.

Imagine you have a floor made of long wooden planks placed side by side. The seams between the planks form a set of equally spaced parallel lines across the floor. Now, suppose you take a needle and randomly drop it onto the floor. Sometimes the needle lands entirely on one plank. Other times, it crosses one of the seams between planks, as shown below.

Now here is the curious question posed by the French mathematician Georges-Louis Leclerc, Comte de Buffon in the 1700s:

If we repeatedly drop the needle at random, what is the probability that it crosses one of the lines on the floor?

At first glance, this sounds like a simple probability puzzle. But the answer turns out to involve one of the most famous numbers in mathematics: π.

To keep things simple, assume the distance between the parallel lines on the floor is the same as the length of the needle. We can also imagine that all of our needles are thrown onto the same plank, potentially crossing onto the plank above or below. This configuration is equivalent to throwing the needle onto any plank as long as the planks are equally wide; this modification makes the analysis much simpler.

Every time the needle lands, two things determine whether it crosses a line:

  • The distance x from the center of the needle to the nearest line
  • The angle θ at which the needle lands with respect to the parallel lines

See a depiction of this below.

To determine the probability of a needle crossing one of these lines, we need to describe what a "random drop" of the needle means mathematically. If the lines are the same length apart as the length of the needle L, then the center of the needle can never be farther than L/2 from the nearest line. Therefore, 0 ≤ x ≤ L/2. Next, we can simplify our domain for θ. The problem is symmetric, so we only need to consider angles between 0 and π/2. Any given half of the needle then has a vertical reach of (L/2)sin(θ).

We will say a needle "crosses" a line precisely when the center lands close enough to a line that one end of the needle can reach across the line. This occurs when x ≤ (L/2)sin(θ).

An important assumption to make is that every pair (x,θ) in the rectangle 0 ≤ x ≤L/2, 0 ≤ θ ≤ π/2 is equally likely. We’re assuming the needle lands with uniform randomness over all vertical positions x and angles θ. This means that the probability of crossing a line is the fraction of this region where the inequalities above hold. That is, 

Probability = (area of favourable region) / (area of total region)

The "rectangle" formed by inequalities has a total area of (L/2) * (π/2) = π*L/4. The needle crosses a line exactly when x ≤ (L/2)sin(θ), so for a fixed angle θ, the allowable x values are 0 ≤ x ≤ (L/2)sin(θ). The favourable area is then:

The probability of a needle crossing a line is therefore:

This result leads to a fascinating idea. If the probability of crossing a line is 2/π, we can rearrange the formula to estimate π itself:

π ≈ 2N / C

where:

  • N = the total number of needle drops
  • C = the number of times the needle crosses a line

In other words, by performing a simple random experiment and counting how often the needle crosses a line, we can approximate π.

For example, suppose you drop the needle 10,000 times and it crosses a line 6,366 times. Plugging these values into the formula gives

π ≈ (2 × 10,000) / 6,366 ≈ 3.14

With enough trials, the estimate tends to get closer and closer to the true value of π. At the bottom of this post, I attached a Maple worksheet that simulates this phenomenon. Below are results from simulating this result using N = 10, 100 & 1000, respectively. Notice as N increases, our approximation for π tends to become more and more accurate.

Below is a more dynamic simulation from the Maple worksheet to show how the approximation stabilizes as N increases.

What makes Buffon’s Needle so fascinating is the unexpected connection between geometry, probability, and one of mathematics’ most important constants.

π usually appears when dealing with circles (circumference, area, rotation, etc). But in Buffon’s experiment, there are no circles at all. Instead, π emerges from the geometry of all the possible ways a needle can land on a set of parallel lines.

This was one of the earliest examples of what we now call a Monte Carlo method, which is essentially using random experiments to estimate numerical values. Today, similar techniques are used in physics, finance, computer graphics, and machine learning.

One of the best parts of Buffon’s Needle is that you can try it yourself. All you need is:

  • A toothpick or needle
  • A piece of paper with a sequence of parallel lines, each a distance of the needle's length apart
  • A lot of patience

Drop the needle repeatedly (N times), record how many times it crosses a line (C), and compute 2N/C. The more times you repeat the experiment, the closer your estimate will get to π.

After reading about this experiment, I was convinced that mathematics is not only about abstract symbols and formulas. Sometimes, even something as simple as dropping a needle onto the floor can reveal the hidden structure of elements of the universe that we would've otherwise never known were there.

 

Buffons_Needle_Simulation.mw

I defined two tensors (vectors) U and D and their components in Maple 2025 using the Physics package. I enter U[~alpha]*U[alpha] and get a symbolic result. SumOverRepeatedIndices expands this but does not substitutes the expressions of the components I gave. How to force Maple to use the values of the components?

Thank you!

I have contacted Maplesoft support with the intend to send them corrupted Maple.ini files (that caused Maple 2026 installation to malfunction) for further analysis.

Before sending I asked whether they were interested. In the email response support replied that they were happy that my problem has been solved. I replied that they apparently did not understand my first mail. Then I got this back.

Hello,

Thank you for clarifying! I apologize for not being more clear in my response.

The issue with the preferences file (Maple.ini) was summarized in the MaplePrimes links that you provided which have been shared with our R&D team. They will be able to investigate the problem further.

Please let us know if you have any questions or concerns.

Best Regards,

XXX(Name removed, 
Case - 00191471 )
Technical Support Analyst

 

Apparently I have shared the files already. Not to my knowledge. Without my ini files no one can investigate the case.

For me this answer sounds like an automated AI generated reply. That is not what I expect as a long-time customer and EPM participant (paying full price). Premium products should come with premium support!

In this case I solved the installation problem myself with the help of this forum and wanted to support Maplesoft to make better products. Now I really feel like an idiot. Spending my free time with debugging, offering assistance, talking to a bot(?!?).

 

Dear upper management and owners:

If you have replaced support staff with bots that do not identify themselves as such, please reconsider what you are doing. Don't squeeze Maple for maximum profit and hide this. Think about your loyal customer base if you have a long-term growth strategy. The value of most companies lies in the people who work for them not in dumb, sloppy working bots. Humans want to deal with competent humans.
And: Do not let AI code Maple. This will lead to sloppy untrustworthy code with definitly more support requests.

 

MAple 2026.0

Maple 2025.2 craches on SupportTools.-Update()

Can anyone verify? 

Solutions?

FYI: The user interface issues I was having with Maple 2026  have now been resolved.

Documents imported with the AI-assistant can containt private and confidential information.

I was wondering how privacy is handeled by third party AI services that are called by the AI assistant.

From https://openai.com/enterprise-privacy/ it is not clear which product is running and how Maplesoft has set it up.

Anyone knows more?

I use plots:-display(Array([p1,p2])) to make two plots (or more) show side by side in worksheet. The problem with this is that there is no way to control the overall width of the output. 

It always takes the entire width of the worksheet window.  Using size=...  makes no difference. This only changes the size of each plot, but does not change the width of the display. Even when using size= inside the plot itself and not inside the display command, it makes no difference to the overall width of display. 

Here is an example to make things clear (site will not let me upload the worksheet).

Here is code and screen shot

s:=t->2*t^4-30*t^3+135*t^2-120*t-10:
v:=t->diff(s(t),t):
p1:=plot(s(t),t=0..8,'gridlines','thickness'=3,'color'="red",'title'="Plot of s(t)"):
p2:=plot(v(t),t=0..8,'gridlines','thickness'=3,'color'="blue",'title'="Plot of v(t)"):
plots:-display(Array([p1,p2]));


This is too wide. Adding size makes no difference. What size does is change each plot size, but display still is using the whole width of the worksheet which makes it look ugly

plots:-display(Array([p1,p2]),size=[300,300]);


I wanted it to look like this (using paint.exe to move things)

ie. to adjust the overall size of the display.

I can avoid display all together and just do 

[p1,p2];
#or
Array([p1,p2]);

But now each plot becomes too small and do not know how to make it larger, but at least they do not take the whole width of the worksheet

Is there a way to tell display not to use the overall width of the worksheet? say to use 50% of the current width and center the output, like the above example made using paint.exe shows?

Hello Friends.

I have created two piecewise functions: dx(t) and dy(t).  I then converted them to RandomVariables:  DX and DY.  When I try to perform a mathematical operation on the random variables, I get a Dirac function, which is unintended.  When I read about this issue, I learned that flawed (discontinuous) piecewise functions may be the problem.  However, my piecewise functions look ok to me.

Does anyone know why this is happening?  I do expect a lenghty result when I process the random variables, but not a Dirac function.  My code is below:

TriangleEuclidean.mw

I want to give my Tensor a the index i with define (a[i]) , but it is not allowed. Can anybody help ?

thank you !

Could someone please help me understand this

restart;
expr:=(A*x-1 )/x
eval(expr,x=infinity)
    # 0    why?

limit(expr,x=infinity)
   # A correct

How did Maple evaluate expr to zero when x=infinity? What math did it use to obtain this result? Did it may be just saw infinity in denominator and said the whole thing therefore is zero?  But there is infinity in the numerator also and infinity/infinity is not defined.

Maple 2026 and Maple 2025.5 on windows 10

Here is a minor nit regarding combining plots in Maple.

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

(1)

 

Plot the cardioids  1+`&+-`(cos*t) in polar coordinates:

pic1 := plot(1-cos(t), t=0..2*Pi, coords=polar);
pic2 := plot(1+cos(t), t=0..2*Pi, coords=polar);

 

 

 

When combining the plots, display() inherits the plotting range from the previous

plots, incorrecting taking it to be 0 .. 2*Pi
 

plots:-display(pic1, pic2, scaling=constrained);

 

To get the correct plot, we need to override the range determined by display():

plots:-display(pic1, pic2, scaling=constrained, view=[-2..2,-2..2]);

 
 

 

Download mw.mw

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