Hi,

I can see the utility for something like this in general. But, I think the 
general case should have an option for function boundaries (e.g., x >=0). I ran 
into an error once in a paper where they defined the maximum in a manner 
similar to this and it turned out that the maximum was at the boundary (x=0 in 
that case). 

Cheers,

Tim.

---
Tim Lahey, Ph.D.
Post-Doctoral Fellow
Systems Design Engineering
University of Waterloo

On 2013-10-09, at 2:29 PM, Pablo Puente <[email protected]> wrote:

> 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.

-- 
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.

Reply via email to