Maple 2024 Questions and Posts

These are Posts and Questions associated with the product, Maple 2024

How do I get the susset that contains unknowns on the rhs of the elements?

restart

 

# I need this subset {a=1/sqrt(2+A), b=6*sqrt(4+N),  d=5*H}

 

C:={a=1/sqrt(2+A),b=6*sqrt(4+N) ,c=sqrt(7),d=5*H,,e=-12,f=-96}

{a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), c = 7^(1/2), d = 5*H, e = -12, f = -96}

(1)

selectremove(has,indets(rhs~(C)),C)

{}, {A, H, K, N, 1/(2+A)^(1/2), (4+N)^(1/2)}

(2)

selectremove(has,lhs~(C)=indets(rhs~(C)),C)

() = (), {a, b, c, d, e} = {H, K, N, (4+N)^(1/2)}

(3)
 

 

Download 2024-06-05_Q_Select_Remove_indet_elements.mw

We see that this ode (x + y(x))*(1+diff(y(x),x)) = 0  has 2 solutions, One when (x + y(x))=0 and one when (1+diff(y(x),x))=0. Maple gives 3 solutions. They are correct but why?

Also when changing (1+diff(y(x),x)) to (a+diff(y(x),x)) now it gives only two solution.

Why does this happen? Should it not just return 2 solutions in both cases? and more strange one

(x + y(x))^2 *(1+diff(y(x), x))=0; now it gives 4 solutions. But this is no different. We also have 2 solutions. One when (x + y(x))=0 and one when (1+diff(y(x), x))=0. This time the extra two solutions are complex. 

17168

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1754 and is the same as the version installed in this computer, created 2024, June 3, 20:39 hours Pacific Time.`

ode:=(x + y(x))*(a+diff(y(x),x)) = 0;
dsolve(ode);
map(X->odetest(X,ode),[%])

(x+y(x))*(a+diff(y(x), x)) = 0

y(x) = -x, y(x) = -a*x+c__1

[0, 0]

ode:=(x + y(x))*(1+diff(y(x),x)) = 0;
dsolve(ode);
map(X->odetest(X,ode),[%])

(x+y(x))*(1+diff(y(x), x)) = 0

y(x) = -x, y(x) = -x-c__1, y(x) = -x+c__1

[0, 0, 0]

ode:= (x + y(x))^2 *(1+diff(y(x), x))=0;
dsolve(ode);
map(X->odetest(X,ode),[%])

 

(x+y(x))^2*(1+diff(y(x), x)) = 0

y(x) = -x, y(x) = -x+c__1, y(x) = -(1/2)*c__1-((1/2)*I)*3^(1/2)*c__1-x, y(x) = -(1/2)*c__1+((1/2)*I)*3^(1/2)*c__1-x

[0, 0, 0, 0]

 

 

Download why_extra_solution_from_dsolve_june_5_2024.mw

Any idea why this sometimes happens? odeadvisor says ode is quadrature but when asking it to solve it using quadrature sometimes it works and sometimes not.

Am I doing something wrong?

22020

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1754 and is the same as the version installed in this computer, created 2024, June 3, 20:39 hours Pacific Time.`

restart;

18368

Example 1 that does not work

 

ode:=diff(y(x),x)=-1;
DEtools:-odeadvisor(ode);

diff(y(x), x) = -1

[_quadrature]

sol:=dsolve(ode,y(x),['quadrature']);

"sol := "

Example 2 that works

 

ode:=diff(y(x),x)=x;
DEtools:-odeadvisor(ode);

diff(y(x), x) = x

[_quadrature]

sol:=dsolve(ode,y(x),['quadrature']);

y(x) = (1/2)*x^2+c__1

 

 

Download sometimes_dsolve_works_on_quadrature_june_5_2024.mw

Any one could find why Maple 2024 gives Error, (in evalf/int) invalid arguments on this ode? Why is it even calling evalf in first place as this is all symbolic.

Also reported to Maplesof just in case.

25504

restart;

