Ask Your Question

PsylentKnight's profile - activity

2017-04-27 20:33:38 +0200 received badge  Famous Question (source)
2016-12-07 18:04:12 +0200 received badge  Notable Question (source)
2016-12-07 18:04:12 +0200 received badge  Popular Question (source)
2015-04-01 21:01:09 +0200 received badge  Scholar (source)
2015-04-01 20:50:13 +0200 commented answer What's wrong with my function syntax?

Thank you! It was probably because I pasted it from an outside source (probably the .pdf the instructions the professor gave us were in).

2015-04-01 20:05:16 +0200 received badge  Editor
2015-04-01 19:41:28 +0200 asked a question 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...