Evaluate a polynomial at an element

19 views
Skip to first unread message

Jonas Ehrhard

unread,
Mar 2, 2023, 4:49:27 AM3/2/23
to Macaulay2
I feel a bit stupid for asking this, but say I have a polynomial f over a field K, is it possible to evaluate f at some element a of K, i.e. compute f(a)? I was not able to do this, and did not find anything in the beginner tutorials.

Mike Cummings

unread,
Mar 2, 2023, 9:34:58 AM3/2/23
to Macaulay2
Use the `sub` command. For example:

i1 : R = QQ[x,y];
i2 : f = x+y;
i3 : sub(f, y=>1)  -- evaluates f(x,1)
o3 = x + 1


Torrance, Douglas

unread,
Mar 2, 2023, 10:54:26 AM3/2/23
to maca...@googlegroups.com
Square brackets also work as syntactic sugar for "sub". For example:

i3 : f[x, 1]

o3 = x + 1

o3 : R

i4 : f[2, 3]

o4 = 5

Jonas Ehrhard

unread,
Mar 2, 2023, 4:52:52 PM3/2/23
to Macaulay2
Thank you two, that is helpful!
Reply all
Reply to author
Forward
0 new messages