1 | initial version |
I'm not sure what's happening here. If I don't do it quite the way you do, I get
sage: pz = solve(A == 0, p)
sage: pz
[p == -340/5007*sqrt(24168884910961) - 1671503750/5007, p == 340/5007*sqrt(24168884910961) - 1671503750/5007]
sage: pz[0].rhs()
-340/5007*sqrt(24168884910961) - 1671503750/5007
sage: pz[0].rhs().n()
-667666.665528360
sage: pz[1].rhs().n()
-0.100998502399307
Plotting this
sage: plot(A,-700000,100000)
seems to agree with these results.
2 | No.2 Revision |
Edit: I see your question. You are saying that plugging 67... in yields something not quite right. This is going to happen with floating point approximations, especially when we pass things to Maxima, which we do here. Maxima is turning the floats into fractions, essentially, which means things will get off a little bit with such constants.
The following will help you more:
sage: A.find_root(-700000,-500000)
-667666.66566816461
sage: sol = A.find_root(-700000,-500000)
sage: A(p=sol)
0.000000000000000
+++++ original
Another thing that might work is not trying to approximate symbolic solutions which come
I'm not sure what's happening here. If I don't do it quite the way you do, I get
sage: pz = solve(A == 0, p)
sage: pz
[p == -340/5007*sqrt(24168884910961) - 1671503750/5007, p == 340/5007*sqrt(24168884910961) - 1671503750/5007]
sage: pz[0].rhs()
-340/5007*sqrt(24168884910961) - 1671503750/5007
sage: pz[0].rhs().n()
-667666.665528360
sage: pz[1].rhs().n()
-0.100998502399307
Plotting this
sage: plot(A,-700000,100000)
seems to agree with these results.
3 | No.3 Revision |
Edit: I see your question. You are saying that plugging 67... in yields something not quite right. This is going to happen with floating point approximations, especially when we pass things to Maxima, which we do here. Maxima is turning the floats into fractions, essentially, which means things will get off a little bit with such constants.
The following will help you more:
sage: A.find_root(-700000,-500000)
-667666.66566816461
sage: sol = A.find_root(-700000,-500000)
sage: A(p=sol)
0.000000000000000
Second edit:
Based on the comment, I think you need to use higher-precision rings. I don't know if Maxima (which is what does our solve
command can do higher precision easily from within the Sage interface, though I am pretty sure it can do it. Here is one solution in Sage. No pun with ???? intended, as CC
is already defined in Sage as the 53 bit precision complex field.
sage: CCC = ComplexField(150)
sage: a = CCC(a)
sage: b = CCC(b)
sage: c = CCC(c)
sage: R.<z> = CCC['z']
sage: R
Univariate Polynomial Ring in z over Complex Field with 150 bits of precision
sage: B = a*z^2+b*z+c
sage: B
0.000014829461196243200000000000000000000000000000*z^2 + 9.9011384083045000000000000000000000000000000*z + 1.0000000000000000000000000000000000000000000
sage: type(B)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
sage: B.roots()
[(-667666.66566816452809456920010337455502540059, 1), (-0.10099850239767434102211890294234211348279429, 1)]
sage: B.subs(z=B.roots()[0][0])
-8.9931131544973785160672193466796947557173371e-41
I hope that provides enough accuracy for your needs!
+++++ original
Another thing that might work is not trying to approximate symbolic solutions which come
I'm not sure what's happening here. If I don't do it quite the way you do, I get
sage: pz = solve(A == 0, p)
sage: pz
[p == -340/5007*sqrt(24168884910961) - 1671503750/5007, p == 340/5007*sqrt(24168884910961) - 1671503750/5007]
sage: pz[0].rhs()
-340/5007*sqrt(24168884910961) - 1671503750/5007
sage: pz[0].rhs().n()
-667666.665528360
sage: pz[1].rhs().n()
-0.100998502399307
Plotting this
sage: plot(A,-700000,100000)
seems to agree with these results.
4 | No.4 Revision |
Edit: Second edit:
Based on the comment, I think you need to use higher-precision rings. I don't know if Maxima (which is what does our solve
command) can do higher precision easily from within the Sage interface, though I am pretty sure it can do it. Here is one solution in Sage. No pun with CCCP intended, as CC
is already defined in Sage as the 53 bit precision complex field.
sage: CCC = ComplexField(150)
sage: a = CCC(a)
sage: b = CCC(b)
sage: c = CCC(c)
sage: R.<z> = CCC['z']
sage: R
Univariate Polynomial Ring in z over Complex Field with 150 bits of precision
sage: B = a*z^2+b*z+c
sage: B
0.000014829461196243200000000000000000000000000000*z^2 + 9.9011384083045000000000000000000000000000000*z + 1.0000000000000000000000000000000000000000000
sage: type(B)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
sage: B.roots()
[(-667666.66566816452809456920010337455502540059, 1), (-0.10099850239767434102211890294234211348279429, 1)]
sage: B.subs(z=B.roots()[0][0])
-8.9931131544973785160672193466796947557173371e-41
I hope that provides enough accuracy for your needs!
++++Edit: I see your question. You are saying that plugging 67... in yields something not quite right. This is going to happen with floating point approximations, especially when we pass things to Maxima, which we do here. Maxima is turning the floats into fractions, essentially, which means things will get off a little bit with such constants.
The following will help you more:
sage: A.find_root(-700000,-500000)
-667666.66566816461
sage: sol = A.find_root(-700000,-500000)
sage: A(p=sol)
0.000000000000000
Second edit:
Based on the comment, I think you need to use higher-precision rings. I don't know if Maxima (which is what does our solve
command can do higher precision easily from within the Sage interface, though I am pretty sure it can do it. Here is one solution in Sage. No pun with ???? intended, as CC
is already defined in Sage as the 53 bit precision complex field.
sage: CCC = ComplexField(150)
sage: a = CCC(a)
sage: b = CCC(b)
sage: c = CCC(c)
sage: R.<z> = CCC['z']
sage: R
Univariate Polynomial Ring in z over Complex Field with 150 bits of precision
sage: B = a*z^2+b*z+c
sage: B
0.000014829461196243200000000000000000000000000000*z^2 + 9.9011384083045000000000000000000000000000000*z + 1.0000000000000000000000000000000000000000000
sage: type(B)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
sage: B.roots()
[(-667666.66566816452809456920010337455502540059, 1), (-0.10099850239767434102211890294234211348279429, 1)]
sage: B.subs(z=B.roots()[0][0])
-8.9931131544973785160672193466796947557173371e-41
I hope that provides enough accuracy for your needs!
+++++ original
Another thing that might work is not trying to approximate symbolic solutions which come
I'm not sure what's happening here. If I don't do it quite the way you do, I get
sage: pz = solve(A == 0, p)
sage: pz
[p == -340/5007*sqrt(24168884910961) - 1671503750/5007, p == 340/5007*sqrt(24168884910961) - 1671503750/5007]
sage: pz[0].rhs()
-340/5007*sqrt(24168884910961) - 1671503750/5007
sage: pz[0].rhs().n()
-667666.665528360
sage: pz[1].rhs().n()
-0.100998502399307
Plotting this
sage: plot(A,-700000,100000)
seems to agree with these results.