taylor(1/4*x-x^2,x,0.2,3)

50 views
Skip to first unread message

Marcin Kostur

unread,
Jul 11, 2017, 10:23:20 AM7/11/17
to sage-support
Dear all,

I had following problem:

this gives
sage: taylor(1/4*x-x^2,x,0.2,3)
...
typeError: ECL says: In function GCD, the value of the first argument is
  -0.6000000000000003
which is not of the expected type INTEGER

but 
sage: taylor(1/4*x-x^2,x,0.2,3) works ;-))

the best
mk

(tried sage 4.7.2, 7.3 and 7.6)

kcrisman

unread,
Jul 11, 2017, 3:07:59 PM7/11/17
to sage-support

I had following problem:

this gives
sage: taylor(1/4*x-x^2,x,0.2,3)
...
typeError: ECL says: In function GCD, the value of the first argument is
  -0.6000000000000003
which is not of the expected type INTEGER

but 
sage: taylor(1/4*x-x^2,x,0.2,3) works ;-))


Wait, what is the difference between your commands?  I feel like there might be a typo/cute-paste error somewhere in there. Certainly the error you mention is the sort of thing we've seen in the past when Maxima doesn't like decimals in certain commands.

Dima Pasechnik

unread,
Jul 12, 2017, 4:06:13 AM7/12/17
to sage-support
this does work (replacing 1/4 by 0.25):

sage: taylor(0.25*x-x^2,x,0.2,3)
-1.0*(x - 0.2)^2 - 0.1500000000000001*x + 0.04000000000000002

Both ways work in Sage's Maxima:
$ sage --maxima
;;; Loading #P"/home/dima/Sage/sage-dev/local/lib/ecl/sb-bsd-sockets.fas"
;;; Loading #P"/home/dima/Sage/sage-dev/local/lib/ecl/sockets.fas"
;;; Loading #P"/home/dima/Sage/sage-dev/local/lib/ecl/defsystem.fas"
;;; Loading #P"/home/dima/Sage/sage-dev/local/lib/ecl/cmp.fas"
using Lisp ECL 16.1.2

%i1) taylor(0.25*x-x^2,x,0.2,3);

rat: replaced 0.2 by 1/5 = 0.2

rat: replaced 0.25 by 1/4 = 0.25

rat: replaced 0.2 by 1/5 = 0.2
                     1    3 (x - 0.2)            2
(%o1)/T/            --- - ----------- - (x - 0.2)  + . . .
                    100       20
(%i2) taylor(1/4*x-x^2,x,0.2,3);

rat: replaced 0.2 by 1/5 = 0.2

rat: replaced 0.2 by 1/5 = 0.2
                     1    3 (x - 0.2)            2
(%o2)/T/            --- - ----------- - (x - 0.2)  + . . .
                    100       20

Any idea what's going on? Looks like a Sage bug, or perhaps Sage loads Maxima with an
option that prevents calling that 'rat' thing...

Nils Bruin

unread,
Jul 12, 2017, 4:35:14 AM7/12/17
to sage-support
On Wednesday, July 12, 2017 at 10:06:13 AM UTC+2, Dima Pasechnik wrote:


Any idea what's going on? Looks like a Sage bug, or perhaps Sage loads Maxima with an
option that prevents calling that 'rat' thing...

Yes, sage does turn off the "turn floats into rational numbers" because that gives confusing and questionable results. If you trust that your users know when to use floats and when rational numbers, then converting from one to the other automatically is not so good.

Robert Dodier

unread,
Jul 12, 2017, 2:23:52 PM7/12/17
to sage-support
On Tuesday, July 11, 2017 at 7:23:20 AM UTC-7, Marcin Kostur wrote:
 
sage: taylor(1/4*x-x^2,x,0.2,3)
...
typeError: ECL says: In function GCD, the value of the first argument is
  -0.6000000000000003
which is not of the expected type INTEGER

but 
sage: taylor(1/4*x-x^2,x,0.2,3) works ;-))

A lot of Maxima was written assuming exact numbers (integers and rationals) -- you have found such a function.

Generally Maxima converts floats to rationals in symbolic algorithms, but there is a global flag keepfloat, which is set to true by Sage, to prevent that conversion. That causes trouble, given the widespread implicit assumption about exact numbers.

It's a bug of course -- perhaps you can submit a bug report to: http://sourceforge.net/p/maxima/bugs
but you can work around it by setting keepfloat to false, or writing 1/5 instead of 0.2.

best,

Robert Dodier

Marcin Kostur

unread,
Jul 13, 2017, 7:30:41 AM7/13/17
to sage-support

Wait, what is the difference between your commands?  I feel like there might be a typo/cute-paste error somewhere in there. Certainly the error you mention is the sort of thing we've seen in the past when Maxima doesn't like decimals in certain commands.

the last should be of course: 
  sage: taylor(0.25*x-x^2,x,0.2,3)

(as Dima noticed ;-)

mk
Reply all
Reply to author
Forward
0 new messages