Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Step by step :

sage: var('x, m, n')
(x, m, n)
sage: hh=(exp(x)*(1-x))^n/x^m
sage: solve(hh.diff(x)==0,x)
[x^2 == (m*x^2 - m)/n]

That's an implicit solution. Sage's default solver (Maxima's) can be coaxed to find for a more explocit answer :

sage: solve(hh.diff(x)==0,x, to_poly_solve=True)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

Or you may use solve recursively) :

sage: solve(solve(hh.diff(x)==0,x),x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

or

sage: solve(hh.diff(x)==0,x)[0].solve(x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

But bewa

Step by step :

sage: var('x, m, n')
(x, m, n)
sage: hh=(exp(x)*(1-x))^n/x^m
sage: solve(hh.diff(x)==0,x)
[x^2 == (m*x^2 - m)/n]

That's an implicit solution. Sage's default solver (Maxima's) can be coaxed to find for a more explocit answer :

sage: solve(hh.diff(x)==0,x, to_poly_solve=True)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

Or you may use solve recursively) :

sage: solve(solve(hh.diff(x)==0,x),x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

or

sage: solve(hh.diff(x)==0,x)[0].solve(x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

But bewabeware : you should check these vatious solutions.And be wary of simplify_full which may use simplifications validonly certain assumptions...

Left as an exercise for the reader...

HTH,

Step by step :

sage: var('x, m, n')
(x, m, n)
sage: hh=(exp(x)*(1-x))^n/x^m
sage: solve(hh.diff(x)==0,x)
[x^2 == (m*x^2 - m)/n]

That's an implicit solution. Sage's default solver (Maxima's) can be coaxed to find for a more explocit answer :

sage: solve(hh.diff(x)==0,x, to_poly_solve=True)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

Or you may use solve recursively) :

sage: solve(solve(hh.diff(x)==0,x),x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

or

sage: solve(hh.diff(x)==0,x)[0].solve(x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

But beware : you should check these vatious solutions.And be wary of simplify_full which may use simplifications validonly certain assumptions...

Left as an exercise for the reader...

HTH,

EDIT :

the final solution [x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))] that you obtained by repeated application of solve procedure is wrong, so this is the bug of "Maxima" after all.

Indeed :

sage: [Eq.subs(t).simplify_full().is_zero() for t in flatten([s.solve(x) for s in S1])]
[False, False]

This is now [#35541]{https://github.com/sagemath/sage/issues/35541)

Workarounds :

sage: Ex.factor().solve(x)
[x == 1, x == 1/2*(m - sqrt(m^2 - 4*m*n))/n, x == 1/2*(m + sqrt(m^2 - 4*m*n))/n, x == 0]
sage: [Ex.subs(s).is_zero() for s in Ex.factor().solve(x)]
[True, True, True, True]
sage: Ex.solve(x, algorithm="giac")
[1/2*(m - sqrt(m^2 - 4*m*n))/n, 1/2*(m + sqrt(m^2 - 4*m*n))/n]
sage: [Ex.subs(x==s).is_zero() for s in Ex.solve(x, algorithm="giac")]
[True, True]
sage: [{v[1].sage():v[2].sage() for v in s} for s in mathematica.Solve(Ex==0, x)]
[{x: -1/2*(sqrt(m - 4*n)*sqrt(m) - m)/n},
 {x: 1/2*(sqrt(m - 4*n)*sqrt(m) + m)/n}]
sage: [Ex.subs(s).is_zero() for s in [{v[1].sage():v[2].sage() for v in s} for s in mathematica.Solve(Ex==0, x)]]
[True, True]

HTH,

Step by step :

sage: var('x, m, n')
(x, m, n)
sage: hh=(exp(x)*(1-x))^n/x^m
sage: solve(hh.diff(x)==0,x)
[x^2 == (m*x^2 - m)/n]

That's an implicit solution. Sage's default solver (Maxima's) can be coaxed to find for a more explocit answer :

sage: solve(hh.diff(x)==0,x, to_poly_solve=True)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

Or you may use solve recursively) :

sage: solve(solve(hh.diff(x)==0,x),x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

or

sage: solve(hh.diff(x)==0,x)[0].solve(x)
[x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))]

But beware : you should check these vatious solutions.And be wary of simplify_full which may use simplifications validonly certain assumptions...

Left as an exercise for the reader...

HTH,

EDIT :

the final solution [x == -sqrt(m/(m - n)), x == sqrt(m/(m - n))] that you obtained by repeated application of solve procedure is wrong, so this is the bug of "Maxima" after all.

Indeed :

sage: [Eq.subs(t).simplify_full().is_zero() for t in flatten([s.solve(x) for s in S1])]
[False, False]

This is now [#35541]{https://github.com/sagemath/sage/issues/35541)#35541

Workarounds :

sage: Ex.factor().solve(x)
[x == 1, x == 1/2*(m - sqrt(m^2 - 4*m*n))/n, x == 1/2*(m + sqrt(m^2 - 4*m*n))/n, x == 0]
sage: [Ex.subs(s).is_zero() for s in Ex.factor().solve(x)]
[True, True, True, True]
sage: Ex.solve(x, algorithm="giac")
[1/2*(m - sqrt(m^2 - 4*m*n))/n, 1/2*(m + sqrt(m^2 - 4*m*n))/n]
sage: [Ex.subs(x==s).is_zero() for s in Ex.solve(x, algorithm="giac")]
[True, True]
sage: [{v[1].sage():v[2].sage() for v in s} for s in mathematica.Solve(Ex==0, x)]
[{x: -1/2*(sqrt(m - 4*n)*sqrt(m) - m)/n},
 {x: 1/2*(sqrt(m - 4*n)*sqrt(m) + m)/n}]
sage: [Ex.subs(s).is_zero() for s in [{v[1].sage():v[2].sage() for v in s} for s in mathematica.Solve(Ex==0, x)]]
[True, True]

HTH,