# Re: [Jprogramming] Fractional parts

```Continued fractions come immediately to mind as an application, per
http://code.jsoftware.com/wiki/Essays/Continued_Fractions
Suggestions here might be suitable to remove restrictions mentioned in that
essay.```
```
Continued fractions themselves are applied in at least the ways stated in
https://math.stackexchange.com/questions/585675/what-are-the-applications-of-continued-fractions

I am working a bit with Diophantine equations, so they seem like a natural tool
to me.

Sent from Mail for Windows 10

From: Skip Cave
Sent: Wednesday, August 9, 2017 1:09 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Fractional parts

Markus,

Actually, yes, I looked at using extended precision, and here's what
happened:

v=:2%(3r19-%x:1 2 3 245 246 247 248)

​v
_19r8 _76r13 _57r5 4655r358 9348r719 13 9424r725​

fp=. * * 1||

fp v

_3r8 _11r13 _2r5 1r358 1r719 0 724r725

ip=: * * <.@|

ip v

_2 _5 _11 13 13 13 12

So our original definitions would work with extended precision, but the
fractional parts would be rational rather than decimal. Extended precision
still keeps the negative signs on the fractions.

I'm not so sure about Martin's approach with extended precision:

mfp1 =: 1&|     NB. Martin's first suggestion for fractional part

mfp1 v

5r8 2r13 3r5 1r358 1r719 0 724r725

mfp2 =: 1&#:    NB. Martin's second suggestion for fractional part

mfp2 v

5r8 2r13 3r5 1r358 1r719 0 724r725

fp v      NB. First fractional part proposal

_3r8 _11r13 _2r5 1r358 1r719 0 724r725

However, mfp1 & mvfp2 have lost the sign, so combining them by adding
doesn't work for the negative numbers:

v

_19r8 _76r13 _57r5 4655r358 9348r719 13 9424r725

ip v

_2 _5 _11 13 13 13 12

mfp1 v

5r8 2r13 3r5 1r358 1r719 0 724r725

(ip v) + (mfp1 v)

_11r8 _63r13 _52r5 4655r358 9348r719 13 9424r725

(ip v) + (mfp2 v)

_11r8 _63r13 _52r5 4655r358 9348r719 13 9424r725

v

_19r8 _76r13 _57r5 4655r358 9348r719 13 9424r725

Skip Cave
Cave Consulting LLC

On Wed, Aug 9, 2017 at 10:45 AM, Schmidt-Gröttrup, Markus <
m.schmidt-groett...@hs-osnabrueck.de> wrote:

> Skip, have you considered to use extended precision?
> In your example only small fraction are used, and the methods discussed
> would apply as well without precision problems.
>
> v=:2%(3r19-%x:1 2 3 245 246 247 248)
>
> I haven’t read the whole thread, so sorry if this contribution doesn’t fit.
>
> Markus
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm```