- #1
kevmac
- 6
- 2
I recently plotted a piecewise function:
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?
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?