Hi,
I could not find a function in Sympy that finds the minimum of a function
symbolically.
In case it is not implemented yet, would it make sense to add it?
minimize() and maximize() are used in several of the Wester test cases.
This is an example of how I implemented one of the test cases. Maybe can be
used as a basis:
def _minmaximize(expr, x, si):
f = Lambda(x, expr)
f1 = f(x).diff(x)
f2 = Lambda(x,f1.diff(x))
m = None
mp = None
for p in solve(f1,x):
if Gt(si*f2(p),0)==True and ((m == None) or
Lt(si*(f(p)-m),0)==True):
m=f(p)
mp = p
return (m,mp)
def _minimize(expr, x):
return _minmaximize(expr, x, +1)
def _maximize(expr, x):
return _minmaximize(expr, x, -1)
def test_U13():
assert _minimize(x**4 - x + 1, x)[0] == -3*2**Rational(1,3)/8 + 1
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.