How to use trigonometric functions with Data.Scientific?

Hi, I am writing a program to do some astronomical calculation, and I am using the Data.Scientific library to represent my floating point numbers. Would anyone know how to use trigonometric functions with the Scientific type? I see: a :: Scientific a = scientific 500036 (-5) sin :: Floating a => a -> a -- this won't work wrongType = sin a Any ideas? Many Thanks Martin

You should be able to use sin (toRealFloat a). But I imagine that could
introduce some error into your calculations. You will have to make sure
you put enough type signatures to infer Double.
On Tue, Jun 2, 2015 at 6:51 AM, Martin Vlk
Hi, I am writing a program to do some astronomical calculation, and I am using the Data.Scientific library to represent my floating point numbers. Would anyone know how to use trigonometric functions with the Scientific type?
I see: a :: Scientific a = scientific 500036 (-5)
sin :: Floating a => a -> a
-- this won't work wrongType = sin a
Any ideas?
Many Thanks Martin _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

David McBride:
You should be able to use sin (toRealFloat a). But I imagine that could introduce some error into your calculations. You will have to make sure you put enough type signatures to infer Double.
Hi David, many thanks for your reply. In the end I found the problem was not in precision, but rather a much more mundane mistake - I failed to notice the trigonometric functions expect input value in radians, not degrees. Doh! :-) Now my calculation works as expected. Thanks again Martin
participants (2)
-
David McBride
-
Martin Vlk