|
I prefer computers and cats
|
|
|
|
|
Ok, it seems Mr. Bihy isn't posting it. Here's an easy one for today:
Old-fashioned mother's question (5)
I ain't got no signature.
|
|
|
|
|
Pirate Guy wrote: Old-fashioned mother's question
Aren't kiddos excessively modern these days?
Okay, let me get my coat, which I haven't got to get since Feb
|
|
|
|
|
|
Eh ?
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Nope.
I ain't got no signature.
|
|
|
|
|
With utter disgust at the wordplay ...
MUMSY
Y = question? Really? I'm still shuddering!
I am not a number. I am a ... no, wait!
|
|
|
|
|
Like it or not, you should start to preparing for tomorrow...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Just because you did't see it before? That's ridiculous really!
Anyway you are up for tomorrow.
I ain't got no signature.
|
|
|
|
|
Professional standards! If I've not seen it before it's because no crossword editor in the world would accept it.
I am not a number. I am a ... no, wait!
|
|
|
|
|
Well, whatever fancies you!
I ain't got no signature.
|
|
|
|
|
I agree
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
OR…
Why VB is better than C#.
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
Next
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?
P.S. Bonus points for identifying the function.
|
|
|
|
|
What is wrong with writing a pow() function ? Or use it from some exisiting library ?
|
|
|
|
|
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.
|
|
|
|
|
Rage wrote: What is wrong with writing a pow() function ?
Using a loop there is no need to write a pow() function:
Fac = Tu
X = array(0)
For I = 1 to 10
X = X + array(I) * Fac
Fac = Fac * Tu
Next
|
|
|
|
|
Elegant - I like it!
Now why didn't I think of that?
|
|
|
|
|
Thank you.
It is a common implementation for polynomial equations because it is much faster than using pow() .
|
|
|
|
|
No, thank you! This approach has now be stored away for future use.
Most of the stuff that I get paid for is LOB for SMEs - and you don't come across exponentiation. In any event, most clients specify VB because " My [insert relative of choice] did computers at school and can maintain it". Ha!
Just for the record, the function calculates the obliquity of the ecliptic for the given time, in radians.
Dim Tu As Double = (JulianDate - 2451545.0#) / 36525.0#
is the missing first line.
|
|
|
|
|
I must confess that I don't know much about astronomical navigation. So I would not got the first line.
I started my career (apprenticeship) in a company manufacturing yacht electronics including Gonio radio direction finders and selling LORAN-C navigators and have used those in the past sometimes. The first GPS system I ever saw was 1984 on a bridge of a brand new cargo ship. It was located in a 19" rack occupying more than 20 units.
|
|
|
|
|
In 1984 that would be the Transit system I mentioned in my first post. Despite its size, it still wasn't very good. At the very best, you got a fix every hour, but normally about every three hours. It took a long time to get a fix, and because of this it had to be interfaced to the ship's log for speed and distance traveled, and an electronic compass (or MUCH more expensive gyroscopic compass) for direction of travel. It got smaller quite quickly, and eventually became practical for the yachtsman by the end of the decade.
The Loran system, or in the UK, the Decca chain, was much better, and gave good and pretty much real-time results. However, relying on ground based stations, its range was very limited, and was no use at all out at sea. Ocean going ships still relied on the good old sextant.
True GPS became available to the public, in a restricted form, after Korean flight 007 was shot down by the Russians in 1983, courtesy of Ronald Reagan, but was nowhere like ready until 1989. The full constellation of satellites became available in 1995, and with full accuracy, courtesy of Bill Clinton in 1996, in 2000 - by which time, I am sure, the US military had something even better!
Sorry - I am a bit of a navigation geek.
|
|
|
|
|
If I read it right this part 'array(I) * Tu^I' is a constant and can be computed once...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I have a feeling you've just experienced Osborn's Law.
|
|
|
|
|
Right. Wrong word...What I meant is that it can be computed once and used everywhere...
With 3 iterations (I'm too lazy for 10) I see something like this:
X0 = ?
X1 = X0 + A0 + Tu^0
X2 = X1 + A1 + Tu^1
X3 = X2 + A2 + Tu^2
=>
X3 = X1 + A1 + Tu^1 + A2 + Tu^2
=>
X3 = X0 + A0 + Tu^0 + A1 + Tu^1 + A2 + Tu^2
Where the part 'A0 + Tu^0 + A1 + Tu^1 + A2 + Tu^2' is a fixed value (is that better than const me think )
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
A simple ipow(X, N) function may be written that requires a maximum of 2*log2[N] multiplications (may be off-by-one), and a possible division (if N was negative). If all N are known, it is possible to optimize ipow() even further, by writing custom code for each power.
For summation of polynomials, note that there are special cases where the Horner polynomial calculation may be optimized:
Even polynomials p(x) = a0 + a2*x^2 + a4*x^4 ... ==> y = x^2; p(y) = a0 + a2*y + a4*y^2 ...
Odd polynomials p(x) = a1*x + a3*x^3 + a5*x^5 ... ==> y = x^2; q(y) = a1 + a3*y + a5*y^2 ... ; p(x) = q(y) * x
...
One advantage of the alternate forms is that they preserve mathematical identities such as p(x) == p(-x) for even polynomials, and p(x) = -p(-x) for odd polynomials.
Note that using Horner polynomial evaluation Horner's method - Wikipedia, the free encyclopedia[^] saves many multiplications - you only need a maximum of 2*(N-1) multiplications and (N-1) additions for the entire polynomial.
EDIT - corrected information about polynomial evaluation
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
modified 11-Apr-16 7:17am.
|
|
|
|