Discussion:
Trig question
(too old to reply)
Beverly Howard
2010-05-29 22:06:13 UTC
Permalink
Last time I worked with trig functions was half a century ago... help!

sin^2(x)

How would the above be notated in Foxpro

I found this

sin^2(x) = 1/2 - 1/2 cos(2x)

...but have no basis to know if that's correct.

Beverly Howard
Rush Strong
2010-05-29 22:52:52 UTC
Permalink
Post by Beverly Howard
Last time I worked with trig functions was half a century ago... help!
sin^2(x)
How would the above be notated in Foxpro
I found this
sin^2(x) = 1/2 - 1/2 cos(2x)
...but have no basis to know if that's correct.
Beverly Howard
SIN^2(x) = SIN(x) * SIN(x)

[But NOT SIN(X * X)]

Not so triggy, was it?

- Rush
Rush Strong
2010-05-29 22:53:05 UTC
Permalink
Post by Beverly Howard
Last time I worked with trig functions was half a century ago... help!
sin^2(x)
How would the above be notated in Foxpro
I found this
sin^2(x) = 1/2 - 1/2 cos(2x)
...but have no basis to know if that's correct.
Beverly Howard
SIN^2(x) = SIN(x) * SIN(x)

[But NOT SIN(X * X)]

Not so triggy, was it?

- Rush
Rush Strong
2010-05-29 22:54:20 UTC
Permalink
Post by Beverly Howard
Last time I worked with trig functions was half a century ago... help!
sin^2(x)
How would the above be notated in Foxpro
I found this
sin^2(x) = 1/2 - 1/2 cos(2x)
...but have no basis to know if that's correct.
Beverly Howard
SIN^2(x) = SIN(x) * SIN(x)

[But NOT SIN(X * X)]

Not so triggy, was it?

- Rush
Rush Strong
2010-05-30 02:13:27 UTC
Permalink
Post by Rush Strong
Post by Beverly Howard
Last time I worked with trig functions was half a century ago... help!
sin^2(x)
How would the above be notated in Foxpro
I found this
sin^2(x) = 1/2 - 1/2 cos(2x)
...but have no basis to know if that's correct.
Beverly Howard
SIN^2(x) = SIN(x) * SIN(x)
[But NOT SIN(X * X)]
Not so triggy, was it?
- Rush
No, no idea why the triple send. Please file one copy, print
another, and forward the third to someone you don't like.

- Rush
Beverly Howard
2010-05-30 02:40:27 UTC
Permalink
triple send <<
death rattle?
sin^2(x) <<
hmmm... http://math2.org/math/trig/identities.htm

...too tired to see if the formulas yield the same value.

fwiw, the original need came from trying to understand and used the
Haversine Formula at http://www.movable-type.co.uk/scripts/gis-faq-5.1.html

will report back when I run some tests tomorrow.

Thanks...
...in triplicate,
Beverly Howard
Beverly Howard
2010-05-30 13:57:15 UTC
Permalink
Ahhh... success

The code is small and it works... life is good ;-)

In case it might be of value to others,
Beverly Howard

=======

* To find the distance (in this case km) between two sets of lat/lon
* decimal degree coordinates;

param lat1,lon1,lat2,lon2

* convert degrees to radians
lat1 = lat1*3.141592/180
lon1 = lon1*3.141592/180
lat2 = lat2*3.141592/180
lon2 = lon2*3.141592/180

* a good discussion the Haversine formula with samples
* is at http://www.movable-type.co.uk/scripts/latlong.html

d = ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371

return d

* the value 6371 is the mean radius of the earth in km...
* replace it with the value for your distance unit of choice
* in order to return the distance in that unit.
MikeA
2010-05-30 23:59:11 UTC
Permalink
They are transcendental numbers. Not the we need the series but back in the
old days where we didn't have a function to call:

Sin(X) = X - X^3/3! + X^5/5! - X^7/7!
Post by Beverly Howard
Ahhh... success
The code is small and it works... life is good ;-)
In case it might be of value to others,
Beverly Howard
=======
* To find the distance (in this case km) between two sets of lat/lon
* decimal degree coordinates;
param lat1,lon1,lat2,lon2
* convert degrees to radians
lat1 = lat1*3.141592/180
lon1 = lon1*3.141592/180
lat2 = lat2*3.141592/180
lon2 = lon2*3.141592/180
* a good discussion the Haversine formula with samples
* is at http://www.movable-type.co.uk/scripts/latlong.html
d = ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371
return d
* the value 6371 is the mean radius of the earth in km...
* replace it with the value for your distance unit of choice
* in order to return the distance in that unit.
Loading...