For some reason the answer I get in the program is 7.091341682475861 It is supposed to be 6.66634. Can someone please explain to me what I am doing wrong. The equation is fairly simple and straightforward?
import math as mt
def third_side(a, b, c):
return mt.sqrt((a * a) +
(b * b) - 2 * a * b * mt.cos(c))
c = 37
a, b = 8, 11
print(third_side(a,b,c))
According to https://docs.python.org/3/library/math.html#math.cos
math.cos
takes input in radians. You should do mt.cos(c/180*mt.pi)
import math as mt
def third_side(a, b, c):
return mt.sqrt((a * a) + (b * b) - 2 * a * b * mt.cos(c/180*mt.pi))
c = 37
a, b = 8, 11
print(third_side(a,b,c))