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 answers submitted by dharr

Do you want b to be an integer? Maple's RootOf for polynomials (where all the powers are integers can be quite useful), but for more complicated cases like here where b is not necessarily integer, there are probably only a few things one can do. The attached explores some of the parameter space.

Roots_of_a_Polynomial.mw

When you solved with the inequalities, solve returned a RootOf with a range to say which of the roots to use, which was the one evalf produced, and which presumably satisfies the equations and inequalities.

When you solved with just the equations, solve returned a generic RootOf, which stands for all roots, but evalf gives only the first. If you use allvalues and then evalf, you will get all possibilities, and the 7th one is the one that agrees with the earlier solve.

problems_with_solve_15.10.24.mw

iroot is much faster, but it gives the closest integer, not the floor, so there may be a digit difference.

Edit: floor(root(evalf(n), 3)) is faster yet, but needs appropriately high Digits.

restart;

Digits:=50;

50

n := 33333333333333333333333333333333333444444444444444444;
CodeTools:-Usage(floor(root(evalf(n), 3)),iterations=1000);
CodeTools:-Usage(floor(root(n, 3)),iterations=1000);
CodeTools:-Usage(iroot(n, 3, 'exact'),iterations=1000);
exact;

33333333333333333333333333333333333444444444444444444

memory used=1.75KiB, alloc change=0 bytes, cpu time=16.00us, real time=16.00us, gc time=0ns

321829794868543252

memory used=29.20KiB, alloc change=0 bytes, cpu time=172.00us, real time=355.00us, gc time=0ns

321829794868543252

memory used=7.45KiB, alloc change=28.99MiB, cpu time=47.00us, real time=85.00us, gc time=46.88us

321829794868543253

false

Check

Digits := 50;
root(evalf(n),3);

50

321829794868543252.61997759481168897289518515510196

 

Download iroot.mw

Since you want your answer in terms of h1 and h2, you want to solve for the other variables.

ans := solve({v1^2 = 2*g*(h-h1), (1/2)*g*t^2 = h2, v1*t+(1/2)*g*t^2 = h1}, {g, h, v1})

{g = 2*h2/t^2, h = (1/4)*(h1^2+2*h1*h2+h2^2)/h2, v1 = (h1-h2)/t}

simplify(ans)

{g = 2*h2/t^2, h = (1/4)*(h1+h2)^2/h2, v1 = (h1-h2)/t}

NULL

Download Expression_of_NLP_with_desired_parameters.mw

If you substitute the solve solutions back into the equation, you find that (except for the trivial solution), they are not actually solutions. On the other hand, fsolve gives an accurate solution for one range I tried (I was assuming you wanted a positive solution). Since you want a numerical solution, fsolve is preferred.

By the way, your second equation is c__3*(expression), so c__3 = 0 always works. If that is a solution you are not interested in, then I would change that to just (expression); then it may be easier to get a solution without c__3 = 0.

question11.mw

Aside from the 2I, there is a 6I (interpreted correctly anyway), and then missing spaces after a C1 and an h3 which makes them into unknown functions. Then since everything else is real you can use evalc() or evalc(Re())

real_and_imaginary_.mw

