Alex
Alex

Reputation: 238

math.sin() not returning proper value

Hello I have an equation I am trying to calculate using python. Where The desired output I am looking for is 1.71528

Below I have my current code with all of the current values d should equal 100 and theta should equal 60.

import math

m = 0.065
g = 9.8
print("Input the distance to professor")
d = 100 # float(input())
k = 25
print("Now input the value for theta")
theta = 60 # float(input())

x = math.sqrt(m*g*d/k*math.sin(2 * theta))
print(x, 'meters')

The output I get when I run this code is 1.2163047715819324 meters

I think my issue is something with math.sin any help would be appreciated thanks.

Upvotes: 0

Views: 405

Answers (1)

ai2ys
ai2ys

Reputation: 1571

Convert to theta to radians and put brackets around the denominator.

x = math.sqrt(m*g*d/(k*math.sin(2 * math.radians(theta))))
print(f"{x:.5f} meters")

Will result in

Input the distance to professor
100
Now input the value for theta
60
1.71528 meters

Upvotes: 3

Related Questions