nm

12008 Reputation

20 Badges

13 years, 197 days

MaplePrimes Activity


These are replies submitted by nm

@acer 

fyi, I've run your CPL05.mw on 650 problems. No issues found. It handled empty plot OK.

I changed it on my end to return [] instead of PLOT(), as it is easier for caller function to check on [] result than PLOT(). 

     `if`( ( (not M::table) or nops([indices(M)])=0 )
           and ( (not T::table) or nops([indices(T)])=0 )
           and DensityOptions=NULL,
          [],  # <----- REPLACED PLOT() by []
          plots:-display([
          `if`(DensityOptions = NULL,NULL,
               plots:-densityplot(Expr, Range1, Range2, ':-colorbar'=false,
                                  ':-style'=':-surface', DensityOptions[])),
           `if`(M::table,seq(plot(mm,':-color'=M[mm[]], GraphicOptions[]),mm=[indices(M)]),NULL),
           `if`(T::table,seq(plots:-textplot(mm,':-color'="red", TextOptions[]),mm=[indices(T)]),NULL)
                    ], 'axes'=':-box', 'gridlines'=false, _rest)
        );

I've also made all labels on the lines to be one color red above.

I found this is better to read labels than having each label same color as the contour line, because when contour line have low shade/color, the lable is not affected and still easier to read the value on the lines.

Other than this, all is working OK now. Will run it over another 25,000 problems and see, but it looks good now. You can make this version the "official" one.

good job. You can send to Maplesoft and ask them to add to Maple 2026 as built in function.

@acer 

Is the code in your answer at the very top is now the "official version" to use and not the code in your later reply? 

If so, I just copied the code in your answer at very top but I get an error  

Error, (in ContoursWithLabels) invalid input: indices received M, which is not valid for its 1st argument, t

In one test.

Please see attached  worksheet.  Here is the input I used

ff:=ln(1+y^2);
ContoursWithLabels(ff,x=-10..10, y=-1..1,
            contours=[$-4..4],
            ImplicitplotOptions = [gridrefine=3],
            labels=[x,y]);

ps. you might want to remove the code in your later reply if this is not the one to use, so there is only one copy  of your function in the whole thread to reduce confusion as which one to use?

Forum firewall just decided to  not let me update my worksheet. Here is screen shot

Again, this used the version at the very top, not the second one in your later reply.

For now, will just add try/catch and return [] when this fail.So not a big problem.

May be your function could trap such error internally  and return [] back to user?

Here is what Maple does with same input, it returns empty plot if unable to generate contours

plots:-contourplot(ln(1+y^2), x=-10..10, y=-1..1,
           contours=[$-4..4],contourlabels = false, colorbar = false);

@acer 

Thanks for the updated version, it no longer give Error, (in contours_with_labels) invalid subscript selector on any of the above examples.

Maple 2025.2

@acer 

Thanks for the effort. I just saw this now.

For some values, it gives

Error, (in ContoursWithLabels) invalid subscript selector

Here is an example

ff := -y+(x-2)^2;
ContoursWithLabels(
     ff, x=-4..2, y=-200..40, contours=12,    
     ImplicitplotOptions = [gridrefine=3],     
     labels=[x,y]);

Changing  contours=12 to  contours=11 the error goes away.

Also keeping contours=12 but changing x=-4..2 to say x=-2..2 the error also goes away.

Here is another example (just changed the name of your function)

 ff := (x-1)/y;
contours_with_labels(
     ff,  x=-8..8, y=-8..8, contours=10,
     ImplicitplotOptions = [gridrefine=3],     
     labels=[x,y]);

Error, (in contours_with_labels) invalid subscript selector

Changing  contours=11 to  contours=10 the error goes away.

And this example below gives the  invalid subscript selector for any value of contours I tried from 2 all the way to 12 I tried.

