I plotted a function and a certain horizontal line as a benchmark.

After time t = 2 my function goes below the line, which is ok.

enter image description here

But I need to show when the AVERAGE of this function goes below the line. For example, it crosses the line in 2 hours but on average this rate will go below the line only after 5 hours. How do I plot this?

Currently, my code looks approximately like this

Plot[{1000, function[t]}, {t, 0, 20}, PlotStyle -> {{Red}, {Thickness[0.01]}}, AxesLabel -> {"t", "Name"}, PlotRange -> All]

1 Answer 1


As an example, since we don't know what you function is,

f[t_] := 15 Exp[-2 t]
fav[t_] = Integrate[f[tp], {tp, 0, t}]/t

 {f[t], fav[t]},
 {t, 0, 1},
 Axes -> False,
 Frame -> True,
 FrameLabel -> {"t", "Name"},
 PlotRange -> All,
 GridLines -> {t /. NSolve[fav[t] == 10, t, Reals], {10}},
 GridLinesStyle -> {Directive[Red, Thick], Directive[Darker[Green, 3/5], Thick]},
 PlotLegends -> {"f", "f average"},
 PlotLabel -> "Average of f = " <> ToString@10 <> " at t = " <> ToString[t /. First@NSolve[fav[t] == 10, t, Reals]]

(15 E^-t Sinh[t])/t

enter image description here


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.