Ask Your Question
1

Limit evaluatation from user input not working

asked 2016-05-03 02:31:05 +0100

user6502 gravatar image

My code is:

t = raw_input()
#n = var('x')
u2 = raw_input()
(t).limit(x=u2)
(t).limit(x=u2+0.001)
(t).limit(x=u2+0.0001)

It gives me this error:

Error in lines 4-4
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
AttributeError: 'unicode' object has no attribute 'limit'

What am I doing wrong? I want to ask the user the function to be evaluated and the number that x approaches.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-03 05:53:07 +0100

tmonteil gravatar image

It is not clear what should the user enter, but if it is something like sin(x) for t and pi for u2, you have to understand that when you write sin(x) in the command line, you create a symbolic object, corresponding to the mathematical function $sin(x)$. When you type "sin(x)" as an input of raw_input(), the function returns the string "sin(x)", not the symbolic mathematical function. So you have to transform this string as a symbolic expression, that is an element of the symbolic ring, for this you should replace the string t by SR(t) (idem for u2):

sage: SR(t).limit(x=SR(u2)+0.001)
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: 2016-05-03 02:31:05 +0100

Seen: 255 times

Last updated: May 03 '16