25504

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1752 and is the same as the version installed in this computer, created 2024, May 31, 18:17 hours Pacific Time.`

ode:=diff(y(x), x)^3 = (x - 2)^2;
ic:=y(2)=1;
Student:-ODEs:-ODESteps([ode,ic]);

(diff(y(x), x))^3 = (x-2)^2

y(2) = 1

Error, (in evalf/int) invalid arguments

dsolve([ode,ic])

y(x) = 1+(1/5)*(3*x-6)*RootOf(_Z^3-x^2+4*x-4)

DEtools:-odeadvisor(ode)

[_quadrature]

 

 

Download odetest_internal_error_evalf_int_june_3_2024.mw

Probably I am missing the obvious. In the attached worksheet the for statement gives me all results as desired but if I try to put this in a procedure I only get the last value. Could someone help me out. Thank you  ProcQuestion.mw

I wanted to do 

map(X->odetest(X,ode) assuming x>0,[sol]) 

where sol are the solutions I wanted to test. The above does not work as is. After some trial and errors, I found this works

map(X->[odetest(X,ode) assuming x>0],[sol]) 

I am not sure why. But it works. Is this the above the correct way to add assuming to a command inside Map? Or is there a different way or better way to do this?

I want to stick to the map command as above and nothing else such as ~ or some other ones. I find map more clear to use for me.

Here is worksheet.

9592

restart;

9592

ode:=x = diff(y(x), x)*sqrt(1 + diff(y(x), x)^2);

x = (diff(y(x), x))*(1+(diff(y(x), x))^2)^(1/2)

sol:=dsolve(ode);
map(X->[odetest(X,ode) assuming x>0],[sol])

y(x) = ((1/32)*I)*2^(1/2)*(-(256/3)*Pi^(1/2)*2^(1/2)*x^3*cosh((3/2)*arcsinh(2*x))-8*Pi^(1/2)*2^(1/2)*(-(64/3)*x^4-(8/3)*x^2+2/3)*sinh((3/2)*arcsinh(2*x))/(4*x^2+1)^(1/2))/Pi^(1/2)+c__1, y(x) = -((1/32)*I)*2^(1/2)*(-(256/3)*Pi^(1/2)*2^(1/2)*x^3*cosh((3/2)*arcsinh(2*x))-8*Pi^(1/2)*2^(1/2)*(-(64/3)*x^4-(8/3)*x^2+2/3)*sinh((3/2)*arcsinh(2*x))/(4*x^2+1)^(1/2))/Pi^(1/2)+c__1, y(x) = Int(-(1/2)*(-2+2*(4*x^2+1)^(1/2))^(1/2), x)+c__1, y(x) = Int((1/2)*(-2+2*(4*x^2+1)^(1/2))^(1/2), x)+c__1

[[(1/2)*(2*x*(4*x^2+1)^(1/2)+(-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+16*x^3*sinh((3/2)*arcsinh(2*x))-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x)*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)], [-(1/2)*(-2*x*(4*x^2+1)^(1/2)+(-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+16*x^3*sinh((3/2)*arcsinh(2*x))-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x)*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)], [2*x], [0]]

for item in [sol] do
    odetest(item,ode) assuming x>0;
od;

(1/2)*(2*x*(4*x^2+1)^(1/2)+(-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+16*x^3*sinh((3/2)*arcsinh(2*x))-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x)*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)

-(1/2)*(-2*x*(4*x^2+1)^(1/2)+(-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+16*x^3*sinh((3/2)*arcsinh(2*x))-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x)*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)

2*x

0

 

 

Download how_to_use_map_with_assuming.mw

These  are good example(s)  why I think Maple's simplify needs to be improved. 

Example 1

Given an expression which is zero for nonnegative x, one would expect simplify to simplify it to zero when told that x is positive. 

But nothing I tried with simplify worked. combine  figured it out.

But why? Is this not the job of simplify? 

The expression is 

e:=x-1/4*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2);

Here is worksheet

``

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

28000

e:=x-1/4*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2);

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

coulditbe(e=0);

true

#we see it is zero for x>=0
plot(e,x=-3..3)

simplify(e) assuming x>=0;

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

simplify(e,size) assuming x>=0;

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

expand(e) assuming x>=0;

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

simplify(e,sqrt) assuming x>=0;

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

simplify(e,symbolic) assuming x>=0;

x-(1/4)*(-2+2*(4*x^2+1)^(1/2))^(1/2)*(2+2*(4*x^2+1)^(1/2))^(1/2)

combine(e) assuming x>=0;

0


Compare some other software on this same problem

It should be as simple as the above in Maple.

A user should not have to try 100 different commands in Maple to find which works.

simplify should have done it in first place. What Am I overlooking here?

Maple 2024

Download why_simplify_do_not_work_example.mw

EXAMPLE 2

In this example the expression is zero for x<0. Here nothing worked for me. This is challenge for Maple experts here to find the command to simplify this to zero. 

I know it is zero for x<0.

e := -1/2*(-2*x*sqrt(4*x^2 + 1) + (16*x^3*sinh(3/2*arcsinh(2*x)) - 8*x^2*cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1) + 4*sinh(3/2*arcsinh(2*x))*x - cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1))*sqrt(-2 + 2*sqrt(4*x^2 + 1)))/sqrt(4*x^2 + 1)


 

24064

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1752 and is the same as the version installed in this computer, created 2024, May 31, 18:17 hours Pacific Time.`

e:=-1/2*(-2*x*sqrt(4*x^2 + 1) + (16*x^3*sinh(3/2*arcsinh(2*x)) - 8*x^2*cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1) + 4*sinh(3/2*arcsinh(2*x))*x - cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1))*sqrt(-2 + 2*sqrt(4*x^2 + 1)))/sqrt(4*x^2 + 1);

-(1/2)*(-2*x*(4*x^2+1)^(1/2)+(16*x^3*sinh((3/2)*arcsinh(2*x))-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2))*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)

plot(e,x=-10..3);

coulditbe(e=0)

true

simplify(e) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

simplify(e,symbolic) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

combine(e) assuming x<0;

-(1/2)*(-2*x*(4*x^2+1)^(1/2)+(16*x^3*sinh((3/2)*arcsinh(2*x))-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2))*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)

simplify(e,arctrig) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

simplify(e,sqrt) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

simplify(normal(e),sqrt) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

simplify(normal(e, expanded)) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

simplify(radnormal(e)) assuming x<0;

(1/8)*((4*x^2+(4*x^2+1)^(1/2)+1)*(-2+2*(4*x^2+1)^(1/2))-64*x*((1/2)*cosh((3/2)*arcsinh(2*x))*(-1/8-x^2)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2))/((4*x^2+1)^(1/2)*x)

simplify(evala(e)) assuming x<0;

