Find the critical points

Tim Roberts timr at probo.com
Thu Feb 5 00:35:30 EST 2009


antoniosacchi85 at gmail.com wrote:
>
>someone can help me??
>I am new to programing,
>but I need to make some script like this:
>http://blogs.nyu.edu/blogs/agc282/zia/2008/11/using_python_to_solve_optimiza.html
>so th equestion is :
>is possible to open it than it ask something and it tell me the
>result??

I'm not exactly sure what you're asking.  The script as you wrote it works,
but it was designed to be entered from the interactive interpreter, so if
you run it in a script it won't print anything.  Basically, just add
"print" in front of the expressions that you want printed:

>import sympy as S
>x,y=S.symbols('xy')
>f=x**4+x**2-6*x*y+3*y**2
>a=S.diff(f,x)
>S.pprint(a)
>b=S.diff(f,y)
>S.pprint(b)
>S.solve_system([a,b],[x,y])

print S.solve_system([a,b],[x,y])

>H=S.hessian(f,[x,y])
>M1=S.Matrix([14,-6],[-6,6])
>M2=S.Matrix([2,-6],[-6,6])
>S.Matrix.berkowitz_minors(M2)
>S.Matrix.berkowitz_minors(M1)

print S.Matrix.berkowitz_minors(M2)
print S.Matrix.berkowitz_minors(M1)
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list