dharr

Dr. David Harrington

8345 Reputation

22 Badges

21 years, 6 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 retired professor of chemistry at the University of Victoria, BC, Canada. 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

@sursumCorda Yes, thanks for pointing that out; I missed the distnctness aspect. You could separately do the cases of 1, 2 and 3 distinct roots, but I suppose postprocessing is required.

dec1 := RealRootClassification([f], [], [x], [p, q, r], 3, 1, R);
dec2 := RealRootClassification([f], [], [x], [p, q, r], 3, 2, R);
dec3 := RealRootClassification([f], [], [x], [p, q, r], 3, 3, R);

The [p,q,r] was to look only for cases where these are non-zero, but seems to make no difference here over []. However, when I was playing with RealTrangularize there was a difference between [p,q,r] and [], so I'm confused about this. 

discrim(f,x) is zero iff there exist multiple roots, so that may also help. Here it is just the now familiar

 -4*p^3*r + p^2*q^2 + 18*p*q*r - 4*q^3 - 27*r^2

and Descarte's rule of signs is useful in this case, though you did want it without polynomials theory.

@dharr This is very close, but has the condition p^2*q + 3*p*r - 4*q^2>0 instead of q<0 - perhaps they are equivalent but that wasn't immediately obvious to me.

restart

with(RegularChains); with(ParametricSystemTools)

f := p*x^2+x^3+q*x+r

p*x^2+x^3+q*x+r

R := PolynomialRing([x, p, q, r])

polynomial_ring

Solve f for solutions with x>0 and p,q,r non-zero and 3 real roots.
We find the correct main condition and  r<0, p<0, but the condition on q is more complicated

dec := RealRootClassification([f], [], [x], [p, q, r], 3, 3, R)

Display(dec, R)

[[Typesetting:-mrow(Typesetting:-mi("r"), Typesetting:-mo("&lt;"), Typesetting:-mn("0")) and Typesetting:-mrow(Typesetting:-mi("p"), Typesetting:-mo("&lt;"), Typesetting:-mn("0")) and Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-msup(Typesetting:-mi("p"), Typesetting:-mn("2")), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("q")), Typesetting:-mo("&plus;"), Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("r"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("p")), Typesetting:-mo("&minus;"), Typesetting:-mrow(Typesetting:-mn("4"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typesetting:-mi("q"), Typesetting:-mn("2")))), Typesetting:-mo("&gt;"), Typesetting:-mn("0")) and Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("4"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typesetting:-mi("p"), Typesetting:-mn("3")), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("r")), Typesetting:-mo("&minus;"), Typesetting:-mrow(Typesetting:-msup(Typesetting:-mi("p"), Typesetting:-mn("2")), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typesetting:-mi("q"), Typesetting:-mn("2"))), Typesetting:-mo("&minus;"), Typesetting:-mrow(Typesetting:-mn("18"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("q"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("r"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("p")), Typesetting:-mo("&plus;"), Typesetting:-mrow(Typesetting:-mn("4"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typesetting:-mi("q"), Typesetting:-mn("3"))), Typesetting:-mo("&plus;"), Typesetting:-mrow(Typesetting:-mn("27"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typesetting:-mi("r"), Typesetting:-mn("2")))), Typesetting:-mo("&lt;"), Typesetting:-mn("0"))], [p, r, p^2*q+3*p*r-4*q^2, -4*p^3*r+p^2*q^2+18*p*q*r-4*q^3-27*r^2]]

NULL

Download cubic2.mw

Setting all variables to 1 shows that the odetest result cannot be zero

q := odetest(G, F4);
eval(q, indets(q, name) =~ 1);

Since many of your equations are set up by pasting output, it's possibly a cut and paste error, but that makes it nearly impossible to diagnose.

@Saha So you will need to make a loop changing the L values. Each time though the loop use dsolve and find Q, and store L^2 and Q in Vectors. Then you can use pointplot to plot the vector of Q values vs the vector of L^2 values.

Your worksheet doesn't have theta, so I'm guessing you want f'(1). The output of dsolve can be used to get this, e.g., c1(1) gives

[x = 1., f(x) = 1.00000000000000, diff(f(x), x) = 0.294118092731875] 

and so to extract the value 0.294118092731875 use eval(diff(f(x), x), c1(1)).

@Carl Love I added a 60 Digit calculation to the 30 digit one

evalf[30](eval([p, sinnx, p - sinnx], x = -1.95));
evalf[60](eval([p, sinnx, p - sinnx], x = -1.95));

 (errors (p-sinnx) ca. 10^(-13) for 30 digits and 10^(-43) for 60 digits.)

At 30 digits I was thinking there was a true error because Maple usually does much better than half the digits correct. But since the functions are identical, I increased to 60, which shows how poor the 30 Digit one was.

@Carl Love Thanks for the resolution of the identical/approx issue. Nice solution for the plot - vote up.

@FDS I get the same as you on Maple 2024.1 on Windows. Opening the Excel file in Excel (Office 365) everything looks fine. So that is a mystery; perhaps contact technical support. 

@vv On my Maple 2024.1, I get the same as you got on Maple 2018.

@FDS So why not upload a small excel file that doesn't work for you, to see if we get the same results, or can figure out if there is something about your file that might make a difference.

@felixiao You mean you want to find that there are three peaks? This is a nontrivial task - you need to numerically differentiate the data and then find where it crosses zero. It is easiest to do this visually - use the plot probe to see the max values and where they occur. I just split the data into ranges and did the max on each. You can use max[index] to find which N value the maximum occurs at.

MMSE_2re.mw

@felixiao Please upload the worksheet finding the maximum of KR[N].

I don't know an automatic way to get the indenting. I usually do this manually within the startup code window, with a bunch of "enter", "tab" and "delete". As a bonus, the diagnostics pane at the bottom tells you about unused variables etc (no errors in this case though).

For killing command completion, look at the choices under tools -> options -> interface.

@emendes try

procnames:=select(type,[anames('user')],procedure)[];
save procnames, cat(currentdir(),"/myprocs.mpl");

 

@FDS I think @Thomas Richard is asking you what happens if you use his method on your Excel file.

First 20 21 22 23 24 25 26 Last Page 22 of 87