Minkowski question-mark function: Difference between revisions

Content added Content deleted
m (J: make it easier to experiment with longer continued fractions (though it's not clear that this length should match for minkowski and its inverse))
m (J: remove some silliness, add a small but movtivating example)
Line 479: Line 479:
node=. t (1-b)} node
node=. t (1-b)} node
end.
end.
(<.y)+B+/ .*2x^-1+i.ITERCOUNT
(<.y)+B+/ .*2^-1+i.ITERCOUNT
}}
}}

invmink=: {{
invmink=: {{
f=. 1|y
f=. 1|y
Line 492: Line 492:
end.
end.
f=. f*2
f=. f*2
c=. -.b=. 1 >`<@.cur f
b=. 1 >`<@.cur f
cf=. cf,c#cnt
cf=. cf,(-.b)#cnt
cnt=. 1+b*cnt
cnt=. 1+b*cnt
cur=. cur=b
cur=. cur=b
Line 514: Line 514:
3.53553
3.53553
minkowski invmink (p:%%:)2
minkowski invmink (p:%%:)2
3.53553</lang>
3.53553
*:invmink 1.4 NB. square of inverse minkowski of 1.4
2</lang>


That said, note that this algorithm introduces significant numeric instability for √7 divided by 3:
That said, note that this algorithm introduces significant numeric instability for √7 divided by 3: