HP42s first major program (Double Integral) Best way to approach?
|
06-01-2020, 06:11 PM
(This post was last modified: 06-14-2020 03:08 PM by Albert Chan.)
Post: #37
|
|||
|
|||
RE: HP42s first major program (Double Integral) Best way to approach?
(06-01-2020 01:02 PM)Werner Wrote: Well, I had to try that out, Albert! Very nice ! Suggestion: Your AGM2 code had AGM(a,b) in Y register, instead of expected X The fix actually made the code shorter, by deleting Line 47, Line 61 To make the name more suggestive, rename "AGM2" as simply "AGM" With these changes, on Free42, we calculate Pi via AGM, like this. 0.5 SQRT 1 XEQ "AGM" [X^2] [X<>Y] / 2 * → 3.141592653589793238462643383279504 Another example, ellipse_perimeter(50, 10): 50 Enter 10 + 50 Enter 10 * SQRT 2 * XEQ "AGM" / ; "diameter" of ellipse = y/x PI * → 210.100445397 Or, 50 Enter 10 XEQ "AGM" [X<>Y] 10 [X↑2] + [X<>Y] / ; "diameter" of ellipse = (y+b²)/x PI * → 210.100445397 For the same reason, I would rename "KE" as "EK", since E is in X register Again, for ellipse_perimeter(50, 10): Perimeter = 4 a E(e), where a = 50, e = √(1-0.2^2) = √0.96 0.96 SQRT XEQ "EK" ; E(e) 200 * ; 4 a → 210.100445397 What do you think ? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 23 Guest(s)