4
$\begingroup$

I need to maximize this function on the positive real line:

$$ \frac{1}{\Gamma(x)^{14}}\cdot\frac{1}{{\frac{323.6}{14x}}^{14x}}\cdot(1.22578*10^{19})^{x-1}e^{-14x} $$ the correct answer should be around $x=514$, but I could not use mathematica to show it. My plot has a peak at $x=680$ instead. I want to ask if anyone has any idea how to get the correct answer.

The code I am using now is:

A = 1/Gamma[x]^{14}*(301.6/(14*x))^{-14 *x}*(1.22578*10^{19})^{x -1} E^{-14 x}

and I plot it by

Plot[A, {x, 513, 700}, PlotPoints -> 1000]

The result is something very strange:

enter image description here

$\endgroup$
7
  • 1
    $\begingroup$ Could you provide the code you've used? Interestingly, using NMaximize I'm getting results depending on the upper bound of x. However with NMaximize[{f[x], 10^3 > x > 0}, x] I get {1.82059*10^-9, {x -> 514.197}} which seems correct comparing with an appropriate plot. $\endgroup$
    – Artes
    Feb 21, 2014 at 22:33
  • $\begingroup$ I used:A = 1/Gamma[x]^{14}*(301.6/(14*x))^{-14 *x}*(1.22578*10^{19})^{x - 1} E^{-14 x}, Plot[A, {x, 513, 700}, PlotPoints -> 1000] $\endgroup$ Feb 21, 2014 at 22:46
  • $\begingroup$ What do you mean? I have answered your question with my code. $\endgroup$ Feb 21, 2014 at 22:57
  • $\begingroup$ @Szabolcs: Fine. I shall correct it. $\endgroup$ Feb 21, 2014 at 23:05
  • $\begingroup$ @Artes: Updated. Hopefully now it is clearer. $\endgroup$ Feb 21, 2014 at 23:09

2 Answers 2

9
$\begingroup$

I don't like using approximate numbers when we can use exact ones, therefore with Rationalize and RootApproximant I can rewrite the function this way:

f[x_] := 1/Gamma[x]^14 1/(1618/(70 x))^(14 x) 12257800000000000000^(x - 1) Exp[-14 x]

let's plot this function:

Plot[ f[x], {x, 0, 1500}, PlotStyle -> Thick]

enter image description here

We can use:

NMaximize[{ f[x], 10^5 > x > 0}, x]
{1.82059*10^-9, {x -> 514.198}}

which most likely is a good approximation. However when we use e.g.

NMaximize[{ f[x], 10^6 > x > 0}, x]
{3.92756*10^-30, {x -> 0.327666}}

we get an incorret result. It may depend on the computer system one uses.
I guess this issue is explained with anwswers to this post: Numerical underflow for a scaled error function.

$\endgroup$
4
$\begingroup$

Following Artes' Rationalizeation, why don't you simply find where the first derivative goes to zero?

f[x_] := 1/Gamma[x]^14 1/(1618/(70 x))^(
    14 x) 12257800000000000000^(x - 1) Exp[-14 x]

Plot[f'[x], {x, 100, 1100}]

FindRoot[f'[x] == 0, {x, 500}]

    {x -> 514.198}
$\endgroup$
2
  • $\begingroup$ For the record: A zero derivative is only a necessary condition for a local extremum, not a sufficient condition. And even if have a local extremum there, you still don't know from the first derivative's vanishing whether it's a local minimum or a local maximum. Of course additional information, such as a plot, can suggest (but not prove) you really have a local max and that it's a global max. $\endgroup$
    – murray
    Feb 22, 2014 at 17:58
  • 1
    $\begingroup$ The OP already knew there was a maximum near 500. By looking at the plot of the derivative you can see what is happening. The black-box NMaximize is no different than looking to a plot (there is no proof, just the hope that it is as the software says). A detailed study of the function can be done by analyzing how first and second derivative behave, but that's math, not Mathematica... $\endgroup$
    – Peltio
    Feb 23, 2014 at 4:50

Your Answer

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

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