Convert amount currency_1 to currency_2
and prints results in the obvious way. Here are a couple of
sample runs:
Command: Convert 3.50 Euros to Dollars Results: |
Command: Convert 3.50 Euros to Pounds Results: |
Command: Convert 3.50 Euros to Dollars Canadian Results: |
Command: Convert 11.72 Dollars US to Dollars Canadian Results: |
And here's the plot that is produced by Excel with that data:
cmath
library has a function asin()
that computes the arcsine of an angle. Enter man asin
on the command line for documentation.
We have a bit of a problem in that for any positive angle $\theta$
less than $\pi/2$, we have that $\sin(\theta) = \sin(\pi - \theta)$.
Thus, when we use $\theta$ = asin(w)
for positive w
,
we don't know whether we really want the angle
$\theta$ or $\pi - \theta$.
In our triangle case, we cans fix things like this: if the three
angles we calculate (A, B and C) sum up to a lot less than $\pi$ (in fact, we
should probably check that the sum is less than 3), we replace the
angle opposite the longest side with $\pi$ minus that angle. So,
for example, if $A$ is opposite the longest side, then
we replace $A$ with $\pi - A$.
cmath
, the
constant M_PI
gives you a high-precision double
representation of $\pi$.
sqrt( )
computes square roots.