I have the following simple sine formula (in degrees) which I am plotting on the screen. The user is able to change the values of the variables waveAmplitude, angleCoef, and horizontalShift.

y = waveAmplitude * Math.sin(x * angleCoef + horizontalShift)

I have to also display the wavelength on the screen. But I can't quite figure out how to calculate the wavelength.

So how exactly can I calculate wavelength for my simple sine function?

  • 1
    $\begingroup$ It is $2\pi$ divided by your 'angleCoef'. Try plugging this in for $x$ and see that it gives the same as when plugging in $x=0$. Your 'angleCoef' is usually called angular frequency. $\endgroup$ – M. Winter May 20 '17 at 15:57
  • $\begingroup$ @M.Winter thank you. i edited to respond to your suggestion. $\endgroup$ – Jose Martinez May 20 '17 at 16:11
  • $\begingroup$ Your plot is clearly indicating that your sine function is expecting radians and not degree. E.g. try 0.01, then $2\pi/0.01\approx 628.3$ which fits the plot. $\endgroup$ – M. Winter May 20 '17 at 16:19
  • $\begingroup$ @M.Winter thank you!!! $\endgroup$ – Jose Martinez May 20 '17 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.