McJohnalds
McJohnalds

Reputation: 85

Problems with calculating Law of Sines

In my math class we are currently in a basic trigonometry unit, with Law of Sines/Law of Cosines. I occasionally write programs that let me input known values and get answers from that input when I am bored.

I am struggling with the Law of Sines Side/Side/Angle rules, however. I am using this problem as a test (apologies for the quality): The problem worked out on paper:

When worked out on paper, it equals roughly 15 degrees.

This is the code I have in place:

# SSA
x = float(input("Known Angle Degrees: "))
y = float(input("Length of Side Opposite Known: "))
z = float(input("Length of Side Opposite Unknown: "))

a = (math.sin(math.radians(x))/y)*z
b = math.asin(a)

print(str(a))
print(str(b))

And this is the result I get:

Known Angle Degrees: 48
Length of Side Opposite Known: 63
Length of Side Opposite Unknown: 22
0.2595108914365504
0.26251570863497786

It clearly gets everything right until getting the reverse/arc sine of a. I'm just not sure what is wrong here. When getting the value of b, I've tried converting A to radians, and to decimals, and instead of using asin(), using sin() raised to -1. Nothing's worked.

Any ideas?

Edit: Apologies, I did not include that I had imported the math module. Sorry.

Upvotes: 3

Views: 1065

Answers (2)

Data_Is_Everything
Data_Is_Everything

Reputation: 2017

You need to include the radians to degrees conversion as well, so like this:

 import math
 angleB = math.degrees(math.asin(0.259))
 print(angleB)
 ### Output is 15 degrees (truncated)

Upvotes: 1

Robby Cornelissen
Robby Cornelissen

Reputation: 97322

You're just missing a conversion back from radians to degrees:

>>> math.degrees(math.asin(0.2595108914365504))
15.041042160670253

Upvotes: 3

Related Questions