Ask Your Question
0

Trying to get the divided differences of a list of points

asked 5 years ago

Masacroso gravatar image

updated 5 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

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

HTH,

Preview: (hide)
link

Comments

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.

John Palmieri gravatar imageJohn Palmieri ( 5 years ago )

@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 ( 5 years ago )

@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 ( 5 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 5 years ago

Seen: 425 times

Last updated: Jul 27 '19