Solve gives incorrect solutions for polynomial

96 views
Skip to first unread message

Francis Banks

unread,
Nov 6, 2016, 10:00:30 AM11/6/16
to sage-support

I am solving a polynomial which arises from plotting titration cures in chemistry. The rule of signs suggests it has one positive root. Find_root seems to find it. Solve with poly_solve=true does not. Instead it gives 4 complex roots, which don't appear to satisfy the equation. They do not even form two conjugate pairs. Here is some code which illustrates the problem:

var('Kb','b0','K1','Ks','a0')
fx(x)=-Kb*x^4 - (b0*Kb + K1*Kb + Ks)*x^3 - (b0*K1*Kb - a0*K1*Kb + K1*Ks - Kb*Ks)*x^2 + (a0*K1*Ks + K1*Kb*Ks + Ks^2)*x + K1*Ks^2

fx(x)=fx.subs(K1=10^-2.15,Ks=10^-14,Kb=10^5.0,a0=0.1,b0=0)
s=find_root(fx,0,0.025,1E-14)
show(s)
s1=solve(fx,x,to_poly_solve=true)
show('roots from solve: ',N(s1[0].rhs(),3));show(N(s1[1].rhs(),3));show(N(s1[2].rhs(),3));show(N(s1[3].rhs(),3))
show('Substituting first root from solve: ',N(fx(s1[0].rhs()),10))
show('Substituting first root from find_root: ',N(fx(s),10))
plot(fx,0.001,0.03)


Can someone shed light on this?

Dima Pasechnik

unread,
Nov 6, 2016, 2:20:36 PM11/6/16
to sage-support
You are working very close to the numerical precision allowed by the usual float doubles (in particular with Ks^2 being 10^(-28)).
With degree 4 polynomials you might be better off using the exact formulae for their roots.

 

slelievre

unread,
Nov 8, 2016, 9:45:00 AM11/8/16
to sage-support
Sun 2016-11-06 16:00:30 UTC+1, Francis Banks:
This is a very good question for Ask Sage, would you ask it there?

https://ask.sagemath.org/

Simon King

unread,
Nov 9, 2016, 3:38:03 AM11/9/16
to sage-s...@googlegroups.com
On 2016-11-08, slelievre <samuel....@gmail.com> wrote:
> This is a very good question for Ask Sage, would you ask it there?

Why should he? He did ask here. And I, for one, dislike the Ask Sage
pages to the extent that I wouldn't answer questions there.

Cheers,
Simon

Emmanuel Charpentier

unread,
Nov 9, 2016, 9:45:38 AM11/9/16
to sage-support
A bit of numerical analysis (see enclosed Jupyter notebook) proves that this polynomial has at least two real roots, and quite probably four), one of them being positive.