-8*((cosh((3/2)*arcsinh(2*x))*(-(1/2)*x^2-1/16)*(4*x^2+1)^(1/2)+sinh((3/2)*arcsinh(2*x))*x*(x^2+1/4))*(-2+2*(4*x^2+1)^(1/2))^(1/2)-(1/8)*x*(4*x^2+1)^(1/2))/(4*x^2+1)^(1/2)

 


Using some other software gives

I'd like to find command to do the same in Maple. i.e. simplify it to zero. What else to try?

 

Download why_simplify_do_not_work_example_2.mw

I think I found another problem with odetest.  When solution is implicit, it fails to verify the solution against the ode when adding the IC. (not everytime, but in some cases).

But it does verify the solution against the ode when IC is not given. I give 3 examples.  Also at bottom is worksheet of all of this.

Example 1

restart;

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;

It says solution satisfies the ode itself OK

odetest(mysol,ode);

gives 0

But adding IC now gives

odetest(mysol,[ode,ic]);

Which I am having hard time reading. Is it now saying the solution does not satisfy the ode or the IC? Both are supposed to be zero.

Are these not supposed to be in same order given? so it looks like if we go left to right, it is saying the solution do not satisfy the ode now but it does satisfy the IC. Right?

But before it said the solution satisfies the ode.

Also, we can see the IC is satisfied. Let do it by hand

eval(mysol,[y(x)=Pi/2,x=0])

              0 = 0

So why does it say solution satisfies the ode first, then when adding the IC, now it changed its mind?

Also, solving for y(x) from the implicit solution, now it verifies it OK  with the IC also:

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;
mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic])

          [0, 0]

You see. Same solution. But different result from odetest depending if it is implicit or explicit.

Is this supposed to happen or is this a bug in odetest I should report? odetest is supposed to handle both explicit and implicit solutions. I know my solutions are correct. I just use odetest for verification. I also plotted my solution against maple's solutions and they are exact match. 

Example 2

ode:=diff(y(x),x)=1+y(x)^2;
mysol:=arctan(y(x))=x;
ic:=y(0)=0;
odetest(mysol,ode);
odetest(mysol,[ode,ic]);

Gives 0 for the first call to odetest but gives [diff(y(x), x) - 1 - y(x)^2, 0] for the second call.

Changing the solution to explicit. now it verifies it

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

Now it gives [0,0]

Example 3

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=y(0)=1;
mysol:=ln(sqrt(y(x))+1)=x+ln(2);
odetest(mysol,ode);
odetest(mysol,[ode,ic]) assuming positive;

Gives for the first call but  [diff(y(x), x) - 2*y(x) - 2*sqrt(y(x)), 0] but when using explicit it now verifies OK

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]) assuming positive;

           [0, 0]

Maple 2024 on windows 10

