[Tutor] Trigonometric Functions in Python

Alan Gauld alan.gauld at yahoo.co.uk
Mon May 25 03:29:16 EDT 2020


On 25/05/2020 01:09, April Morone wrote:

> Severance on page 45. Please explain for me how the following checks the
> result of the conversion from degrees to radius to get  0.7071067811865476
> to see if the result is correct:
> 
> math.sqrt(2) / 2.

This is a slightly unusual way of expressing 1/sqrt(2) which
is the definititive value for sin(45degrees) (Think of a
45 degree right-angled triangle of short length 1.
By pythagorus the hypoteneuse is sqrt(2) so sine is 1/sqrt(2)...

>>>> degrees = 45
>>>> radians = degrees / 360.0 * 2 * math.pi
>>>> math.sin(radians)
> 0.7071067811865475

And this is the sin(45 degrees) using radian conversion.

So if both values are the same it demonstrates that the radian
conversion must be correct.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list