As the others have pointed out the sum involves roots of a degree 4 polynomial. If you put some values in, then this will give you directly what you want. (I used some random values so didn't get realistic output.)

Download RootOf.mw

Not sure what happened. Here's a way to get around that. Probably simpler to combine all constants into A and B at the beginning.

Download odes.mw

Something like this? (The matrices don't show on Mapleprimes; download the worksheet and run to see them.)

restart

with(LinearAlgebra)

A := `<,>`(`<|>`(2*x, z), `<|>`(-2*x-2, x-2)); B := `<,>`(`<|>`(4*y, 2*y), `<|>`(w, 3))

Matrix(2, 2, {(1, 1) = 2*x, (1, 2) = z, (2, 1) = -2*x-2, (2, 2) = x-2})

Matrix(%id = 36893490406780077108)

Meqns := A-B-IdentityMatrix(2)

Matrix(%id = 36893490406780082884)

By default solve assumes =0

eqns := convert(Meqns, set); solve(eqns)

{x-6, z-2*y, -2*x-2-w, 2*x-4*y-1}

{w = -14, x = 6, y = 11/4, z = 11/2}

 

 

Download eqns.mw

(For the more usual A.x = b with A a matrix of constants, x a vector of variables and b a vector of constants, use LinearSolve)

For future reference, please upload your worksheet with the green up-arrow in the Mapleprimes editor.
Your nested piecewise expression can be changed to a regular piecewise by simplify(..., piecewise).
You need to solve for y not y_.
Since you want a numerical solution, use fsolve, not solve.
Then it solves and gives the solution 0. You are asking when your piecewise expression 2*AA_=A_, but one of the conditions on each side is that it is 0 for y<=0, and so y=0 is a correct solution.

fsolve.mw

restart;

f:=(deltab*(-2*ub^2*mu*M^2*deltab*((-2+deltab)*(3/4+(phi0-1/2)*kappa)*(kappa-1/2)*M^4-(5*((alpha^2-6/5)*phi0*(kappa-1/2)*deltab+((-9/5*phi0-1/5)*alpha^2+13/5*phi0)*kappa+(11/10*phi0+3/10)*alpha^2-13/10*phi0))*(3/2+phi0-kappa)*M^2-2*alpha^2*phi0*(3/2+phi0-kappa)^2)*(3/2+phi0-kappa)*sqrt(1/(mu*ub^2))+sqrt(2)*(((3*(((mu*ub^2+2/3)*kappa^2+(-(2/3*mu)*ub^2-1)*kappa+(1/12)*mu*ub^2)*deltab^2-4*ub^2*mu*(kappa-1/6)*(kappa-1/2)*deltab+4*ub^2*mu*(kappa-1/6)*(kappa-1/2)))*(kappa-1/2)*M^6+(10*((alpha^2-6/5)*((mu*ub^2+1)*kappa-(1/2)*mu*ub^2-3/2)*deltab^2-(14/5*(ub^2))*mu*((alpha^2-12/7)*kappa-13/14*(alpha^2)+1)*deltab+(8/5*((alpha^2-3)*kappa-2*alpha^2+2))*ub^2*mu))*(kappa-3/2)*(kappa-1/2)*M^4-8*ub^2*mu*(alpha^2*(kappa-1/2)*deltab-3*alpha^2*kappa-(1/2)*kappa+1/4)*(kappa-3/2)^2*M^2-8*ub^2*mu*alpha^2*(kappa-3/2)^3)*(-phi0)^(3/2)+(2*kappa^2*deltab^2*(kappa-1/2)*M^6+(10*((alpha^2-6/5)*(2*kappa^2+(mu*ub^2-2)*kappa-(1/2)*mu*ub^2-3/2)*deltab^2-(14/5*(ub^2))*((alpha^2-12/7)*kappa-6/7*(alpha^2)+15/14)*mu*deltab+(8/5*(ub^2))*((alpha^2-3)*kappa-7/4*(alpha^2)+9/4)*mu))*(kappa-1/2)*M^4-(16*(-(1/8)*alpha^2*(kappa-3/2)*(kappa-1/2)*deltab^2+mu*ub^2*alpha^2*(kappa-1/2)*deltab-3*ub^2*mu*((alpha^2+1/6)*kappa-(1/4)*alpha^2-1/12)))*(kappa-3/2)*M^2-24*ub^2*mu*alpha^2*(kappa-3/2)^2)*(-phi0)^(5/2)+(20*kappa*(alpha^2-6/5)*deltab^2*(kappa-1/2)*M^4+(4*alpha^2*(kappa-3/2)*(kappa-1/2)*deltab^2-8*mu*ub^2*alpha^2*(kappa-1/2)*deltab+24*ub^2*((alpha^2+1/6)*kappa-(1/3)*alpha^2-1/12)*mu)*M^2-24*ub^2*mu*alpha^2*(kappa-3/2))*(-phi0)^(7/2)+(2*(deltab^2*(kappa-1/2)*M^2-4*mu*ub^2))*alpha^2*(-phi0)^(9/2)+((((mu*ub^2+1/2)*kappa-(1/2)*mu*ub^2-3/4)*deltab^2-4*ub^2*mu*(kappa-1/2)*deltab+4*ub^2*mu*(kappa-1/2))*(kappa-1/2)*M^4+2*ub^2*mu*(alpha^2+1)*(-2+deltab)*(kappa-3/2)*(kappa-1/2)*M^2+4*ub^2*mu*alpha^2*(kappa-3/2)^2)*M^2*sqrt(-phi0)*(kappa-3/2)))*sqrt(-phi0/(mu*ub^2))+(1/2*((((mu*phi0*ub^2-2*(phi0-1/2)^2)*kappa^2+(3/2-3*phi0-mu*phi0*ub^2)*kappa-9/8+(1/4)*mu*phi0*ub^2)*deltab^2-4*ub^2*mu*phi0*(kappa-1/2)^2*deltab+4*ub^2*mu*phi0*(kappa-1/2)^2)*M^4-(2*(-(10*(alpha^2-6/5))*(3/4+(phi0-1/2)*kappa)*deltab^2+ub^2*mu*(alpha^2+1)*(kappa-1/2)*deltab-2*ub^2*mu*(alpha^2+1)*(kappa-1/2)))*phi0*(3/2+phi0-kappa)*M^2+4*alpha^2*(mu*ub^2-(1/2)*deltab^2*phi0)*phi0*(3/2+phi0-kappa)^2))*M^2*deltab*sqrt(2)*(3/2+phi0-kappa)*sqrt(1/(mu*ub^2))+(-(((mu*ub^2+4)*kappa^2+(-mu*ub^2-7)*kappa+(1/4)*mu*ub^2+3/2)*deltab^2-4*ub^2*mu*(kappa-1/2)^2*deltab+4*ub^2*mu*(kappa-1/2)^2)*(-2+deltab)*(kappa-1/2)*M^6-(2*((5*(alpha^2-6/5))*(kappa-3/2)*(kappa-1/2)*deltab^3+((ub^2*(alpha^2+2)*mu-8*alpha^2+14)*kappa^2+(-ub^2*(alpha^2+2)*mu-53/2+16*alpha^2)*kappa+(1/4)*ub^2*(alpha^2+2)*mu-6*alpha^2+33/4)*deltab^2-4*ub^2*mu*(alpha^2+2)*(kappa-1/2)^2*deltab+4*ub^2*mu*(alpha^2+2)*(kappa-1/2)^2))*(kappa-3/2)*M^4-(8*(-(1/2)*alpha^2*(kappa-3/2)*deltab^2+ub^2*(alpha^2+1/2)*mu*(kappa-1/2)*deltab-2*ub^2*(alpha^2+1/2)*mu*(kappa-1/2)))*(kappa-3/2)^2*M^2-8*ub^2*mu*alpha^2*(kappa-3/2)^3)*(-phi0)^(3/2)+(-6*kappa*(-2+deltab)*deltab^2*(kappa-1/3)*(kappa-1/2)*M^6+(-40*kappa*(alpha^2-6/5)*(kappa-3/2)*(kappa-1/2)*deltab^3+((60*alpha^2-88)*kappa^3+(-2*ub^2*(alpha^2+2)*mu-134*alpha^2+180)*kappa^2+(2*ub^2*(alpha^2+2)*mu+73*alpha^2-77)*kappa-(1/2)*ub^2*(alpha^2+2)*mu-21/2*(alpha^2)+15/2)*deltab^2+8*ub^2*mu*(alpha^2+2)*(kappa-1/2)^2*deltab-8*ub^2*mu*(alpha^2+2)*(kappa-1/2)^2)*M^4-(16*(kappa-3/2))*((1/8)*alpha^2*(kappa-3/2)*(kappa-1/2)*deltab^3-(5/4*(alpha^2))*(kappa+1/10)*(kappa-3/2)*deltab^2+ub^2*(alpha^2+1/2)*mu*(kappa-1/2)*deltab-2*ub^2*(alpha^2+1/2)*mu*(kappa-1/2))*M^2-24*alpha^2*(((1/6)*kappa-1/4)*deltab^2+mu*ub^2)*(kappa-3/2)^2)*(-phi0)^(5/2)+(-40*deltab^2*((alpha^2-6/5)*(kappa-1/4)*(kappa-1/2)*deltab+(-3/2*(alpha^2)+11/5)*kappa^2+(3/2*(alpha^2)-19/10)*kappa-3/8*(alpha^2)+17/40)*M^4+(-4*alpha^2*(kappa-3/2)*(kappa-1/2)*deltab^3+40*alpha^2*(kappa-1/5)*(kappa-3/2)*deltab^2-8*ub^2*(alpha^2+1/2)*mu*(kappa-1/2)*deltab+16*ub^2*(alpha^2+1/2)*mu*(kappa-1/2))*M^2-24*alpha^2*(kappa-3/2)*(((1/2)*kappa-3/4)*deltab^2+mu*ub^2))*(-phi0)^(7/2)-2*alpha^2*(((kappa-1/2)*deltab-10*kappa+3)*deltab^2*M^2+(-9+6*kappa)*deltab^2+4*mu*ub^2)*(-phi0)^(9/2)-(1/2)*deltab^2*(8*alpha^2*(-phi0)^(11/2)+((-2+deltab)*(kappa-1/2)*M^2-3+2*kappa)*M^4*sqrt(-phi0)*(kappa-3/2)^2))*sqrt(-phi0/(mu*ub^2))*sqrt(-phi0^3)*Omega^2/(sqrt(-phi0)*sqrt(-phi0^3/(mu^3*ub^6))*ub^4*mu^2*(M^2*sqrt(-phi0)*deltab*sqrt(2)*(kappa-1/2)*sqrt(-phi0/(mu*ub^2))-(1/2)*M^2*deltab*sqrt(2)*(3/2+phi0-kappa)*sqrt(1/(mu*ub^2))-2*(-phi0)^(3/2)+(((-kappa+1/2)*deltab+2*kappa-1)*M^2+3-2*kappa)*sqrt(-phi0))^3*M^2):

Required form

f1:=(M^2-M1^2)/(M^2*(M^2-M0^2));

(M^2-M1^2)/(M^2*(M^2-M0^2))

limit(f1*M^2, M=infinity);

1

Find numerator and denominator high and low degrees. Could be (M^6-const)/(M^2*(M^6-const)) perhaps (but no, see below), but can't be of the expected form

f:=normal(f):
nf:=collect(numer(f),M):
degree(nf,M),ldegree(nf,M);
df:=collect(denom(f),M):
degree(df,M),ldegree(df,M);

6, 0

8, 2

Nonzero powers of M in the numerator and denominator for all even powers. We could factor the denominator into M^2(M^6 + ...) but that's about it.

seq([i,evalb(coeff(nf, M, i) <>0)], i = 6..0,-1);
seq([i,evalb(coeff(df, M, i) <>0)], i = 8..0,-1);

[6, true], [5, false], [4, true], [3, false], [2, true], [1, false], [0, true]

[8, true], [7, false], [6, true], [5, false], [4, true], [3, false], [2, true], [1, false], [0, false]

NULL

 

NULL

Download f1.mw

restart

Equation recast in form for ThueSolve

eq := -N*x*y+x^2+y^2 = N

-N*x*y+x^2+y^2 = N

Try for N=9;

eqN := eval(eq, N = 9)

x^2-9*x*y+y^2 = 9

Finds no solutions - for the quadratic case just passes to isolve, which is not up to the task.

NumberTheory:-ThueSolve(eqN)

[]

isolve(eqN)

Solve just solves the quadratic for arbirary y. But it is clear that if the discriminant were a square and y were even, then x would be integer.

ans := [solve(eqN)]

[{x = (9/2)*y+(1/2)*(77*y^2+36)^(1/2), y = y}, {x = (9/2)*y-(1/2)*(77*y^2+36)^(1/2), y = y}]

Want discriminant a square

deq2 := discrim((lhs-rhs)(eqN), x) = z^2

77*y^2+36 = z^2

This time we get 12 solutions, each in terms of an arbitrary integer variable _Z1

sols := [isolve(deq2)]; nops(%)

12

Look at the first solution, for say _Z1=1

test := simplify(eval(sols[1], _Z1 = 1))

{y = -240, z = -2106}

Find the corresponding x value

test2 := simplify(eval(ans[1], test))

{-240 = -240, x = -27}

And check it is a solution for the original equation

eval(eqN, `union`(test, test2))

9 = 9

From the form of the equation, changing the signs of x and y gives a positive solution.

soln := `~`[`=`]({x, y}, eval({-x, -y}, `union`(test, test2))); eval(eqN, %)

{x = 27, y = 240}

9 = 9

Check that the original form of the equation returns N

eval((x^2+y^2)/(x*y+1), soln)

9

For N=49

eqN := eval(eq, N = 49); ans := `~`[`=`]([x, x], [solve(eqN, x)]); deq2 := discrim((lhs-rhs)(eqN), x) = z^2; sols := [isolve(deq2)]; nops(%); test := simplify(eval(sols[1], _Z1 = 1)); test2 := {simplify(eval(ans[1], test))}; soln := `~`[`=`]({x, y}, eval({-x, -y}, `union`(test, test2))); eval(eqN, soln)

x^2-49*x*y+y^2 = 49

[x = (49/2)*y+(1/2)*(2397*y^2+196)^(1/2), x = (49/2)*y-(1/2)*(2397*y^2+196)^(1/2)]

2397*y^2+196 = z^2

12

{y = -16800, z = -822514}

{x = -343}

{x = 343, y = 16800}

49 = 49

For N=729

eqN := eval(eq, N = 729); ans := `~`[`=`]([x, x], [solve(eqN, x)]); deq2 := discrim((lhs-rhs)(eqN), x) = z^2; sols := [isolve(deq2)]; nops(%); test := simplify(eval(sols[1], _Z1 = 1)); test2 := {simplify(eval(ans[1], test))}; soln := `~`[`=`]({x, y}, eval({-x, -y}, `union`(test, test2))); eval(eqN, soln)

x^2-729*x*y+y^2 = 729

[x = (729/2)*y+(1/2)*(531437*y^2+2916)^(1/2), x = (729/2)*y-(1/2)*(531437*y^2+2916)^(1/2)]

531437*y^2+2916 = z^2

12

{y = -14348880, z = -10460294154}

{x = -19683}

{x = 19683, y = 14348880}

729 = 729

NULL

NULL

Download Thu.mw

For Var__phi you have Omega^2[  ... ] (The ] is at the end of the expression). What do the square brackets mean?

Is this supposed to be Omega^2*( ... ) or some unspecified function Omega( ... )^2 or something else.

Your second case can be done by

display(p2, pointplot(eval([x, y], sol[]), symbol = circle, symbolsize = 12, color = black))

Linear_System.mw

You are confused about the worksheet (*.mw) in which Maple runs, and the external text file of Maple commands that are read in to the worksheet (*.txt). Download the following two files to the same directory. Open the EKHAD.mw file by double-clicking (NOT the one you made) and follow the instructions (it has a bit more explanation). Hope this is clear.

EKHAD.mw

EKHAD.txt

(normally I would call the last one EKHAD.mpl, but the Mapleprimes site won't let me upload that, so EKHAD.txt will do.)

 

First 12 13 14 15 16 17 18 Last Page 14 of 82