Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trigonometry
#11
There ain't much interest in this, so if I don't recieve another entry within 3 days of now then toonski wins. But its easy to improve what he has done, someone else challenge him.
Reply
#12
Code:
DECLARE FUNCTION GetSin# (a#) '*** CHALLENGE ENTRY ***
DECLARE FUNCTION fact# (count&) '*** NEEDED ROUTINE ***

CLS
INPUT "Enter angle in degrees (0 to 360), you wish to calculate sine for: ", a#

si# = GetSin#(a#)

PRINT "QB VALUE= "; SIN(a#)  '*** SHOW QB ANSWER ***
PRINT "MY VALUE= "; si# '*** SHOW MY FUNCTION'S ANSWER ***

WHILE INKEY$ <> "": WEND '*** PAUSE ***
WHILE INKEY$ = "":WEND
SYSTEM

FUNCTION fact# (count&) '*** CALCULATE (2n-1)! ***
     f# = 1
     FOR x& = count& TO 2 STEP -1
          f# = f# * x&
     NEXT x&

     fact# = f#
END FUNCTION

FUNCTION GetSin# (a#)
     pi# = 3.141592653589793#
     a# = a# * (pi# / 180) '*** CONVERT DEGREES TO RADIANS ***

     DO
          n& = n& + 1
          
          p1# = (-1) ^ (n& - 1) '*** DETERMINE + OR - ***
          p2# = a# ^ (2 * (n&) - 1) '*** DETERMINE NUMERATOR ***
          p3# = fact#((2 * (n&)) - 1) '*** DETERMINE DENOMINATOR ***

          s# = s# + p1# * (p2# / p3#) '*** ADJUST SUM ***
     LOOP UNTIL n& > 70

     '*** THE HIGHER n& GOES, THE MORE ACCURATE MY FUNCTION IS***
     '*** HOWEVER, HIGHER n& WILL OVERFLOW THE FACTORIAL :( ***

     GetSin = s#
END FUNCTION

*peace*

Meg.
Reply
#13
I have seen it, no time at the mo to give detailed result.
Reply
#14
Right, have reviewed it. It's very accurate, but quite long, especially compared to toonski84's entry, which he pm'ed me. Meg gets 21 challenge pts. From this post, everyone has 3 days again to improve, but at the moment toonski84 is still winning.
Reply
#15
long code-wise, or long running-time wise? it'd be really easy to make the code shorter (but somewhat less readable).

*peace*

Meg.
Reply
#16
Both, but code-wise more.
Reply
#17
without the main sub (which mine didn't include), meg's is about the same length in code size.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#18
my routines to calculate *ARC*SIN and *ARC*COS. At any rate, not that I'm doing anything but relieving boredom, I emailed Oracle my version of the type of routine he seemed to be looking for. (Oracle, hopefully you've noticed that some of my comments statements wrapped in the email. You'll have to fix those. I should've zipped it.)
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#19
Yeah, I've got it. I'll fix it and post a score here soon.

toonski: you are still winning, but perhaps not for long now you have Glenn on your case :wink: . Try making your one shorter. Same with you, Meg.
Reply
#20
Right, no more interest recently, so you all have untill friday morning my time (GMT + 1200, about 40 hours) to submit final entries else toonski wins.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)