This triggers the question : does Sage have built-in facilities for uncertainty computation ("calcul d'erreurs" in French, but I don't know the accepted English idiom) ? That's an non-negligible part of any numerical analysis...

HTH,

--
Emmanuel Charpentier
An obstinate polynomial.ipynb

kcrisman

unread,
Nov 9, 2016, 12:38:14 PM11/9/16
to sage-support



> This is a very good question for Ask Sage, would you ask it there?

Why should he? He did ask here. And I, for one, dislike the Ask Sage
pages to the extent that I wouldn't answer questions there.

Interesting.   If you have ideas on how to improve it so that you might do so, please start a thread on sage-devel about that.  If you'd rather not start such a thread, that's fine too, I just haven't heard anybody mention that before so it would be useful to know.  

I find it a lot easier to help people there, myself, just because of the interface, but I'm very glad we have both options - one alone would not suffice.

Simon King

unread,
Nov 10, 2016, 6:06:08 AM11/10/16
to sage-s...@googlegroups.com
Hi Karl-Dieter,

On 2016-11-09, kcrisman <kcri...@gmail.com> wrote:
>> > This is a very good question for Ask Sage, would you ask it there?
>>
>> Why should he? He did ask here. And I, for one, dislike the Ask Sage
>> pages to the extent that I wouldn't answer questions there.
>>
>
> Interesting. If you have ideas on how to improve it so that you might do
> so, please start a thread on sage-devel about that.

I don't. I have expressed my dislike of AskSage as soon as it was
available. It is just that I don't like all these badges and awards and
I don't like the fact that I need a web browser and a good internet
connection to use the page. I prefer a list such as sage-devel or
sage-support that I can use with slrn and with my mobile broadband (or
rather "narrow band") stick.

> I find it a lot easier to help people there, myself, just because of the
> interface,

For the exact same reason I prefer sage-support...

In any case, I believe if a user asks on sage-support then it is
impolite to ask him/her to go to AskSage and ask the question again, rather
than answering his/her question right away.

Best regards,
Simon


John Cremona

unread,
Nov 10, 2016, 6:51:29 AM11/10/16
to SAGE support
Sage has two sources of support, the mailing list sage-support and the
AskSage site. Users and helpful developers can use whichever they
choose, and I don't think that any of us should be telling anyone
which one they ought to use, either as an asker of questions or as a
helpful answerer. Of course someone might use one system to ask their
question while the best person to answer it only uses the other
system, but that is hardly a disaster.

I suggest that this thread be closed (or reopened on sage-devel under
an appropriate name). The original poster has had an answer and night
want to follow it up, something which the rest of this thread is not
helping.
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

kcrisman

unread,
Nov 10, 2016, 1:50:09 PM11/10/16
to sage-support

>
> Interesting.   If you have ideas on how to improve it so that you might do
> so, please start a thread on sage-devel about that.

I don't. I have expressed my dislike of AskSage as soon as it was
available. It is just that I don't like all these badges and awards and
I don't like the fact that I need a web browser and a good internet
connection to use the page. I prefer a list such as sage-devel or
sage-support that I can use with slrn and with my mobile broadband (or
rather "narrow band") stick.


Those are excellent reasons!  No new thread needed, then (and John, sorry for hijacking this one).
 
> I find it a lot easier to help people there, myself, just because of the
> interface,

For the exact same reason I prefer sage-support...

In any case, I believe if a user asks on sage-support then it is
impolite to ask him/her to go to AskSage and ask the question again, rather
than answering his/her question right away.

Indeed.  Occasionally with a very involved request on AskSage I recommend going to sage-support, but that is because the interfaces are not simply interchangeable, as you note.  Thanks for the clarification! 


 

William Stein

unread,
Nov 14, 2016, 3:15:32 PM11/14/16
to sage-support
On Thu, Nov 10, 2016 at 3:04 AM, Simon King <simon...@uni-jena.de> wrote:
> Hi Karl-Dieter,
>
> On 2016-11-09, kcrisman <kcri...@gmail.com> wrote:
>>> > This is a very good question for Ask Sage, would you ask it there?
>>>
>>> Why should he? He did ask here. And I, for one, dislike the Ask Sage
>>> pages to the extent that I wouldn't answer questions there.
>>>
>>
>> Interesting. If you have ideas on how to improve it so that you might do
>> so, please start a thread on sage-devel about that.
>
> I don't. I have expressed my dislike of AskSage as soon as it was
> available. It is just that I don't like all these badges and awards and

I agree. Somebody just asked me to look at an AskSage post, and I
did. I filled out the available answer form, and it says "you can't
answer until you sign in". So -- having been burned before -- I
copied what I wrote first, then clicked to sign in. I then signed in
under what i thought was my usual account, and had to search around to
find the question again. I answered it, then clicked submit, and it
just put in big yellow some message refusing my submission. I
refreshed and confirmed that my account has 2069 karma. I tried to
answer again and it just doesn't respond. I see now that might
account is blocked for some reason when trying to upvote something
else (see screenshot). So I give up. AskSage is really outside of my
workflow (which is email).


> I don't like the fact that I need a web browser and a good internet
> connection to use the page. I prefer a list such as sage-devel or
> sage-support that I can use with slrn and with my mobile broadband (or
> rather "narrow band") stick.
>
>> I find it a lot easier to help people there, myself, just because of the
>> interface,
>
> For the exact same reason I prefer sage-support...
>
> In any case, I believe if a user asks on sage-support then it is
> impolite to ask him/her to go to AskSage and ask the question again, rather
> than answering his/her question right away.
>
> Best regards,
> Simon
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



--
William (http://wstein.org)
Screen Shot 2016-11-14 at 12.13.48 PM.png
Reply all
Reply to author
Forward
0 new messages