Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What's wrong with my function syntax?

I've been using sagemath throughout the semester with few problems, but I just can't seem to figure out what's wrong with my syntax here.

x = var('x')

p(x) = x^3 – 3*x^2 + (x - 1)
Dp(x) = derivative(p(x), x)

plot(p(x), -1, 1)

I'm getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCgpwKHgpID0geF4zIOKAkyAzKnheMiArICh4IC0gMSkKRHAoeCkgPSBkZXJpdmF0aXZlKHAoeCksIHgpCgpwbG90KHAoeCksIC0xLCAxKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpd2XXUV/___code___.py", line 5
    __tmp__=var("x"); p = symbolic_expression(x**_sage_const_3  – _sage_const_3 *x**_sage_const_2  + (x - _sage_const_1 )).function(x)
                                                                ^
SyntaxError: invalid syntax

So appears that the function is in error...

What's wrong with my function syntax?

I've been using sagemath throughout the semester with few problems, but I just can't seem to figure out what's wrong with my syntax here.

x = var('x')

p(x) = x^3 – 3*x^2 + (x - 1)
Dp(x) = derivative(p(x), x)

plot(p(x), -1, 1)

I'm getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCgpwKHgpID0geF4zIOKAkyAzKnheMiArICh4IC0gMSkKRHAoeCkgPSBkZXJpdmF0aXZlKHAoeCksIHgpCgpwbG90KHAoeCksIC0xLCAxKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpd2XXUV/___code___.py", line 5
    __tmp__=var("x"); p = symbolic_expression(x**_sage_const_3  – _sage_const_3 *x**_sage_const_2  + (x - _sage_const_1 )).function(x)
                                                                ^
SyntaxError: invalid syntax

So appears that the function is in error...

I've been using sagemath throughout the semester with few problems, but I just can't seem to figure out what's wrong with my syntax here.

x = var('x')

p(x) = x^3 – 3*x^2 + (x - 1)
Dp(x) = derivative(p(x), x)

plot(p(x), -1, 1)

I'm getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCgpwKHgpID0geF4zIOKAkyAzKnheMiArICh4IC0gMSkKRHAoeCkgPSBkZXJpdmF0aXZlKHAoeCksIHgpCgpwbG90KHAoeCksIC0xLCAxKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpd2XXUV/___code___.py", line 5
    __tmp__=var("x"); p = symbolic_expression(x**_sage_const_3  – _sage_const_3 *x**_sage_const_2  + (x - _sage_const_1 )).function(x)
                                                                ^
SyntaxError: invalid syntax

So appears that the function is in error...

What's wrong with my function syntax?

I've been using sagemath throughout the semester with few problems, but I just can't seem to figure out what's wrong with my syntax here.

x = var('x')

p(x) = x^3 – 3*x^2 + (x - 1)
Dp(x) = derivative(p(x), x)

plot(p(x), -1, 1)

I'm getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCgpwKHgpID0geF4zIOKAkyAzKnheMiArICh4IC0gMSkKRHAoeCkgPSBkZXJpdmF0aXZlKHAoeCksIHgpCgpwbG90KHAoeCksIC0xLCAxKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpd2XXUV/___code___.py", line 5
    __tmp__=var("x"); p = symbolic_expression(x**_sage_const_3  – _sage_const_3 *x**_sage_const_2  + (x - _sage_const_1 )).function(x)
                                                                ^
SyntaxError: invalid syntax

So appears that the function is in error...

I've been using sagemath throughout the semester with few problems, but I just can't seem to figure out what's wrong with my syntax here.

x = var('x')

p(x) = x^3 – 3*x^2 + (x x - 1)
1
Dp(x) = derivative(p(x), x)

plot(p(x), -1, 1)

I'm getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCgpwKHgpID0geF4zIOKAkyAzKnheMiArICh4IC0gMSkKRHAoeCkgPSBkZXJpdmF0aXZlKHAoeCksIHgpCgpwbG90KHAoeCksIC0xLCAxKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpd2XXUV/___code___.py", line 5
    __tmp__=var("x"); p = symbolic_expression(x**_sage_const_3  – _sage_const_3 *x**_sage_const_2  + (x - _sage_const_1 )).function(x)
                                                                ^
SyntaxError: invalid syntax

So appears that the function is in error...