How to ask SOLVE nicely?



-----maxima-bounces at math.utexas.edu wrote: -----

>I define
>
>========
>m : 10*q/sqrt(q^2 + 3) - 5*q^3/(q^2+3)^(3/2);
>========
>and I want to find q such that
>
>m = 5.07

Not ideal, but this is the best that I can think of.
The term sqrt(q^2+3) causes trouble for solve. So
let's do subst q^2 + 3 --> z^2.

(%i1) eq0 : 10*q/sqrt(q^2 + 3) - 5*q^3/(q^2+3)^(3/2) - 507/100$
(%i2) eq1 : num(ratsubst(z,sqrt(q^2+3),eq0))$
(%i3) eq2 : [eq1,z^2=q^2+3]$
(%i4) eq2 : map(lhs,eq2) - map(rhs,eq2);
(%o4) [-507*z^3+1000*q*z^2-500*q^3,z^2-q^2-3]
(%i5) sol : solve(eq2,[q,z]);
(%o5)
[[q=1.4239622270312808,z=2.2422464375523887],[q=2.2012012530882625*%i+3.6201499951379152*10^-17,

z=-1.3584133967969165*%i-5.866166164471163
*10^-17],[q=3.6201499951379152*10^-17-2.2012012530882625*%i,z=
1.3584133967969165*%i-5.866166164471163
*10^-17],[q=-1.4239622270312808,z=-2.2422464375523887],[q=
10.010778443113772,z=10.1595124536301],[q=-10.010778443113772,z=-10.1595124536301]]


Some of these solutions might be spurious; let's delete the bad solutions:

(%i6) subset(setify(sol), lambda([s], is(abs(subst(s,eq0)) < 1.0e-10)));
(%o6) {}

Yikes! No solutions.  Try again:

(%i7) subset(setify(sol), lambda([s], is(abs(subst(s,eq0)) < 1.0e-5)));
(%o7)
{[q=1.4239622270312808,z=2.2422464375523887],[q=10.010778443113772,z=10.1595124536301]}


A picture shows that the graph of eq0 isn't all that steep near 1.4 and
10.15. That
explains why the filer in %i6 gave no solutions. To draw the graph do:

(%i8) plot2d(eq0,[q,0,12]);
(%o8)

If you really want a symbolic answer, here is one way to do that.

(%i9) eq3 : resultant(eq2[1],eq2[2],z);
(%o9) -7049*q^6+686559*q^4+2059677*q^2-6940323
(%i10) sol2 : solve(eq3,q);

(huge mess deleted)

If you do float(rectform(sol2)), you'll get

(%o12) [q=-10.010778646766727,q=10.010778646766727,q=-2.2012012530882612
*%i,q=2.2012012530882612*%i,
q=-1.4239622503267211,q=1.4239622503267211]

The solution q=-10.01.. is spurious; I don't know if the two non-real
solutions are true solutions.

Barton