It’s probably not you; the order of operations for trigonometric functions is messed up: bug report. That bug report applies to equations, but is even more likely to apply to things that aren’t in equations. If you do this:
[code]Lab is a room.
R is a real number that varies. R is initially 90.
Latitude is a real number that varies. R is initially 90.
tanal is a real number that varies.
When play begins:
now tanal is cosine of r degrees * tangent of latitude degrees;
say “Tanal is [tanal]. Cosine of r degrees is [cosine of r degrees]. Tangent of latitude degrees is [tangent of latitude degrees].”[/code]
you get
which I think means that it’s taking (90 degrees * tangent of 90 degrees), which is 0, and taking the cosine of that, which is 1.
Put in parentheses:
[code]Lab is a room.
R is a real number that varies. R is initially 90.
Latitude is a real number that varies. R is initially 90.
tanal is a real number that varies.
When play begins:
now tanal is (cosine of r degrees) * (tangent of latitude degrees);
say “Tanal is [tanal]. Cosine of r degrees is [cosine of r degrees]. Tangent of latitude degrees is [tangent of latitude degrees].”
[/quote]
and it works (approximately):
[code]Lab is a room.
R is a real number that varies. R is initially 90.
Latitude is a real number that varies. R is initially 90.
tanal is a real number that varies.
When play begins:
now tanal is (cosine of r degrees) * (tangent of latitude degrees);
say “Tanal is [tanal]. Cosine of r degrees is [cosine of r degrees]. Tangent of latitude degrees is [tangent of latitude degrees].”[/code]
though note that the numbers aren’t exact (I suspect that the conversion to radians rounds the numbers off very slightly, leading to a tiny negative value for the cosine).
So, if something is going wrong, wrap everything in parentheses and see if that helps. If that doesn’t help, wrap it in more parentheses. (And for stuff like this it might be a good idea to use equations rather than set the values in line, because it’s likely to get very ugly-looking very quickly. Which, if I read your post already, you’re already doing.)