Well in my opinion trying to create a sine wave output from a pwm analogWrite() command is a pretty difficult thing to do, as you have two variables that have to be manipulated, duty cycle for the amplitude information and update time for the frequency information, followed by the required external low-pass filtering required.
I would think a easier solution would be to run the tone library code, set it to output a continuous 40Hz square wave output signal, then have pass it through an external low-pass (or narrow bandpass) filter to extract the sine wave required.
Lefty