My birthday, so a little commemorative minichallenge ! Message #1 Posted by Valentin Albillo on 5 Mar 2013, 7:34 a.m.
Hi all,
As fate would have it, today's my birthday (don't ask) so I think that a little commemorative minichallenge is in order, namely:
The commemorative minichallenge
Write a short program or code snippet to evaluate a given polynomial at any given particular argument X, without explicitly using either multiplication/division operators (*, /)(that excludes reciprocals as well) or addition/subtraction operators (+, ).
For good measure, any and all kinds of conditional, looping, or GoTo statements or constructions are forbidden as well so no equivalents to IF, GOTO, SELECT, CASE, UNTIL, WHILE, LOOP, FOR, ... you get the point.
To simplify matters a little you can particularize your code to evaluate this particular 5thdegree polynomial:
y = 5 x^{5} + 8 x^{4} + 4 x^{3} + 2 x^{2} + 3 x + 1
for any given argument X (the generalization to arbitrary polynomials is obviously straightforward).
Assorted HP models can be used for this challenge (not all can deliver) but in case your particular model has a builtin (or library's) polynomial evaluation functionality (say "CALL POLYEV(coefficients, X)") you're asked not to use it lest you'll ruin the challenge for yourself.
I'll give a 3line HP71B solution, which runs like this:
>RUN
? PI ( X value )
2463.56024568 ( P(x) )
>RUN
? 7
66121
Try your hand at it, it's actually quite easy !
Best regards from V.
