Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can put e.g. sin(x),cos(x) in google's search box and it will plot the 2 functions. But if I only want to plot the maximum value, how do I plot something like max(sin(x),cos(x)) or the minimum ? I'm not sure but if the max and min are not implemented maybe trigonometric functions can implement the max / min functions?


I was not clear enough. I want something like max(sin(x), 0.5x) and only plot the maximum value at each x.

share|cite|improve this question
You mean like this and this? Maybe get MMA or some other CAS. – Amzoti Mar 8 '13 at 23:56
Find your answer below! – user59169 Mar 9 '13 at 0:06
up vote 3 down vote accepted

Use $\frac{sin(x)+cos(x)+|sin(x)-cos(x)|}{2}$ or (sin(x)+cos(x)+abs(sin(x)-cos(x)))/2 for max(sin(x),cos(x)) and $\frac{sin(x)+cos(x)-|sin(x)-cos(x)|}{2}$ for min(sin(x),cos(x)).

like this.

EDIT: Seems like I wasn't clear enough, for any arbitrary f(x) and g(x) you can use 1/2*(f(x)+g(x)+abs(f(x)-g(x))) to plot max(f(x),g(x)).

EDIT 2: Note that $$ \forall x, f(x) < g(x): |f(x) - g(x)| = g(x) - f(x) \implies f(x) + g(x) + |f(x) - g(x)| = 2g(x). $$

$$ \forall x, f(x) > g(x): |f(x) - g(x)| = f(x) - g(x) \implies f(x) + g(x) + |f(x) - g(x)| = 2f(x). $$

$$ \implies \forall x: f(x) + g(x) + |f(x) - g(x)| = 2* max(f(x),g(x)). $$

$$ \square $$

share|cite|improve this answer
You beat me to it by a second :) +1 – Sasha Mar 8 '13 at 23:59
Thank you but I think I want it more general i.e. max(f(x),g(x)) and I was not clear enough in the post. – Programmer 400 Mar 9 '13 at 0:07
Just replace the sin and cos with f and g. Edited. – user59169 Mar 9 '13 at 0:08
Proved it will work in any case :). Edited, second. – user59169 Mar 9 '13 at 0:16
Well, it will be ugly. Use the fact that max(f,g,h) = max(f,max(g,h)). example: max(sin(x),cos(x),tan(x)) will be 1/2*(sin(x)+(1/2*(cos(x)+tan(x)+abs(cos(x)-tan(x)))+abs(sin(x)-(1/2*(cos(x)+tan‌​(x)+abs(cos(x)-tan(x))))). I don't know if google's engine will parse such a big string as a formula or not. – user59169 Mar 9 '13 at 0:26

You can use Wolfram Alpha to get this

share|cite|improve this answer
Why can't google do simple math? Thanks for the answer. Google could let us make a macro or so for the max and min. – Programmer 400 Mar 9 '13 at 22:19

Your Answer


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.