ff :=cos(2*x);
contours_with_labels(
     ff,  x=-2*Pi..2*Pi, y=0.4..1.4, contours=9,     
     labels=[x,y]);

Maple 2025.2

May be this is what you mean? Not sure. You could try

Forum is broken again, here is screen shot



Download matrix.mw

You must have typed something else in Mathematica than what you show,. This has Dimension 3 and not 4 as you show. Mathematica's Dimension for list is just number of "rows". For Actual Matrix it will be {nrows,ncols}

IN addition, this is not a Matrix, Mathematica also says so

It is a ragged list.

You could enter it in Maple as list of lists?

 A:=[[a, [1, a, -0.5]], [[b, [1]]], c + d];

 

@Kitonum 

THnaks, I tried it. Only issue is colorscheme. In Maple one can do this

plots:-contourplot(y^2+x-1, x=-10..10, y=-10..10 ,
         contours=[$-1 .. 5], #specific slope value to show
         legend=true,
         'axes'='boxed',
         legendstyle=[location=right], 
         contourlabels = true,
         colorscheme="DivergeRainbow");

It will be nice to keep the coloring scheme as is, i.e. keep line coloring as is, but add labels.

When I use your proc, it seems one has to specify the color of each line or may be not?

Is there a way to use same automatic coloring of lines as above but just add labels?

When I try

ContoursWithLabels(y^2+x-1, x=-10 .. 10, y=-10 .. 10,contours={$-1 .. 5});

 

But to add coloring, when I tried

ContoursWithLabels(y^2+x-1, -10 .. 10, -10 .. 10,{$-1 .. 5},Coloring=[ colorscheme="DivergeRainbow"]);

Is there a way to get same output close to Maple's, i.e. keep same line coloring, but with the labels on the lines using your proc?

@acer 

unfortunately this does not work for each name listed in the initial known names. Small test:

restart;
f:=x+y+undefined+z+gamma+Pi+a+integrate+lasterror;
indets(f,And(name,Not(constant)));

@ecterrab 

fyi, may be this is what you meant.

I found workaround for this is to call `assuming/restore_previous_state`; in the catch. The reason solve hangs the second time, is because assumptions are stuck on y(x) after the timelimit expires. 

So your short example to reproduce it, now does not hang

restart;
ode_1:=y(x)*sqrt(1 + diff(y(x), x)^2) - a*y(x)*diff(y(x), x) - a*x = 0:
sol:=-_C4^2 + (-y(x)*sqrt(_C4^2/y(x)^2) + a*x)^2/a^2 + y(x)^2 = 0:
ode_2:=y(x)*(1+diff(y(x),x)^2)^(1/2)-a*y(x)*diff(y(x),x)-a*x = 0:

_Env_Physics_assumingusesAssume := true

solve(ode_2,diff(y(x),x)); #finishes right away

try
    timelimit(30,(odetest(sol,ode_1,y(x)) assuming integer));
catch:
   `assuming/restore_previous_state`; #MUST DO THIS, else next solve HANGS
end try;

solve(ode_2,diff(y(x),x)); #no hang now

@C_R 

I would not use map(forget, [anames()]); it causes problems. Here is an example

restart;

ode:=y(x)*sqrt(1 + diff(y(x), x)^2) - a*y(x)*diff(y(x), x) - a*x = 0:
sol:=-_C4^2 + (-y(x)*sqrt(_C4^2/y(x)^2) + a*x)^2/a^2 + y(x)^2 = 0;
timelimit(10,(odetest(sol,ode,y(x)) assuming integer)):

-_C4^2+(-y(x)*(_C4^2/y(x)^2)^(1/2)+a*x)^2/a^2+y(x)^2 = 0

Error, (in forget) time expired

map(forget, [anames()]);

[]

Physics:-Setup('assumingusesAssume'=true):

Warning, previous type for `&*` has been overwritten.

Warning, previous type for `&.` has been overwritten.

Warning, previous type for `&^` has been overwritten.

