Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
1  
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. –  Artes Feb 21 at 22:33
    
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] –  Bombyx mori Feb 21 at 22:46
    
What do you mean? I have answered your question with my code. –  Bombyx mori Feb 21 at 22:57
    
@Szabolcs: Fine. I shall correct it. –  Bombyx mori Feb 21 at 23:05
    
@Artes: Updated. Hopefully now it is clearer. –  Bombyx mori Feb 21 at 23:09

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer

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}
share|improve this answer
    
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. –  murray Feb 22 at 17:58
    
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... –  Peltio Feb 23 at 4:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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