# Solve fails to identify the maximum of the entropy function

The entropy function has its maximum at x=1/2

Yet when one uses solve:

x=var('x')
assume(x>0)
solve(derivative(-x*log(x) -(1-x)*log(1-x),x)==0,x)


sage returns something that is correct, but curiously non-specific

[log(x) == log(-x + 1)]


It almost seems like sage can't figure out that x=1/2 solves the above even after the assumption on x.

edit retag close merge delete

Sort by » oldest newest most voted

solve(e^derivative(-x*log(x) -(1-x)*log(1-x),x)==1,x)


gives

[x == (1/2)]

more

Alternatives :

sage: Ex=-(x*log(x)+(1-x)*log(1-x))
sage: solve(Ex.diff(x),x)
[log(x) == log(-x + 1)]


Fails indeed. but :

sage: solve(Ex.diff(x),x, algorithm="sympy")
[x == (1/2)]
sage: solve(Ex.diff(x),x, algorithm="giac")
Warning, argument is not an equation, solving -ln(sageVARx)+ln(-sageVARx+1)=0
[1/2]
sage: solve(Ex.diff(x),x, algorithm="fricas")
[log(x) == log(-x + 1)]


Not directly translatable as of 9.7.beta6 :

sage: mathematica.Solve(Ex.diff(x)==0,x)
{{x -> 1/2}}


Somewhat trichodynamic :

sage: foo=solve(Ex.diff(x),x)
sage: foo.operator()(*map(exp, foo.operands())).solve(x)
[x == (1/2)]


HTH,