Math formula

How can I convert the following into C++?

sin2x?

Thank you.
1
2
3
#include <cmath>

double y = pow(sin(x), 2);
Thank you.
As others will usually say, using pow() to square stuff is usually overkill, so you might want to just use sin(x)*sin(x).
Calculating trigonometric function 2 times might be even more overkill.
Assign to variable, multiply it by itself.
Thank you
True, I was thinking about that myself after I posted but didn't bother saying anything.
Topic archived. No new replies allowed.