23112

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1751 and is the same as the version installed in this computer, created 2024, May 31, 18:17 hours Pacific Time.`

Example 1

 

restart;

18420

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;
odetest(mysol,ode);

diff(y(x), x) = sin(y(x))

y(0) = (1/2)*Pi

ln(tan((1/2)*y(x))) = x

0

odetest(mysol,[ode,ic]);

[diff(y(x), x)-sin(y(x)), 0]

mysol:=ln(tan(y(x)/2))=x;
mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

ln(tan((1/2)*y(x))) = x

2*arctan(exp(x))

[0, 0]

Example 2

 

ode:=diff(y(x),x)=1+y(x)^2;
mysol:=arctan(y(x))=x;
ic:=y(0)=0;
odetest(mysol,ode);

diff(y(x), x) = 1+y(x)^2

arctan(y(x)) = x

y(0) = 0

0

odetest(mysol,[ode,ic]);

[diff(y(x), x)-1-y(x)^2, 0]

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

tan(x)

[0, 0]

Example 3

 

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=y(0)=1;
mysol:=ln(sqrt(y(x))+1)=x+ln(2);
odetest(mysol,ode);

diff(y(x), x)-2*y(x) = 2*y(x)^(1/2)

y(0) = 1

ln(y(x)^(1/2)+1) = x+ln(2)

0

odetest(mysol,[ode,ic]) assuming positive;

[diff(y(x), x)-2*y(x)-2*y(x)^(1/2), 0]

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]) assuming positive;

(2*exp(x)-1)^2

[0, 0]

 

 

Download odetest_implicit_problem_june_2_2024.mw

Simple question. I hope it has simple answer. I have always thought that what int() returns should match exactly what "default" result shows when using int() with the option _RETURNVERBOSE 

I mean exact match. But this below shows that int() result underwent some simplification as it is not the same as default.

restart;

integrand:=sin(x)/(sin(x) + 1);
maple_result_1 :=int(integrand,x);
maple_result_2 := int(integrand,x,'method'=':-_RETURNVERBOSE')[1]

Ofcourse maple_result_2 can be made the same as maple_result_1

simplify(rhs(maple_result_2)) assuming 0<x and x<Pi;

But this is beside the point. Why is "default" is not excatly the same as int() result?  It seems that int() does something more after obtaining the :"default" result as shown.

Should default not match exactly result from int() ?

Maple 2024.

 

Maple int gives one result, called the "default" result unless one uses method=_RETURNVERBOSE to look for other results.

First, how does Maple decide what is "default" i.e. given all the methods listed, what method then used for "default".

Here is an example where default result makes it hard to solve for a differential equation. The integrand is 

1/(y+sqrt(y))

Maple int default gives anti as ln(y - 1) + 2*arctanh(sqrt(y))  which is complex valued for all y. The arctanh is only defined for argument between -1 and 1 also. Having sqrt there makes it now valid for 0 to 1. But ln(y-1) is negative in this region also. Hence complex. 

Using method=_RETURNVERBOSE we see much better anti derivatives hidding there and given by "derivativedivides" and "meijerg" as 2*ln(1 + sqrt(y)) which is complex valued only for negative y and real for all positive y. Same for "trager"  ln(2*sqrt(y) + 1 + y)

So it would have been much better if Maple picks the best anti-derivative automatically and use that for default instead and give this to the user.

Why is this important? Try to solve   the ode y'/(y+sqrt(y))=2 with IC y(0)=1 and you see we can't solve for the constant of integration using  ln(y - 1) + 2*arctanh(sqrt(y))=2x+c since at y=1 we get division by zero. If Maple had returned 2*ln(1 + sqrt(y)) instead then solving for constant of integration is trivial now since anti is real and defined at y=1

This is just one example of many.

My question is, How does Maple integrate decide what is "default" and why it does not try harder to pick better one (using number of known metrices for this sort of thing) from the other solvers it already has access to?  

What is the point of having all these other nice integrate methods, if the default used is not the "best" one?

Should user then always use method=_RETURNVERBOSE and then try to pick the "best" one themselves? This will be too much work for user to do.

I think Maple should do this automatically. Btw, I tried few other CAS integrators and the all give the better result given above by "meijerg" automatically.

Maple 2024

 

Update

Here is a quick function, called it smart_int() which returns the anti-derivative with the smallest leaf size from Maple.

Ofcourse smallest leaf size does not mean the anti-derivative is necessarily the "best" using other measures. But this function already allowed me to solve some ode's I could not solve before using Maple's defaullt int result because it made solving for constant of integration easier now.

Feel free to improve and change. If you find any bugs please let me know

The test here shows the result of smart_int compared to int on few integrals. You see on many of them smart_int gives smaller result. Additional criteria for selection can ofcourse be added and I will probably do that.

For example, do not pick ones with complex numbers if there is one without even though leaf size is smaller. This check has been added also.

Check the last integral in this test. The difference is so large. 


 

restart:

8456

#smart_int picks the anti-derivative with smallest leaf count
#version June 1, 2024. Maple 2024
#change: added check not to pick one with complex even is smaller
#change: added percentage reduction

smart_int:=proc(integrand,x::symbol)
local anti,result_of_int,a,b;

    local F:=proc(a,b)::truefalse;       
       if (has(a,I) and has(b,I)) or ( not has(a,I)  and not has(b,I)) then
           evalb(MmaTranslator:-Mma:-LeafCount(a)<MmaTranslator:-Mma:-LeafCount(b));
       elif has(a,I) then
           false;
       else
           true;
       fi;
    end proc;

    try
        anti := timelimit(60,int(integrand,x,'method'=':-_RETURNVERBOSE'));
        if evalb(op(0,anti)='int') then
           RETURN(anti);
        fi;   
    catch:
        RETURN(Int(integrand,x));
    end try;
    
    result_of_int := select(type,anti,string=algebraic);
    if nops(result_of_int)=0 then
        RETURN(Int(integrand,x));
    fi;

    result_of_int := map(X->rhs(X),result_of_int);
    result_of_int := sort(result_of_int,(a,b)->F(a,b));

    #return the one with smallest leaf size
    RETURN(result_of_int[1]);
    
end proc:

#TESTS

tests:=[1/(x+sqrt(x)),1/(sin(x)),1/(cos(x)),sin(x)/(sin(x)+1),1/((1+x)^(2/3)-(1+x)^(1/2)),1/x^3/(1+x)^(3/2),1/(1-x)^(7/2)/x^5,x*((-a+x)/(b-x))^(1/2),x/(-x^2+5)/(-x^2+3)^(1/2),exp(arcsin(x))*x^3/(-x^2+1)^(1/2),x*arctan(x)^2*ln(x^2+1),(x^2+1)/(-x^2+1)/(x^4+1)^(1/2),(a+b*f*x+b*sin(f*x+e))/(a+a*cos(f*x+e)),x*ln(1/x+1),1/x/(x^5+1)];
result:=map(X->[Int(X,x),int(X,x),smart_int(X,x)],tests):
for item in result do
    print("###################################\nintegral",item[1]);
    print("maple default result ",item[2]);
    print("smart int result ",item[3]);
    PERCENTAGE:=MmaTranslator:-Mma:-LeafCount(item[3])*100/MmaTranslator:-Mma:-LeafCount(item[2]):
    print("smart int percentage size relative to default ",sprintf("%.2f",PERCENTAGE));
od:
 

[1/(x+x^(1/2)), 1/sin(x), 1/cos(x), sin(x)/(sin(x)+1), 1/((1+x)^(2/3)-(1+x)^(1/2)), 1/(x^3*(1+x)^(3/2)), 1/((1-x)^(7/2)*x^5), x*((-a+x)/(b-x))^(1/2), x/((-x^2+5)*(-x^2+3)^(1/2)), exp(arcsin(x))*x^3/(-x^2+1)^(1/2), x*arctan(x)^2*ln(x^2+1), (x^2+1)/((-x^2+1)*(x^4+1)^(1/2)), (a+b*f*x+b*sin(f*x+e))/(a+a*cos(f*x+e)), x*ln(1/x+1), 1/(x*(x^5+1))]

"###################################
integral", Int(1/(x+x^(1/2)), x)

"maple default result ", ln(x-1)+2*arctanh(x^(1/2))

"smart int result ", 2*ln(x^(1/2)+1)

"smart int percentage size relative to default ", "72.73"

"###################################
integral", Int(1/sin(x), x)

"maple default result ", ln(csc(x)-cot(x))

"smart int result ", ln(tan((1/2)*x))

"smart int percentage size relative to default ", "62.50"

"###################################
integral", Int(1/cos(x), x)

"maple default result ", ln(sec(x)+tan(x))

"smart int result ", ln(sec(x)+tan(x))

"smart int percentage size relative to default ", "100.00"

"###################################
integral", Int(sin(x)/(sin(x)+1), x)

"maple default result ", 2/(tan((1/2)*x)+1)+x

"smart int result ", (x*tan((1/2)*x)+2+x)/(tan((1/2)*x)+1)

"smart int percentage size relative to default ", "150.00"

"###################################
integral", Int(1/((1+x)^(2/3)-(1+x)^(1/2)), x)

"maple default result ", 6*(1+x)^(1/6)+3*(1+x)^(1/3)+ln(x)+2*ln((1+x)^(1/6)-1)-ln((1+x)^(1/3)+(1+x)^(1/6)+1)-2*ln((1+x)^(1/6)+1)+ln((1+x)^(1/3)-(1+x)^(1/6)+1)-ln((1+x)^(1/2)+1)+ln((1+x)^(1/2)-1)+2*ln((1+x)^(1/3)-1)-ln((1+x)^(2/3)+(1+x)^(1/3)+1)

"smart int result ", 3*(1+x)^(1/3)+6*(1+x)^(1/6)+6*ln((1+x)^(1/6)-1)

"smart int percentage size relative to default ", "22.73"

"###################################
integral", Int(1/(x^3*(1+x)^(3/2)), x)

"maple default result ", (1/8)/((1+x)^(1/2)+1)^2+(7/8)/((1+x)^(1/2)+1)-(15/8)*ln((1+x)^(1/2)+1)-(1/8)/((1+x)^(1/2)-1)^2+(7/8)/((1+x)^(1/2)-1)+(15/8)*ln((1+x)^(1/2)-1)+2/(1+x)^(1/2)

"smart int result ", (1/4)*(15*x^2+5*x-2)/((1+x)^(1/2)*x^2)-(15/4)*arctanh((1+x)^(1/2))

"smart int percentage size relative to default ", "40.28"

"###################################
integral", Int(1/((1-x)^(7/2)*x^5), x)

"maple default result ", (1/64)/((1-x)^(1/2)+1)^4+(17/96)/((1-x)^(1/2)+1)^3+(159/128)/((1-x)^(1/2)+1)^2+(1083/128)/((1-x)^(1/2)+1)-(3003/128)*ln((1-x)^(1/2)+1)-(1/64)/((1-x)^(1/2)-1)^4+(17/96)/((1-x)^(1/2)-1)^3-(159/128)/((1-x)^(1/2)-1)^2+(1083/128)/((1-x)^(1/2)-1)+(3003/128)*ln((1-x)^(1/2)-1)+(2/5)/(1-x)^(5/2)+(10/3)/(1-x)^(3/2)+30/(1-x)^(1/2)

"smart int result ", (1/960)*(45045*x^6-105105*x^5+69069*x^4-6435*x^3-1430*x^2-520*x-240)/((x-1)^2*(1-x)^(1/2)*x^4)-(3003/64)*arctanh((1-x)^(1/2))

"smart int percentage size relative to default ", "37.18"

"###################################
integral", Int(x*((-a+x)/(b-x))^(1/2), x)

"maple default result ", (1/8)*(arctan((1/2)*(-b+2*x-a)/(-a*b+a*x+b*x-x^2)^(1/2))*a^2+2*b*arctan((1/2)*(-b+2*x-a)/(-a*b+a*x+b*x-x^2)^(1/2))*a-3*arctan((1/2)*(-b+2*x-a)/(-a*b+a*x+b*x-x^2)^(1/2))*b^2+4*(-a*b+a*x+b*x-x^2)^(1/2)*x-2*(-a*b+a*x+b*x-x^2)^(1/2)*a+6*(-a*b+a*x+b*x-x^2)^(1/2)*b)*(-(-a+x)/(-b+x))^(1/2)*(-b+x)/(-(-a+x)*(-b+x))^(1/2)

"smart int result ", (1/4)*(a-3*b-2*x)*(b-x)*(-(a-x)/(b-x))^(1/2)*(-(a-x)*(b-x))^(1/2)/(-(-a+x)*(-b+x))^(1/2)+((1/4)*b*a+(1/8)*a^2-(3/8)*b^2)*arctan((x-(1/2)*a-(1/2)*b)/(-x^2+(a+b)*x-b*a)^(1/2))*(-(a-x)/(b-x))^(1/2)*(-(a-x)*(b-x))^(1/2)/(a-x)

"smart int percentage size relative to default ", "67.63"

"###################################
integral", Int(x/((-x^2+5)*(-x^2+3)^(1/2)), x)

"maple default result ", -(1/4)*2^(1/2)*arctan((1/4)*(-4-2*5^(1/2)*(x-5^(1/2)))*2^(1/2)/(-(x-5^(1/2))^2-2*5^(1/2)*(x-5^(1/2))-2)^(1/2))-(1/4)*2^(1/2)*arctan((1/4)*(-4+2*5^(1/2)*(x+5^(1/2)))*2^(1/2)/(-(x+5^(1/2))^2+2*5^(1/2)*(x+5^(1/2))-2)^(1/2))

"smart int result ", -(1/2)*2^(1/2)*arctan((1/2)*(-x^2+3)^(1/2)*2^(1/2))

"smart int percentage size relative to default ", "20.20"

"###################################
integral", Int(exp(arcsin(x))*x^3/(-x^2+1)^(1/2), x)

"maple default result ", int(exp(arcsin(x))*x^3/(-x^2+1)^(1/2), x)

"smart int result ", Int(exp(arcsin(x))*x^3/(-x^2+1)^(1/2), x)

"smart int percentage size relative to default ", "100.00"

"###################################
integral", Int(x*arctan(x)^2*ln(x^2+1), x)

"maple default result ", (2*I)*ln(2)*arctan(x)-ln((1+I*x)^2/(x^2+1)+1)*arctan(x)^2*x^2+(1/2)*csgn(I*(1+I*x)^2/(x^2+1))^3*Pi*arctan(x)+(1/2)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))^3*Pi*arctan(x)-I*csgn(I*(1+I*x)/(x^2+1)^(1/2))*csgn(I*(1+I*x)^2/(x^2+1))^2*Pi*arctan(x)*x-((1/2)*I)*csgn(I*((1+I*x)^2/(x^2+1)+1))^2*csgn(I*((1+I*x)^2/(x^2+1)+1)^2)*Pi*arctan(x)*x-((1/4)*I)*csgn(I*(1+I*x)/(x^2+1)^(1/2))^2*csgn(I*(1+I*x)^2/(x^2+1))*Pi*arctan(x)^2*x^2-((1/4)*I)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))*csgn(I/((1+I*x)^2/(x^2+1)+1)^2)*csgn(I*(1+I*x)^2/(x^2+1))*Pi*arctan(x)^2+((1/4)*I)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))^2*csgn(I/((1+I*x)^2/(x^2+1)+1)^2)*Pi*arctan(x)^2*x^2+((1/4)*I)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))^2*csgn(I*(1+I*x)^2/(x^2+1))*Pi*arctan(x)^2*x^2+((1/4)*I)*csgn(I*((1+I*x)^2/(x^2+1)+1))^2*csgn(I*((1+I*x)^2/(x^2+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2+1)+1)*Pi*csgn(I*(1+I*x)/(x^2+1)^(1/2))^2*csgn(I*(1+I*x)^2/(x^2+1))-((1/2)*I)*ln((1+I*x)^2/(x^2+1)+1)*Pi*csgn(I*((1+I*x)^2/(x^2+1)+1))^2*csgn(I*((1+I*x)^2/(x^2+1)+1)^2)-((1/2)*I)*ln((1+I*x)^2/(x^2+1)+1)*Pi*csgn(I*(1+I*x)^2/(x^2+1))*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))^2-((1/2)*I)*ln((1+I*x)^2/(x^2+1)+1)*Pi*csgn(I/((1+I*x)^2/(x^2+1)+1)^2)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))^2-I*csgn(I*(1+I*x)/(x^2+1)^(1/2))*csgn(I*(1+I*x)^2/(x^2+1))^2*ln((1+I*x)^2/(x^2+1)+1)*Pi+(1/2)*csgn(I*(1+I*x)^2/((x^2+1)*((1+I*x)^2/(x^2+1)+1)^2))*csgn(I/((1+I*x)^2/(x^2+1)+1)^2)*csgn(I*(1+I*x)^2/(x^2+1))*Pi*arctan(x)+I*ln((1+I*x)^2/(x^2+1)+1)*Pi*csgn(I*((1+I*x)^2/(x^2+1)+1))*csgn(I*((1+I*x)^2/(x^2+1)+1)^2)^2-(1/2)*arctan(x)^2

"smart int result ", (1/2)*ln(x^2+1)*arctan(x)^2*x^2-(1/2)*arctan(x)^2*x^2-ln(x^2+1)*arctan(x)*x+(1/2)*ln(x^2+1)*arctan(x)^2+3*arctan(x)*x-(3/2)*arctan(x)^2+(1/4)*ln(x^2+1)^2-(3/2)*ln(x^2+1)

"smart int percentage size relative to default ", "2.45"

"###################################
integral", Int((x^2+1)/((-x^2+1)*(x^4+1)^(1/2)), x)

"maple default result ", (1/4)*(arctanh((x^2-x+1)*2^(1/2)/(x^4+1)^(1/2))-arctanh((x^2+x+1)*2^(1/2)/(x^4+1)^(1/2)))*2^(1/2)

"smart int result ", (1/2)*arctanh((1/2)*(x^4+1)^(1/2)*2^(1/2)/x)*2^(1/2)

"smart int percentage size relative to default ", "45.65"

"###################################
integral", Int((a+b*f*x+b*sin(f*x+e))/(a+a*cos(f*x+e)), x)

"maple default result ", tan((1/2)*f*x+(1/2)*e)/f+b*x*tan((1/2)*f*x+(1/2)*e)/a-b*ln(1+tan((1/2)*f*x+(1/2)*e)^2)/(a*f)-b*ln(cos(f*x+e)+1)/(a*f)

"smart int result ", tan((1/2)*f*x+(1/2)*e)*(b*f*x+a)/(a*f)

"smart int percentage size relative to default ", "31.43"

"###################################
integral", Int(x*ln(1/x+1), x)

"maple default result ", (1/2)*ln(1/x)+(1/2)*x-(1/2)*ln(1/x+1)*(1/x+1)*(1/x-1)*x^2

"smart int result ", (1/2)*x^2*ln(1/x+1)+(1/2)*x-(1/2)*ln(1+x)

"smart int percentage size relative to default ", "67.74"

"###################################
integral", Int(1/(x*(x^5+1)), x)

"maple default result ", -(1/5)*ln(1+x)+ln(x)-(1/5)*ln(x^4-x^3+x^2-x+1)

"smart int result ", ln(x)-(1/5)*ln(x^5+1)

"smart int percentage size relative to default ", "39.29"

 


 

Download smart_int.mw

 

Any workaround or why ODESteps gives this internal Maple error?  Is this known limitation of ODESteps?

ps. reported also to Maplesoft just in case.

17128

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1750 and is the same as the version installed in this computer, created 2024, May 31, 10:47 hours Pacific Time.`

restart;

20456

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
DEtools:-odeadvisor(ode);
 

diff(y(x), x)-2*y(x) = 2*y(x)^(1/2)

[_quadrature]

ic:=y(0) = 1;
Student:-ODEs:-ODESteps([ode,ic]);

y(0) = 1

Error, (in ln) numeric exception: division by zero

restart;

20456

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=y(0) = 1;
dsolve([ode,ic]);

diff(y(x), x)-2*y(x) = 2*y(x)^(1/2)

y(0) = 1

y(x) = 4*exp(2*x)-4*exp(x)+1

 

 

Download bug_in_odesteps_divide_by_zero_may_31_2024.mw

I put together the attached worksheet to help me determine the cheapest way to buy "refreshments" for a party by comparing price and volume of different bottle size options.  The spreadsheet works fine as is.  However, when I right click on the output of line (14) and format pct_difference as percent with 2 decimal places and execute the worksheet, Maple hangs on that line and progresses no further.  This doesn't happen in Maple 2018 but the problem does show up in Maple 2024.  Suggestions please?

cost_comparison_-_liquid_(v01MP).mw

This question is as much an observation of somthing I accidently stumbled across. I was using eval[recurse] to evaluate expressions reduced with LargeExpressions. I found eval['recurse'](eval['recurse']([Expr1 , Expr2] , [Q=.. Q1=.....])[]) to be better than simplify(eval['recurse']([Expr1 , Expr2] , [Q=.. Q1=.....])[]).

I only realised what was happening  when I put the below together. Then I could see the wood from the trees. 

It would be interesting to know why.

restart

 

Pt:=[[(sqrt(2*sqrt(Q[2]) + 2*Q[10])*sqrt(Q[6])*(t^2 + 1)/(sqrt(sqrt(Q[2])/(4*a*c - b^2)^2)*sqrt((2*sqrt(Q[2])*a*c^2*e^2 + 2*sqrt(Q[2])*b^2*c^2*f - 8*sqrt(Q[2])*a^3*c*f + 2*sqrt(Q[2])*a^2*b^2*f + 16*sqrt(Q[2])*a^2*c^2*f + 2*sqrt(Q[2])*a^2*c*d^2 - 4*sqrt(Q[2])*a^2*c*e^2 - 8*sqrt(Q[2])*a*c^3*f - 4*sqrt(Q[2])*a*c^2*d^2 + 2*sqrt(Q[2])*a^3*e^2 + 2*sqrt(Q[2])*c^3*d^2 - 2*sqrt(Q[2])*b*c^2*d*e + 4*sqrt(Q[2])*a*b*c*d*e - 2*sqrt(Q[2])*a^2*b*d*e - 4*sqrt(Q[2])*a*b^2*c*f + sqrt(Q[2])*sqrt(2*sqrt(Q[2]) + 2*Q[10])*sqrt(2*sqrt(Q[2]) - 2*Q[10])*Q[7] - 2*Q[11])*signum((sqrt(Q[2])*sqrt(2*sqrt(Q[2]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[2]) - 2*Q[10])*Q[7] + 8*(-(a - c)^2*sqrt(Q[2])/4 + Q[5]/4)*Q[8])*Q[4])*Q[4])*(t^2 - 1)) - 2*a*e + b*d)/(4*a*c - b^2)],

[Q[2] = (a^2 - 2*a*c + b^2 + c^2)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)^2, Q[4] = 1/((a^2 - 2*a*c + b^2 + c^2)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)^2), Q[5] = (a^2 - 2*a*c + b^2 + c^2)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)*(a + c), Q[6] = signum((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)/(4*a*c - b^2))*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)/(4*a*c - b^2), Q[7] = csgn((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)*(b*I + a - c)*I)*b, Q[8] = 4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2, Q[9] = csgn((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)*(b*I + a - c)*I), Q[10] = (a - c)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2), Q[11] = (a + c)*(a^2 - 2*a*c + b^2 + c^2)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)^2]]:

