I recently plotted a piecewise function:(adsbygoogle = window.adsbygoogle || []).push({});

Plot[Piecewise[{{1 - Exp[-.002*t],

0 <= t < 120}, {-Exp[-.002*t] + Exp[-.002*(t - 120)],

120 <= t}}], {t, 0, 5000}, PlotRange -> {0, 0.25}]

I then defined the function which I am calling q[t_] as follows:

q[t_] := Piecewise[{{1 - Exp[-.002*t],

0 <= t < 120}, {-Exp[-.002*t] + Exp[-.002*(t - 120)],

120 <= t}}];

I then wish to find the maximum value of this function, which should occur at t=120. I entered:

FindMaximum[q, t]

But received the following error:

FindMaximum::nrnum: "The function value -q is not a real number at {t} = {1.`}"

Any easy way to fix this? Am I using the FindMaximum function incorrectly, or did I do something wrong when initially defining the function?

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# FindMaximum function in Mathematica

Loading...

Similar Threads - FindMaximum function Mathematica | Date |
---|---|

Mathematica Cannot do the integral of the Hyper-geometric function? | Mar 11, 2018 |

Mathematica Cannot Plot This Function in Mathematica | Feb 26, 2018 |

Matlab Dotting autonomous functions | Jan 24, 2018 |

Mathematica Piecewise Function | Jan 18, 2018 |

FindMaximum Mathematica | Jul 22, 2008 |

**Physics Forums - The Fusion of Science and Community**