# Trying to get the divided differences of a list of points

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 close merge delete

Sort by » oldest newest most voted

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)])
[1.00000000000000,
3.50000000000000,
0.500000000000000,
0.000000000000000,
0.000000000000000]


HTH,

more

For future use, if you find something like this in the Sage reference manual (like http://doc.sagemath.org/html/en/refer... or http://doc.sagemath.org/html/en/refer...), there will probably be examples showing exactly how to use it.

@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.

@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.