0
$\begingroup$

I have a very simple question (I'm a beginner on mathematica, and didn't find the answer here). When I try to maximize a simple function like Maximize[x - 0.5*x^(4/3), x] I obtain an error message "the function value... is not a real number". When I replace "0.5" by "1/2" I get the correct anwer. I also get an answer with any integer, but never with a decimal number. Eg "2.5" doesnt work, but "5/2" works. What is the problem please ?

$\endgroup$

2 Answers 2

1
$\begingroup$

If you restrict x to be positive it works as expected:

NMaximize[{x - 0.5*x^(4/3), x > 0}, x]
(* {0.84375, {x -> 3.375}} *)
$\endgroup$
2
  • $\begingroup$ Additionally, one might want to apply Rationalize[] to the exponent. $\endgroup$ Commented Mar 19, 2018 at 14:50
  • 1
    $\begingroup$ Maximize[{x - 0.5*x^(4/3), FunctionDomain[x - 0.5*x^(4/3), x]}, x] $\endgroup$
    – Bob Hanlon
    Commented Mar 19, 2018 at 15:15
0
$\begingroup$

you can also do this:

Maximize[x - c*x^(4/3), x] /. c -> .5

{0.84375, {x -> 3.375}}

as a bit of explanation, when you give Maximize everything exact it uses analytic methods to find the value. As soon as you give it a float (inexact) value it switches to numerical methods which produce complex results for negative x.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.