Ask Your Question
0

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

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

xuwang gravatar image

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

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>
    eval(compile(s,'<cmdline>','exec'))
  File "<cmdline>", line 1, in <module>
NameError: name 'x' is not defined
$
edit retag flag offensive close merge delete

Comments

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 +0100 )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 +0100 )edit
1

1 Answer

Sort by ยป oldest newest most voted
3

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

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)"
4*x^3

:)

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

Stats

Asked: 2012-10-13 10:19:19 +0100

Seen: 414 times

Last updated: Apr 17 '13