Warning, previous type for `&+` has been overwritten.

Error, (in TypeTools:-GetType) Physics:-ac_symbol is not a type registered with TypeTools

 

 

Download ex1_jan_18_2026.mw

This is the same code, without doing map(forget, [anames()]); no error

restart;

ode:=y(x)*sqrt(1 + diff(y(x), x)^2) - a*y(x)*diff(y(x), x) - a*x = 0:
sol:=-_C4^2 + (-y(x)*sqrt(_C4^2/y(x)^2) + a*x)^2/a^2 + y(x)^2 = 0;
timelimit(10,(odetest(sol,ode,y(x)) assuming integer)):

-_C4^2+(-y(x)*(_C4^2/y(x)^2)^(1/2)+a*x)^2/a^2+y(x)^2 = 0

Error, (in type/realcons) time expired

Physics:-Setup('assumingusesAssume'=true):

 

 

Download ex2_jan_18_2026.mw

I've asked this before here. In How-To-Make-Simplify-Run-Through-Same  

          " is there a way to disable the use of remember tables permanently in Maple?"

You can see answers given there. But based on these by Maple experts, it is not possible to do this without causing some trouble and side-effects.

If you have specific command in Maple you use, and want it not to remember things, what I do is this: For example, for simplify(), I call forget(simplify) each time right after calling simplify anywhere in the code.  Like this

simplify(....);
forget(simplify);

You can do the same for other maple commands that you want it not to remember things.

I started doing the above after finding a bug recently in Maple where simplify remembered things which caused a bug. The bug has since been fixed in Maple, but I kept the above code just in case to be safe.

Each time you use the command, add the forget() after it. 

most nonlinear ode's do not have analytical solutions. This looks like one of them. 

Even if it is first order, many can't be solved analytically. Abel ode's for example, 
few of those have known solutions.

Next best thing is to solve using series solution.

@Kitonum 

Downloaded your work, deleted the output and evaluated, but it does not work for me on Maple 2025.2. It changed back to horizontal.

restart;     

interface(version);

`Standard Worksheet Interface, Maple 2025.2, Windows 10, November 11 2025 Build ID 1971053`

f:=x->x^3-x^2+1;
g:=x->6-2*x-x^2;
the_legend:=[typeset("     ","f(x) = ", f(x),"     "), typeset("      ","g(x) = ",g(x),"     ")]:
plots[setoptions](font=[TIMES,16], labelfont=[TIMES,18]):
the_title:="Plot of f(x) and g(x)":
plot([f(x),g(x)],x=-5..5,
     'gridlines',
     'color'=['red','blue'],
    legend=the_legend,
     'legendstyle'=['location'='bottom'],
     'axes'='normal',
     'title'=the_title,  
     'scaling'='unconstrained');
 

proc (x) options operator, arrow; x^3-x^2+1 end proc

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

 

 

Download legend.mw

@C_R 

It is new, but it started 2-3 weeks ago. I've seen it few times already myself. It normally last for few minutes and then after that it goes away on its own. This below I just got now when I clicked on Mapleprimes.com

@sursumCorda 

I know that. I have been using the debugger for 15 years or more.

showstats displays the whole proc() listing and now I am looking at the last line. Then have to scroll back slowely to find the line I was looking at before. There is small ! mark that shows the line.

But it is hard to see this ! line if the code is long. So it takes time to find the line.  Sometimes I have to type "where" just to find the line number to make it easier to scroll back to correct location I was looking at before hitting showstats.

Then after wasting all this time, and hitting step again, it is back to seeing the 2-3 lines small window again. showstats listing is gone and back to the small window.

I Keep repeating this process over and over and over.  Each time I step, and if I want to see more context, I have to repeat all this. So much time wasted and frustration.

Have you actually used the debugger?

It is a mediocre interface from the stone age. Even the sympy debugger puDb written by just one person 10 years ago or so is so much better and easier to use

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