dharr

Dr. David Harrington

8270 Reputation

22 Badges

20 years, 359 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

@emendes assuming real is implied by beta>0. You need rho>1. It works as modified below. Notice that solve may ignore the assumptions unless you add the "useassumptions" option for solve. However, the solution is in a different form suggesting that it does take some note of them. If you do use the "useassumptions" option, it fails to solve in a reasonable time.

So for this reason I only use assuming clauses after solve and never assume before.

restart;

assume(beta>0,xi[3]>0,xi[8]>0,rho>1);

eqqq := map(simplify,{sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2)/xi[8] = sqrt(beta*rho - beta), (-rho + 1 + sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2))/(xi[3]*xi[8] - 1) = sqrt(beta*rho - beta), -(-rho*xi[3]*xi[8] + sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2) + xi[3]*xi[8])/(xi[8]*(xi[3]*xi[8] - 1)) = rho - 1}):

In general, simplification on an expression to give zero is easier than comparing both sides of an equation. So I convert the equations to solve to expressions. (I could do this on the solutions after solving.)

eq3:=map(eq->(rhs-lhs)(eq),eqqq);

{0, beta^(1/2)*(rho-1)^(1/2)-(-rho+1+xi[8]*beta^(1/2)*(rho-1)^(1/2))/(xi[3]*xi[8]-1), rho-1-(-beta^(1/2)*(rho-1)^(1/2)+xi[3]*(rho-1))/(xi[3]*xi[8]-1)}

sol:=solve(eq3,{xi[8],xi[3]});

Warning, solve may be ignoring assumptions on the input variables.

{xi[3] = RootOf((beta^(1/2)*rho-beta^(1/2))*_Z^2+(-beta^(1/2)*rho-beta*(rho-1)^(1/2)+(rho-1)^(1/2)*rho+beta^(1/2)-(rho-1)^(1/2))*_Z-beta^(1/2)*rho+beta*(rho-1)^(1/2)+beta^(1/2)), xi[8] = -(-RootOf((beta^(1/2)*rho-beta^(1/2))*_Z^2+(-beta^(1/2)*rho-beta*(rho-1)^(1/2)+(rho-1)^(1/2)*rho+beta^(1/2)-(rho-1)^(1/2))*_Z-beta^(1/2)*rho+beta*(rho-1)^(1/2)+beta^(1/2))*(rho-1)^(1/2)+beta^(1/2)-(rho-1)^(1/2))/(RootOf((beta^(1/2)*rho-beta^(1/2))*_Z^2+(-beta^(1/2)*rho-beta*(rho-1)^(1/2)+(rho-1)^(1/2)*rho+beta^(1/2)-(rho-1)^(1/2))*_Z-beta^(1/2)*rho+beta*(rho-1)^(1/2)+beta^(1/2))*(rho-1)^(1/2))}

simplify(subs(sol,eq3));

{0}

sol:=solve(eq3,{xi[8],xi[3]},useassumptions);

Download solve.mw

@Saalehorizontale It's a bug. I put it in a loop and for some reason the 9th one gives a problem (after verifying that index = 2 is correct). I have submitted a bug report.

RootOf_with_Error.mw

@Saalehorizontale Sorry, I mislead you. For a RootOf without an index, the index=1 is implied for evalf or other contexts. But you are right that it can be any of the roots of the minimal polynomial, which was just a polynomial until I turned it into a RootOf. You can check through the roots of the minimal polynomial with an exact calculation without having to worry about numerical issues; see attached.

RootOf.mw

@Carl Love @acer Thanks for the clarification; I've had that misconception for a long time. But why not have the output of p:=plot(...); the same as the actual plot? In most cases p:=foo(..); p; would give duplicate outputs.

@Saalehorizontale If not specified, it is the index = 1 root. I added a line to my answer above to check that. The order is given in the ?RootOf,indexed help page

@Alfred_F A bit more, with a nice example at the end.

restart

z := tan(3*Pi/x)+4*sin(2*Pi/x)-sqrt(x)

tan(3*Pi/x)+4*sin(2*Pi/x)-x^(1/2)

Exact

simplify(eval(z, x = 11))

0

Change 4 to 4. (or 4.0 if you prefer

zf := tan(3*Pi/x)+4.*sin(2*Pi/x)-sqrt(x)

tan(3*Pi/x)+4.*sin(2*Pi/x)-x^(1/2)

Approximate answer

ansf := evalf(eval(zf, x = 11))

0.1e-8

If it is just roundoff error, fnormal will convert it to 0.  - notice the ".", but it is still not evidence of a true zero.

fnormal(ansf)

0.

The following is not 1, though it looks like it with default 10 digit calculations

q := -cos(Pi*cos(Pi*cos(ln(Pi+20)))); evalf(q)

-cos(Pi*cos(Pi*cos(ln(Pi+20))))

1.

Force 40 digit calculation accuracy

evalf[40](q)

.9999999999999999999999999999999999606784

NULL

Download floats.mw

@Ronan I usually copy the URL here so you can give it as additional information. Then go to the "more" tab on mapleprimes and choose submit software change request. Maple employees may notice stuff here, but I would submit the SQR anyway, just in case.

I get the same one-page result as you for both 2024 and 2025; both through exporting as .pdf or printing to the Adobe print driver. (Mac .pdf generation is different I believe.)

I agree with @nm that it's a bug. The following works and is shorter:

B:=<seq(A)>;

@JaneCherrytree Thanks. My point was to simplify the expression as much as possible before integrating, and in particular getting rid of square roots, but if it is correct then we have to live with the square root. What can we assume about the signs of the variables? Are they all positive?

You have

t1 := r*cos(phi);
t22 := (1 - s)*sqrt(1 - t1*t1) + s*t2;

So  sqrt(1 - t1*t1) = sqrt(1 -r^2*cos(phi)^2) seems wrong from a dimensional point of view since r^2*cos(phi)^2 has dimensions if r^2 and is subtracted from dimensionless 1. Is it supposed to be sqrt(r^2 -r^2*cos(phi)^2), which would simplify to r*sin(phi)

@salim-barzani

Quoting @mmcdara:

"This is for the simple reason that I can neither figure out what you're trying to achieve, nor be able to find a relationship between what you say in this reply and the code you provide."

"I hope you can find someone smarter than [us - me and @mmcdara ] - to help you.
Good luck"

@salim-barzani Please explain exactly in your worksheet sys.mw where eq1 comes from. I suggest you highlight the terms in red (in P?, E3?, somewhere else?) to show where they are. You presumably cut and pasted them from somewhere so you can highlight that place.

@salim-barzani So you don't want alpha_i and beta_i in the equation for U? What two terms are you talking about?

@salim-barzani So you want to generate these equations eq0..eq10? This can be done with the collect(...,'distributed'); coeffs(.., 'monomials'); and then if you put the monomials in a table you can pick out the monomials you want. This code you have seen before. I don't see what this has to do with factoring.

4 5 6 7 8 9 10 Last Page 6 of 86