nm

12238 Reputation

20 Badges

13 years, 254 days

MaplePrimes Activity


These are questions asked by nm

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

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

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?

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

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