The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Anything that is unrelated to elephants is irrelephant Anonymous - The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 - I'd just like a chance to prove that money can't make me happy. Me, all the time
Back in the days before GPS, and when Transit took up half the bridge on a destroyer, I navigated by sextant and Admiralty tables. After four years working in Iraq, I took a year off to go sailing, so thought I would computerise the tables function – using an HP75C (no Interwebs back then). I built a digital almanac in HP Basic, good for plus or minus 3k years, handling the Sun, Moon and GHA Aries. I had to jump through a few hoops to fit it all into 24k, but it worked admirably – worst landfall error 1/3 of a mile.
Later, I rewrote it in Classic VB and added the six navigational planets, and a star catalogue of the 57 navigational stars plus Polaris. Then I moved it into VB.net, and added a few more bells and whistles, just for the hell of it - running fixes, great circle routes etc.
I have now decided to put it into C#, and Xamarinate™ it for my Android tablet. Yesterday, I had a quick look through the code to see what gotchas might lie hidden and…
An eleven element array containing the relevant constants, and a loop:
For I = 0 to 10
X = X + array(I) * Tu^I
Has now turned into
X = 0.40909280422233 _
- 0.02269378904316 * Tu _
- 0.00000751461206 * Tu * Tu _
+ 0.00969263751958 * Tu * Tu * Tu _
- 0.00024909726935 * Tu * Tu * Tu * Tu _
- 0.00121043431763 * Tu * Tu * Tu * Tu * Tu _
- 0.00018931974247 * Tu * Tu * Tu * Tu * Tu * Tu _
+ 0.00003451873409 * Tu * Tu * Tu * Tu * Tu * Tu * Tu _
+ 0.00013511757293 * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu _
+ 0.00002807071214 * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu _
+ 0.00001187793519 * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu * Tu
This is just one of dozens of functions using exponentiation.
Please can I scream now?
pow() is a trigonometric function, and therefore rather slow - some of these functions run many times in a single calculation. I would only use it for fractional exponents, for which there is no other solution. As for using a different library, I have zero experience of Xamarin, so I am not sure how that would be handled. I am porting this code to get some idea of using Xamarin.