Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread Don Guinn
00│ │ 89r144│ > > >> │0.61802575107296143│ │ 144r233│ > > >> │0.61803713527851456│ │ 233r377│ > > >> │0.61803278688524588│ │ 377r610│ > > >> │0.61803444782168182│ │ 610r987│ > > >> │0.6180338134001252000

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread Raul Miller
On Mon, Apr 8, 2019 at 12:37 PM William Tanksley, Jr wrote: > Raul Miller wrote: > > They can, which is disturbing. > > However, they don't have to (and they have some other advantages, also...). > > They do have to (round and otherwise display non-arithmetic behavior). > All floats are actually

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread William Tanksley, Jr
Raul Miller wrote: > They can, which is disturbing. > However, they don't have to (and they have some other advantages, also...). They do have to (round and otherwise display non-arithmetic behavior). All floats are actually rational numbers which follow a specific format and truncate in specific

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread Raul Miller
0.61538461538461542│ │ 8r13│ > > >> │0.61904761904761907│ │ 13r21│ > > >> │0.61764705882352944│ │ 21r34│ > > >> │0.61818181818181817│ │ 34r55│ > > >> │0.61797752808988760│ │ 55r89│ > > >> │0.61805555555580000│ │ 89r144│ >

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread William Tanksley, Jr
1808│ │ 89r144│ > >> │0.61802575107296143│ │ 144r233│ > >> │0.61803713527851456│ │ 233r377│ > >> │0.61803278688524588│ │ 377r610│ > >> │0.618034447821681820000│ │ 610r987│ > >> │0.61803381340012520│ │ 987r1597│ > >> │0.61

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread 'Mike Day' via Programming
84│ >> │0.61803396316670656│ │ 2584r4181│ >> │0.618033998521803410000│ │ 4181r6765│ >> │0.61803398501735796│ │6765r10946│ >> └───┴─┴──┘ >> >> Linda >> >> >> >> -Original Message---

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread Ian Clark
65r10946│ > └───┴─┴──┘ > > Linda > > > > -----Original Message- > From: Programming On Behalf Of > William Tanksley, Jr > Sent: Friday, March 29, 2019 12:23 PM > To: Programming forum > Subject: Re: [Jprogramming]

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-04-08 Thread Linda Alvord
To: Programming forum Subject: Re: [Jprogramming] converting from 'floating' to 'rational' Ian Clark wrote: > But why should I feel obliged to carry on using lossy methods when > I've just discovered I don't need to? Methods such as floating point > arithmetic, pl

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-31 Thread Don Kelly
I see what you are doing and for many things using rational numbers is very useful  (i.e. I've used 1r3p1)and the internal representation is a few bits better than a floating point number. Is this important considering that often numbers that aren't rational or involve operations that may requi

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-31 Thread Ian Clark
@William -- I've bought Wildberger's book, on your recommendation. Right up my street! > Do keep us posted -- I for one would love to see the result. If I get results with this (and I am getting results already) you won't be able to shut me up! :-) On Sun, 31 Mar 2019 at 23:29, William Tanksley,

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-31 Thread William Tanksley, Jr
Ian Clark wrote: > accurate timing for GPS satellites. Both require significant relativistic > corrections: not Special relativistic but General relativistic. When it's OK, you have GOT to check out Wildberger's rational trig -- especially his "universal hyperbolic geometry", which extends the w

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-31 Thread Ian Clark
Don Kelly wrote > Of some interest, looking at the sine problem one can note that a =sin(a) =1.23e_5 from the first term of the series and the second term is of the order of 10e_16. The cosine series has a first term of 1 and a second of -7.56e-11. That's the very problem which has triggered my fo

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-30 Thread Don Kelly
Fair enough. I graduated in Electrical Engineering in '54, then MSc, 56 and PhD in mid 60's. I have used a slide rule and also 6 figure log tables, where needed, in the 50's. I was aware of sig figs from the first day of lectures. First programming was in '61 (using MAD (Michigan Algorithmic De

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-29 Thread William Tanksley, Jr
Ian Clark wrote: > But why should I feel obliged to carry on using lossy methods when I've > just discovered I don't need to? Methods such as floating point arithmetic, > plus truncation of infinite series at some arbitrary point. The fact that > few practical measurements are made to an accuracy

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-29 Thread Raul Miller
[This post contains no code. If you feel inclined to compose a response with similar characteristics, that probably means it's time to move this thread to the chat forum. I haven't done that here, because I felt that a hint should be left behind in the old forum when moving a thread across forums.]

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-28 Thread Ian Clark
@Devon - thanks for drawing my attention to a method of formatting I've been overlooking in favour of dyadic (":). Though it isn't actually a "display problem" I've got: more a choice of facilities I want to offer. Anyway 8!:0 is another arrow in my quiver. @Don - If your point concerning the Chur

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-27 Thread Devon McCormick
Ian - could your display problem be solved by always formatting displays but retaining arbitrary internal precision? You probably already do this but thought I'd mention it because I just had to format a correlation matrix to show only two digits of precision, but was annoyed that my rounding fnc

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-27 Thread Don Kelly
Probalbly the main problem, as exemplified in the "sine(a) problem is that a and sine a are the same within 10e-16 and the cosine is 1-7.5e-5 but the display is only 6 figures and so the displayed result is rounded to 1.  as it is closer to 1 than 0.99.  This is grade 8 rounding.Increasing

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-27 Thread Ian Clark
Raul wrote: > So I am curious about the examples driving your concern here. I'm in the throes of converting TABULA ( https://code.jsoftware.com/wiki/TABULA ) to work with rationals instead of floats. Or more accurately, the engines CAL and UU which TABULA uses. No, I don't need to offer the speed

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-27 Thread Raul Miller
On Tue, Mar 26, 2019 at 7:38 PM Ian Clark wrote: > I will still employ my "mickey-mouse" method, because it's easily checked > once it's coded. I need built-into TABULA a number of physical constants > which the SI defines exactly, e.g. > • The thermodynamic temperature of the triple point of wate

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread Ian Clark
Thanks, folks. I had a senior moment here. I was browsing my code (TABULA in fact) and posted my question based on a morning's head-scratching. Then I discovered 2 weeks ago I'd written up a literature search I'd done on rational precision -- and there was (x:) and what it could and could not do f

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread William Tanksley, Jr
Good point, Raul. Depending on what you're doing, there are more or less unconventional ways to compute triangle geometry. Probably the one best supported by the existing library is the best one to use :) . Found some links: Here's a link to Wildberger's own intro (I personally recommend ignoring

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread Ric Sherlock
If you haven't already seen it the following essay on the Jwiki may be of interest: https://code.jsoftware.com/wiki/Essays/Extended_Precision_Functions On Tue, Mar 26, 2019 at 8:08 PM Ian Clark wrote: > I'm doing trigonometry with very small angles and I want to keep all my > calculations in ra

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread Raul Miller
Or often you can avoid using angles entirely and use mechanisms based on cross product for contexts that demand "sine" and dot product for cosine... (Not always, though - especially if you're working through someone else's math notes which were explicitly about angles.) Thanks, -- Raul On Tue,

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread William Tanksley, Jr
Does J provide rational trig functions? If not, you'll want to check out N.J. Wildberger's rational trigonometry, based on "quadrance" (an unsquare-rooted distance) and "spread" (like a relative slope of quadrances). That way your rational numbers will stay rational until it's time to convert them

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread Raul Miller
The x: verb makes a best effort, converting floating point to rational. x:3.14 157r50 It's limited, of course, by both floating point precision and its own internal concepts of epsilon. I hope this helps, -- Raul On Tue, Mar 26, 2019 at 3:08 PM Ian Clark wrote: > > I'm doing trigonometry

[Jprogramming] converting from 'floating' to 'rational'

2019-03-26 Thread Ian Clark
I'm doing trigonometry with very small angles and I want to keep all my calculations in rational precision. Is there a J-supported way of converting from floating-point precision to rational, or reasonably speedy verbs to do the job routinely? My problem is this. Let PIa be π expressed as a ration