----------------------------------------------------------------------
| Sage Version 5.3, Release Date: 2012-09-08 |
| Type "notebook()" for the browser-based notebook interface. |
| Type "help()" for help. |
----------------------------------------------------------------------
sage: eval(preparse("numerical_approx(integral(x/(x^3-x+1), x, 1, 2))"))
0.132008722884722
sage: numerical_approx(integral(x/(x^3-x+1), x, 1, 2))
0.132008722884722
sage: A = integral(x/(x^3-x+1), x, 1, 2)
sage: A_str = str(A)
sage: eval(preparse("numerical_approx("+A_str +")"))
-0.393296585552547
sage:
On 2015-03-10, M M <mirette...@gmail.com> wrote:
> I get different results from Sage when I try to get a numerical
> approximation for an expression and if I use evaluate a preparse of the
> string. I get different results on different versions of sage as well. Here
> are samples:
Integration is done by Maxima, and it is a bloody mess; e.g.
On Tuesday, March 10, 2015 at 9:04:14 AM UTC-7, Dima Pasechnik wrote:On 2015-03-10, M M <mirette...@gmail.com> wrote:
Integration is done by Maxima, and it is a bloody mess; e.g.
It is, but I suspect that's not the cause here. I think it's just numerical instability.
sage: sage: integral(x/(x^3-x+1), x, 1, 2).n(100)
0.56579991645642210974671290281
sage: sage: integral(x/(x^3-x+1), x, 1, 2).simplify_full().n(100)
0.56579991645643344322713389324
I tried this integral directly in Maxima, and taking bfloat of it
outputs nonsense.
I wish there was a more accessible full implementation of Risch algorithm...
On Wed, Mar 11, 2015 at 9:35 AM, Dima Pasechnik <dim...@gmail.com> wrote:
> On 2015-03-11, Nils Bruin <nbr...@sfu.ca> wrote:
>> On Wednesday, March 11, 2015 at 2:46:25 AM UTC-7, Dima Pasechnik wrote:
>>>
>>> I tried this integral directly in Maxima, and taking bfloat of it
>>> outputs nonsense.
>>>
>>
>> I have noticed before that bfloats aren't infectious enough: operations on
>> bfloats can easily result in a normal "double". I think there are ways to
>> convince maxima to use bfloats more pervasively. Perhaps a global precision
>> setting somewhere?
>>
>>
>>> I wish there was a more accessible full implementation of Risch
>>> algorithm...
>>>
>>
>> This is a rational function, so a first calculus course would already teach
>> you the relevant part of the Risch algorithm. It's a little more tricky to
>
> Risch, as implemented in Axiom, does not do factorisation (i.e. no
> partial fractions).
> In this example at least it produces much nicer looking antiderivative,
> no huge integers.
> http://axiom-wiki.newsynthesis.org/ExampleIntegration
>
> Dima
For what it's worth, here's how to mostly do that Axiom session, but
in a SageMathCloud worksheet...
https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2015-03-11-093745-axiom-integral.sagews
Thanks so much for all the efforts for making sage output consistent results for the numerical approximation. However, the main problem I had was the fact that Sage returns different answers when I preparse the string of the same sage expression as in the examples of the original post.
I tried on a different machine with Sage Version 6.5, Release Date: 2015-02-17 and I get the same behaviour described in the original post. Where parsing a string and evaluating returns different results than using the resulted sage expression.
Apologies for the typo.Ah, right. Yes, evaluating a string representation of an object does NOT necessarily result in the same object.