Author Topic: Pythagorean Nightmare in the Digital Age  (Read 423 times)

0 Members and 0 Guests are viewing this topic.

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
Re: Pythagorean Nightmare in the Digital Age
« on: July 24, 2019, 07:12:34 pm »
I am not satisfied with         nextX = 2.25 - ( [f(2.25)] / [f'(2.25)] )

             = 2.25 - ( [0.0625] / [4.5] )
             = 9/4  - ( [1/16] / [9/2] )

           = 9/4 - 139/10000
           = 2.25  - 0.0139

         = 2.236111111111111 ~=~ 2.2361

This step, here, - 139/10000, was produced by nsimplify(), a SymPy function.  It is only approximate.  I will replace it with code which performs the Fraction arithmetic, where numerator =  numerator1*denominator2 + numerator2 and denominator is denominator2.  Then the rational version will have EXACT Rational Expressions.   What's the point of having a rational number if it's just an approximation of 0.0139 = 139/10000?   I want to push the number closer in the direction of 0.013888888888888... between  0.01388 and 0.01389 somewhere.

it turns out to be (1 / 72).  I will make the correction and upload the corrected rsd.py file.

 UPDATE:  Since I can't extract the numerator and denominator from each numerator and denominator, the way I will go about it is this:

 nsimplify(0.0625)*nsimplify(1.0/4.5)
Out[8]: 1/72

This does (1/16)/(9/2) = (1/16)*(2/9) = 1/(8*9) = 1 / 72.

So, in rsd.py, I change line 119 -120:               

#tmp = round(1.0*R[1]/dy, F)

 tmp = nsimplify(R[1])*nsimplify(1.0/dy)
#num, den = farey(tmp, 500)

This eliminates my need for farey(x, 500), but I'll keep it in the file to show what lengths I was willing to go to display the Rational version as EXACTLY as possible.

That fix makes the output:

 rsd_Rational(P, 2, 2, 4)
 
 x = 2 |             | f(2)
---------------------------------------------------
        |  1    2       -1
        |  1    4 =  f'(2.0)

 f(2.0) = -1.0
 and f'(2.0) = 4.0

        nextX = 2.0 - ( [f(2.0)] / [f'(2.0)] )

             = 2.0 - ( [-1.0] / [4.0] )
             = 2  - ( [-1] / [4] )

           = 2  + [1/4]
           = 2.0  + [0.25]

         = 2.25 ~=~ 2.25
sage: rsd_Rational(P, 2, 2.25, 4)

 x = 9/4 |           | f(9/4)
---------------------------------------------------
        |  1    9/4     1/16
        |  1    9/2 =  f'(2.25)

 f(2.25) = 0.0625
 and f'(2.25) = 4.5

        nextX = 2.25 - ( [f(2.25)] / [f'(2.25)] )

             = 2.25 - ( [0.0625] / [4.5] )
             = 9/4  - ( [1/16] / [9/2] )

           = 9/4  - 1/72
           = 2.25  - 0.0139

         = 2.236111111111111 ~=~ 2.2361
sage:rsd_Rational(P, 2, 2.236, 6)

 x = 559/250 |               | f(559/250)
---------------------------------------------------
        |  1    559/250 -19/62500
        |  1    559/125 =  f'(2.236)

 f(2.236) = -0.000304
 and f'(2.236) = 4.472

        nextX = 2.236 - ( [f(2.236)] / [f'(2.236)] )

             = 2.236 - ( [-0.000304] / [4.472] )
             = 559/250  - ( [-19/62500] / [559/125] )

           = 559/250  + [4248658318425761/62500000000000000000]
           = 2.236  + [6.8e-05]

         = 2.236067978533095 ~=~ 2.236068

Look at that Fraction!   This is my point.  In the first couple of approximations rational form is reasonable (no pun intended on that one), but in this third phase of the process,  It is far easier to add or subtract decimal representation 0.000068 from 2.236 than to add or subtract [4248658318425761/62500000000000000000] to/from 559/250.    :-\ 

Trust me, all this will be worth the effort when I start doing these by hand, and need to organize my scratch work in order to master this method.  I can see working with whatever form is clearest until only decimal form is feasible for the poor ape-like sentient meat-head who must muster patience to perform the required arithmetic.   These methods aim to reduce the drudgery, not eliminate it altogether.  What;s cool though is that you may only really need to carry out the repeated division twice, in which case the rational form takes you fairly far into the calculations by hand before becoming quite ugly and not easy to operate with in that most exact form.

I'll have to edit the previous post, after which I will mark as UPDATED.
« Last Edit: July 24, 2019, 08:25:11 pm by gorticide »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~