27 lines
1.8 KiB
Plaintext
27 lines
1.8 KiB
Plaintext
The '''Minkowski question-mark function''' converts the continued fraction representation {{math|[a<sub>0</sub>; a<sub>1</sub>, a<sub>2</sub>, a<sub>3</sub>, ...]}} of a number into a binary decimal representation in which the integer part {{math|a<sub>0</sub>}} is unchanged and the {{math|a<sub>1</sub>, a<sub>2</sub>, ...}} become alternating runs of binary zeroes and ones of those lengths. The decimal point takes the place of the first zero.
|
||
|
||
Thus, {{math|?}}(31/7) = 71/16 because 31/7 has the continued fraction representation {{math|[4;2,3]}} giving the binary expansion {{math|4 + 0.0111<sub>2</sub>}}.
|
||
|
||
Among its interesting properties is that it maps roots of quadratic equations, which have repeating continued fractions, to rational numbers, which have repeating binary digits.
|
||
|
||
The question-mark function is continuous and monotonically increasing, so it has an inverse.
|
||
|
||
* Produce a function for {{math|?(x)}}. Be careful: rational numbers have two possible continued fraction representations:
|
||
:::* {{math|[a<sub>0</sub>;a<sub>1</sub>,... a<sub>n−1</sub>,a<sub>n</sub>]}} and
|
||
:::* {{math|[a<sub>0</sub>;a<sub>1</sub>,... a<sub>n−1</sub>,a<sub>n</sub>−1,1]}}
|
||
* Choose one of the above that will give a binary expansion ending with a '''1'''.
|
||
* Produce the inverse function {{math|?<sup>-1</sup>(x)}}
|
||
* Verify that {{math|?(φ)}} = 5/3, where {{math|φ}} is the Greek golden ratio.
|
||
* Verify that {{math|?<sup>-1</sup>(-5/9)}} = (√13 - 7)/6
|
||
* Verify that the two functions are inverses of each other by showing that {{math|?<sup>-1</sup>(?(x))}}={{math|x}} and {{math|?(?<sup>-1</sup>(y))}}={{math|y}} for {{math|x, y}} of your choice
|
||
|
||
|
||
Don't worry about precision error in the last few digits.
|
||
|
||
|
||
;See also:
|
||
* Wikipedia entry: [[wp:Minkowski%27s_question-mark_function|Minkowski's question-mark function]]
|
||
|
||
<br><br>
|
||
|