Ask Your Question

sage -c "print diff(x^4,x)"

asked 2012-10-13 10:19:19 +0200

xuwang gravatar image

updated 2023-01-10 00:01:08 +0200

tmonteil gravatar image

I'm using 5.3 on Ubuntu 64 bit.

I would like to have the following print 4x^3 to standard out.

$ ./sage -c "print diff(x^4,x)"
Traceback (most recent call last):
  File "/home/xuwang/sage/local/bin/sage-eval", line 15, in <module>
  File "<cmdline>", line 1, in <module>
NameError: name 'x' is not defined
edit retag flag offensive close merge delete


You can explicitly declare x as a variable: `sage -c "var('x'); print diff(x^4,x)"`

John Palmieri gravatar imageJohn Palmieri ( 2012-10-13 12:26:14 +0200 )edit

The question remains of why `./sage -c` doesn't behave the same as Sage proper. Sage does have `x` predefined, like it or not.

kcrisman gravatar imagekcrisman ( 2012-10-13 18:36:52 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-17 20:42:42 +0200

tmonteil gravatar image

This bug was fixed in Sage 5.4.1. Thanks for reporting it . Now, you will get

$ sage -c "print diff(x^4,x)"


edit flag offensive delete link more

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: 2012-10-13 10:19:19 +0200

Seen: 373 times

Last updated: Apr 17 '13