Dr. David Harrington

6083 Reputation

21 Badges

19 years, 322 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity

These are replies submitted by dharr

@michele I'm just worried that for different versions of Maple, different number of random numbers might be used, leading to a diffferent answer for later calculations, even if the first one, r, is the same. An across-versions comparison might need to save the actual polynomial to an .m file and the read them in. That seems like overkill, so try running this to see if you get the same answer, and then the timing comparisons might make more sense.

Edit: 13th Gen Intel(R) Core(TM) i5-1335U   1.30 GHz; 16.0 GB RAM, in "best performance" mode.



`Standard Worksheet Interface, Maple 2024.1, Windows 11, June 25 2024 Build ID 1835466`


"X86 64 WINDOWS", "x86-64", 12



r:= 87*x^10 - 56*x^9 - 62*x^3 + 97*x - 73;


p:=expand(r*randpoly(x, degree=10^6)):
q:=expand(r*randpoly(x, degree=10^5)):


memory used=18.21MiB, alloc change=8.75MiB, cpu time=1.76s, real time=8.61s, gc time=15.62ms



Download gcd.mw

@michele The version of Maple could make a difference here, and the exact random numbers might not be the same (which seems to be the case in the second example because a different answer is obtained). Different polynomials might take different times so unless you average a lot of examples, it is hard to know what an average time is. So for the class polynomials you are using these might not be typical.

So are these results not acceptable to you? You are getting answers without crashes for what I would call large degree polynomials. Your CPU and real times are the same suggesting only one CPU, and perhaps an older computer without multiple cores?

I assume grade means degree here? Some further details about typical coeffs, number of terms, degree etc would be helpful. For integer coeffs, dense or sparse number of terms, degree 10^5 seems feasible, but with both degrees 10^6, it took longer than I was willing to wait. (This was Maple 2024 on Windows 11.)


r:=randpoly(x, degree = 15);
p:=expand(r*randpoly(x, dense, degree=10^5)):
q:=expand(r*randpoly(x, dense, degree=10^5+20)):



memory used=70.30MiB, alloc change=35.88MiB, cpu time=4.72s, real time=19.49s, gc time=0ns


p:=expand(r*randpoly(x, degree=10^6)):
q:=expand(r*randpoly(x, degree=10^5)):


memory used=8.03MiB, alloc change=-29.05MiB, cpu time=1.06s, real time=3.67s, gc time=0ns



Download gcd.mw


@MaPal93 I'm not sure how they are chosen. They seem to be points with integer coordinates on a grid, but I suppose if a region was too small for that then some rationals would be chosen. Note that for regions 2 and 3, the horizontal axis has no particular significance. I think the basic idea is to have any point for which evaluation proves that the equations and inequalities are satisfied; in that sense it doesn't matter where in the region it is.

@C_R With floating point limits, it is supposed to switch to numerical integration. From ?int

"If any of the integration limits of a definite integral are floating-point numbers (e.g. 0.0, 1e5 or an expression that evaluates to a float, such as exp(-0.1)), then int computes the integral using numerical methods if possible (see evalf/Int). Symbolic integration will be used if the limits are not floating-point numbers unless the numeric=true option is given."

But the alternate form also gave a numeric answer with 0..1,0..1 which is not expected, unless the floats in the integrand triggered this.

@mmcdara Very nice. Vote up. 

For axes=normal, the default, I don't know how to change this, but if you are OK with axes=boxed, then the labels are on the other side.

@C_R So even for polynomials allvalues will use radicals for cubics unless told not to. So to avoid radicals, and possible missed solutions, it should be possible to tell dsolve to use solve to get a RootOf. It turns out it is not so simple, but it can be done without as much done "by hand" as I did above.


dsolve without method

ode:=diff(y(x), x) = (3*x - y(x) + 1)/(3*y(x) - x + 5);

diff(y(x), x) = (3*x-y(x)+1)/(3*y(x)-x+5)

y(0) = 0

y(x) = -(-(1/36)*(x+1)^2*((-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-24*x-24)^2/(-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-x^3-x^2+x+1)/(x+1)^2

According to the help, (?dsolve,details), dsolve is sensitive to _EnvExplicit. so I expected this to work



but no


y(x) = -(-(1/36)*(x+1)^2*((-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-24*x-24)^2/(-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-x^3-x^2+x+1)/(x+1)^2

But if we dsolve implicitly, now solve will use RootOf. It seems to find each solution 3 times, but it doesn't miss any.


-(2/3)*ln(-(3+y(x)+x)/(x+1))-(1/3)*ln((-1-y(x)+x)/(x+1))-ln(x+1)+(2/3)*ln(3)+I*Pi = 0





Download RootOf_stuff_2.mw

@Axel Vogt Yes, I noticed that early on, but it was unclear about what exactly the poster wanted. If the poster can explain the practical range of x that they want the integral for I might be willing to look more closely. I've had success with method = _do1akc in the past with oscillating integrals. But non-dimensionalization would be a good first step; I doubt reliable numerics can be found with the parameters ranging from 10^23 to 10^(-37). m is set to 1 but I'm not sure if this is just a test parameter. If it is later to have very different values that also would make a big difference since it multiplies x.

We are still missing a value for x.

The first integral is problematic, since the integrand

(-epsilon^2/(4*a^2) - tau*epsilon^3)*(cos(epsilon*x) - 1)/epsilon^2

goes to infinity as epsilon goes to infinity because of the tau* epsilon^3. Is the first factor perhaps intended to be within an exp?

@Carl Love OK, thanks for that.

If you reorganize the dataframe so the your Data are the row labels (which seems logical to me but may not be what you want), then you can just select the rows and columns by indexing:

TestData[["LC3", "LC4", "LC5", "LC6", "LC7", "LC8", "LC9"], Load];


@C_R I think Maple intends polar to serve that purpose - you can do arithmetic with it, but you need evalc() or simplify() to get back to the Re/Im form.


a := convert(-2, polar)

polar(2, Pi)

b := convert(7, polar)

polar(7, 0)

a*b; simplify(%)

polar(2, Pi)*polar(7, 0)


a+b; simplify(%)

polar(2, Pi)+polar(7, 0)


c := convert(2+I, polar)

polar(5^(1/2), arctan(1/2))

a+c; simplify(%)

polar(2, Pi)+polar(5^(1/2), arctan(1/2))


d := convert(3+I, polar)

polar(10^(1/2), arctan(1/3))

a+d; simplify(%); evalc(%)

polar(2, Pi)+polar(10^(1/2), arctan(1/3))

-2+polar(10^(1/2), arctan(1/3))



Download polar.mw

@Carl Love Generally true of course, but the statement needs some qualification.

eq1 := x*y = 1

x*y = 1

ans := solve(eq1, {x, y})

{x = 1/y, y = y}

Sample solution

map(proc (q) options operator, arrow; lhs(q) = eval(rhs(q), y = 2) end proc, ans)

{x = 1/2, y = 2}


Download solve.mw

I am unable to reproduce this (Maple 2024, Windows 11). After the reformatting thw worksheet runs correctly.


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