Ask Your Question
0

Trying to get the divided differences of a list of points

asked 2019-07-27 03:36:04 -0500

Masacroso gravatar image

updated 2019-07-27 04:09:36 -0500

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
2

answered 2019-07-27 08:05:41 -0500

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,

edit flag offensive delete link more

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 ( 2019-07-27 15:25:58 -0500 )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 13:21:50 -0500 )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-01 20:19:54 -0500 )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

Stats

Asked: 2019-07-27 03:36:04 -0500

Seen: 44 times

Last updated: Jul 27