length(Pt);  # was >27,000

5002

(1)

valsh:=[a = -9, b = -9, c = 16, d = -10, e = 7, f = -36]

[a = -9, b = -9, c = 16, d = -10, e = 7, f = -36]

(2)

S1:=eval['recurse'](Pt,valsh)[];

length(%)

 

[-(1/657)*(2*Q[2]^(1/2)+2*Q[10])^(1/2)*Q[6]^(1/2)*(t^2+1)*431649^(1/2)/(Q[2]^(1/4)*((-28903750*Q[2]^(1/2)+Q[2]^(1/2)*(2*Q[2]^(1/2)+2*Q[10])^(1/2)*(2*Q[2]^(1/2)-2*Q[10])^(1/2)*Q[7]-2*Q[11])*signum((Q[2]^(1/2)*(2*Q[2]^(1/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8*(-(625/4)*Q[2]^(1/2)+(1/4)*Q[5])*Q[8])*Q[4])*Q[4])^(1/2)*(t^2-1))-24/73], [Q[2] = 377479229074, Q[4] = 1/377479229074, Q[5] = 114273866, Q[6] = 23123/657, Q[7] = -9, Q[8] = 23123, Q[9] = 1, Q[10] = -578075, Q[11] = 2642354603518]

 

2074

(3)

simplify(S1);# this is  simplify with side retations
length(%)

[-(257/248003853501618)*377479229074^(3/4)*((377479229074^(1/4)*(t^2-1)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)+(1/168849)*657^(1/2)*23123^(1/2)*431649^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(t^2+1))*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)+(2/168849)*23123^(1/2)*657^(1/2)*431649^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)*t)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t-1)*(t+1)), -(12/13777991861201)*377479229074^(3/4)*((377479229074^(1/4)*(t^2-1)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)-(1/141912)*657^(1/2)*23123^(1/2)*431649^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)*(t^2+1))*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)+(1/70956)*(2*377479229074^(1/2)-1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2))/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t-1)*(t+1))]

 

