Issue 246 in mpmath: findroot problem

4 views
Skip to first unread message

mpm...@googlecode.com

unread,
Nov 10, 2013, 5:37:17 AM11/10/13
to mpmath...@googlegroups.com
Status: New
Owner: ----

New issue 246 by kadirdo...@gmail.com: findroot problem
http://code.google.com/p/mpmath/issues/detail?id=246

What steps will reproduce the problem?
I coded p1 , p2 script in c:\Python33\ :

p1:
def f2():
exec(open('c:\Python33\p2.py').read())
return;
def f1():
f2()
return;


p2:
from mpmath import *
print(findroot(lambda x: sin(x)-0.5, x0=0.2))


What is the expected output? What do you see instead?
when i run idle then:

first time;
from mpmath import *
print(findroot(lambda x: sin(x)-0.5, x0=0.2))
0.523598775598299 expected output no problem

but if enter this form:
from p1 import *
f1()

result:

Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
f1()
File ".\p1.py", line 7, in f1
f2()
File ".\p1.py", line 3, in f2
exec(open('c:\Python33\p2.py').read())
File "<string>", line 5, in <module>
File "C:\Python33\lib\site-packages\mpmath\calculus\optimization.py",
line 925, in findroot
fx = f(*x0)
File "<string>", line 5, in <lambda>
NameError: global name 'sin' is not defined



What version of the product are you using? On what operating system?
Python 3.3.2 , Windows 7

Please provide any additional information below.

in p2:
when i replace
"print(findroot(lambda x: sin(x)-0.5, x0=0.2))"
to "print(sin(2))"
no problem occured

or if i added "from mpmath import *" to p1' as first line
no problem occured
print(findroot(lambda x: sin(x)-0.5, x0=0.2)) Works

So:
in my development excpectations needs to this
way of p1 and p2 works

What is the problem i can't understand
Thanks for any help



--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages