Jump to content

Wrong solution with sin() [solved]


php_joe

Recommended Posts

Hi, I'm having some problems with a math function not giving me the answer that I expect.

 

Wikipedia says that you can find a side of a triangle if you know an angle and 2 sides using the law of cosine:

a2c3a9527af895a3fa6e8e9d0bb1b30d.png

http://en.wikipedia.org/wiki/Law_of_cosines

 

so I used this code:

<?
$a = '5';
$b = '5';
$c = sqrt(pow($a, 2) + pow($b, 2) - (2 * $a * $b * cos(135)));
echo "$c";
?>

And it gave me the correct (I think) answer: 9.9902148003463

 

But when I try to find a side using 2 angles and a side using the law of sine it doesn't work.

 

The equation that I have is "b = (12 Sin 65)/(sin 50)" from http://home.alltel.net/okrebs/page93.html so I used this code:

<?
$b = 12 * sin(65) / sin(50);
echo "$b";
?>

Which, according the the website that I got it from, should have printed "14.2", but I got "-37.815911143213" instead.

 

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/43644-wrong-solution-with-sin-solved/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.