nm

11993 Reputation

20 Badges

13 years, 191 days

MaplePrimes Activity


These are replies submitted by nm

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

@Preben Alsholm 

Yes, I know Kovacic algorithm is used. That is what trace says and what I mentioned.

But Kovacic algorithm is for linear second order ode, and not for first order ode's. Main use of Kovacic is for time varying linear second order ode's which can't be solved easily by other methods.

So dsolve converted the non-linear first order ode first to a linear second order ode and then used Kovacic on it. That is all clear.

But my question is: How did it do this? Trace says clearly that it linearized the first order nonlinear ode by differentiating it, to a second order ode. But how? Since by differentiating the first order ode, it does not give a linear second order ode.

Is this method documented anywhere?

I think some of your result have wrong value at the end. You have extra entry at end of some of your lists.

Here is your code

And this is the output from the pdf:

Here is my implmenetation. No need to use explicit loop. This first gets all primes to the maximum number (in your example, you hade this hardcoded as 101, this takes it as argument), then using map to check if there is next prime in this list which is diff away from the current one.

restart;

ppair:=proc(the_diff::posint,max_number::posint)::list;
local len::posint;
local L::list; #list of primes

    L:=select(isprime,[$1..max_number]);
    print(L);
    len:=nops(L);
    map(N->`if`(N<len and member(L[N]+the_diff,L),L[N],NULL),[$1..len]);

end proc:    
        

ppair(2,101)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

[3, 5, 11, 17, 29, 41, 59, 71]

ppair(4,101)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

[3, 7, 13, 19, 37, 43, 67, 79, 97]

ppair(6,101)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

[5, 7, 11, 13, 17, 23, 31, 37, 41, 47, 53, 61, 67, 73, 83]

ppair(8,101)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

[3, 5, 11, 23, 29, 53, 59, 71, 89]

ppair(10,101)

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

[3, 7, 13, 19, 31, 37, 43, 61, 73, 79]

 

 

Download primes_jan_2_2026.mw

@janhardo 

Sure, This is how to check if anti-derivative is correct.  But see what happens if the anti-derivative is simplified first !

restart:
f := sqrt(1 + sin(x)^2):
F := int(f, x);
F:= simplify(F); #add this line
df := diff(F, x);
simplify(df - f); 

It now no longer gives zero automatically. 

However, now doing simplify(%,symbolic) on the above gives zero.

I do not like to use simpify with symbolic option as branch cuts and sign of things are ignored and sometimes wrong result can be generated.

For example 

e:=3*sqrt(x)*sqrt(y(x)) - 3*sqrt(x*y(x));
simplify(e);
simplify(e,'symbolic')

But the zero is correct only for reals and also when both x and y are nonnegative.

But isn't strange that simplifying the anti-derivative made it not give zero automatically? 

@sand15 

So what should one write in Maple, to get same exact output as Mathematica gives from its EllipticE[x, -1] ?

This is what I get

Table[EllipticE[x, -1], {x, -3, 3, .5}];
{-3.67814, -3.14006, -2.50798, -1.81002, -1.12389, -0.519174, 0., 
0.519174, 1.12389, 1.81002, 2.50798, 3.14006, 3.67814}

Not able to find what I need to do in Maple to get same numerical values as above.

If I do 

seq(EllipticE(x,I),x=-3..3,.5)

-EllipticE(3, I), -1.910098895 + 2.800167923*I, -1.910098895 + 2.187482903*I,
 -1.910098895 + 1.478001735*I, -1.910098895 + 0.*I, -0.5454514561 - 0.*I, 
0.*I, 0.5454514561 + 0.*I, 1.910098895 - 0.*I, 1.910098895 - 
1.478001735*I, 1.910098895 - 2.187482903*I, 1.910098895 -
 2.800167923*I, 1.910098895 - 3.372014175*I

Not same. And I do

seq(EllipticE(x,-1),x=-3..3,.5)

-3, -2.5, -2.0, -1.5, -1.0, -0.5, -0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0

Tried few other things, but can't get same numerical values as Mathematica.  Any idea what I need to change in Maple to get same output? I know this is related to different definitions. But what to change in Maple to make it produce same output?

May be the easiest thing is to make myEllipticE function in Maple and define it such that it is the same as sagemath and Mathematica are using, and use that instead of Maple's EllipticE if I want to get same exact output.

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