If a mass is hung from the end of a spring the two parts wil
If a mass is hung from the end of a spring, the two parts will form a harmonic oscillator. The rate at which the mass oscillates depends on both the spring constant k and the mass m. The frequency of oscillation f is: f = 1/2 pi Squareroot k/m Given values double mass and double spring k, write a C++ expression for the oscillation frequency of the spring-mass system. You may use the squareroot function and M_PI constant from the c math header file (which you may assume has already been included). You only need to write an expression.
Solution
The c++ expression for oscillation frequency is
f = (1/(2*M_PI))*sqrt(k/m);
where M_PI and sqrt are functions in cmath.
M_PI gives the pi value, that is 3.14
sqrt(x) function gives the square root of a variable x, which is x=k/m in the above case.