2316

(4)

simplify(%%);
length(%)

[-(1/71716466988)*(-2471*706^(1/2)+249218)^(1/2)*(2471*706^(1/2)+249218)^(1/2)*((73^(1/2)*(t^2+1)*(46246*706^(1/2)-1156150)^(1/2)+(257/3)*706^(1/4)*(14+2*706^(1/2))^(1/2)*t^2)*(-14+2*706^(1/2))^(1/2)+2*73^(1/2)*(t*(46246*706^(1/2)+1156150)^(1/2)*(14+2*706^(1/2))^(1/2)-257*706^(1/4)))*706^(1/4)/(t^2-1), (1/71716466988)*(-2471*706^(1/2)+249218)^(1/2)*((73^(1/2)*(t^2+1)*(46246*706^(1/2)+1156150)^(1/2)-72*706^(1/4)*(14+2*706^(1/2))^(1/2)*t^2)*(-14+2*706^(1/2))^(1/2)-2*73^(1/2)*((14+2*706^(1/2))^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*t-216*706^(1/4)))*(2471*706^(1/2)+249218)^(1/2)*706^(1/4)/(t^2-1)]

 

744

(5)

 

S2:=eval['recurse'](eval['recurse'](Pt,valsh)[]);# I find this interesting
length(%)

[-(1/162938531750563026)*(2*377479229074^(1/2)-1156150)^(1/2)*23123^(1/2)*657^(1/2)*(t^2+1)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t^2-1))-(1/81469265875281513)*(2*377479229074^(1/2)+1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*(t^2-1))-257/657, (1/162938531750563026)*(2*377479229074^(1/2)+1156150)^(1/2)*23123^(1/2)*657^(1/2)*(t^2+1)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t^2-1))-(1/81469265875281513)*(2*377479229074^(1/2)-1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*(t^2-1))-24/73]

 

1283

(6)

simplify(S2); #
length(%)

 

[-(1/406325592)*(14+2*706^(1/2))^(1/2)*(((181442/3)*(14+2*706^(1/2))^(1/2)*t^2+706^(3/4)*73^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*(t^2+1))*(-14+2*706^(1/2))^(1/2)+2*(46246*706^(1/2)+1156150)^(1/2)*73^(1/2)*706^(3/4)*(14+2*706^(1/2))^(1/2)*t-362884*73^(1/2))*(-14+2*706^(1/2))^(1/2)/(t^2-1), (14+2*706^(1/2))^(1/2)*((-2*706^(3/4)*73^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*t-50832*(-14+2*706^(1/2))^(1/2)*t^2)*(14+2*706^(1/2))^(1/2)+(304992+(t^2+1)*(46246*706^(1/2)+1156150)^(1/2)*706^(3/4)*(-14+2*706^(1/2))^(1/2))*73^(1/2))*(-14+2*706^(1/2))^(1/2)/(406325592*t^2-406325592)]

 

705

(7)
 

 

Download 2024-05-31_Eval_Recurse_vs_Simplify_Side_Rels.mw

counts_and_bins_data_output_from_histogram().mw

The Historgram( ) function is the combination of a binning computation and a visualization of the result of the binning computation. In order to generate any histogram you need to know the set of bin boundaries and the number of counts in each bin.

 

These bin boundaries look like: bin_bounds := [[`x__1,min`, `x__1,max`], [`x__2,min`, `x__2,max`], () .. (), [`x__N,min`, `x__N,max`]]where there are N bins in total.

The counts data looks like: counts := [H__1, H__2, () .. (), H__N]where there are N bins in total.

 

The Histogram( ) command passed this data around internally. Can I have Histogram( ) output this data? In other words, can I get the x-y data from the histogram, the bins-counts data?


Download counts_and_bins_data_output_from_histogram().mw

Can_I_change_the_location_of_the_color_bar_caption_in_Maple_2024.mw

In Maple 2024,

can I change the location of the color bar caption in Maple 2024? It conflicts with the color bar labels sometimes. See the attached maple sheet for an example.

3 4 5 6 7 8 9 Page 5 of 12