Ask Your Question

Trying to get the divided differences of a list of points

asked 2019-07-27 10:36:04 +0200

Masacroso gravatar image

updated 2019-07-27 11:09:36 +0200

I was trying to get the divided differences of a list of points, then I had written

divided_difference((0,1), (1,4.5), (3,14.5), (5,28.5), (6,37)) but when I tried to execute it the notebook spit out


NameError Traceback (most recent call last) <ipython-input-1-7581bf64e41a> in <module>() ----> 1 divided_difference((Integer(0),Integer(1)), (Integer(1),RealNumber('4.5')), (Integer(3),RealNumber('14.5')), (Integer(5),RealNumber('28.5')), (Integer(6),Integer(37)))

NameError: name 'divided_difference' is not defined


However the function divided_difference appear in the manual of SAGE related to polynomials. What Im doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-27 15:05:41 +0200

Emmanuel Charpentier gravatar image

AFAICT, the divided_difference method belongs to the class PolynomialRing_dense_mod_p. You attempt to apply it to a lsit of tuples of integers, for which it is not defined. Therefore, you must somehow give the crucial information (on whar ring are you working ?).

sage: R.<t>=PolynomialRing(RR)
sage: R.divided_difference([(0,1), (1,4.5), (3,14.5), (5,28.5), (6,37)])


edit flag offensive delete link more


For future use, if you find something like this in the Sage reference manual (like or, there will probably be examples showing exactly how to use it.

John Palmieri gravatar imageJohn Palmieri ( 2019-07-27 22:25:58 +0200 )edit

@JohnPalmieri you are totally right, I didn't see the examples (I dont know why, maybe I was seeing a different doc? I dont know). My bad.

Masacroso gravatar imageMasacroso ( 2019-07-31 20:21:50 +0200 )edit

@Macacroso: I wasn't trying to criticize, rather trying to help in the future. For me, once I know how to really use the documentation, it helps me whenever I use the software.

John Palmieri gravatar imageJohn Palmieri ( 2019-08-02 03:19:54 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2019-07-27 10:36:04 +0200

Seen: 157 times

Last updated: Jul 27 '19