# What type of mathematical function is this?

**URL:** <https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790>\
**Category:** Factual Questions\
**Created:** [January 8, 2008, 11:04pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790 "2008-01-08T23:04:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![WarmNPrickly](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@WarmNPrickly](https://boards.straightdope.com/u/WarmNPrickly)\
**Post date:** [January 8, 2008, 11:04pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/1 "2008-01-08T23:04:33Z")

</div>

Suppose a function f(x) was defined so that an inversion around the decimal point occured.

ie.

f(1.2) = 2.1  
f(13.2) = 2.31

From what I remember, this function is one to one and onto for rational numbers. I have no idea how I know that, but I’m pretty sure that it means that each number has it’s own unique solution within the set of rational numbers.

Now suppose we define a new function as g(x) = f(f(x) + f(x)). All of the sudden I think that g(x) is one to one and onto for all real numbers. But if you try to plot it, you get a graph that seems to be fractal in it’s dimension. The problem of course is that you can never compute all of the in-between numbers.

What type of math is this, and is it useful in any way?

---

<div class="post-metadata">

**Author:** ![Squink](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Squink](https://boards.straightdope.com/u/Squink)\
**Post date:** [January 8, 2008, 11:12pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/2 "2008-01-08T23:12:59Z")

</div>

ROL and ROR are pretty useful in assembly language (base 2)  
[Logical, Shift, Rotate and Bit Instructions](http://webster.cs.ucr.edu/AoA/DOS/ch06/CH06-3.html)

> [@](#):
>
> The Rotate Instructions: RCL, RCR, ROL, and ROR
> 
> The rotate instructions shift the bits around, just like the shift instructions, except the bits shifted out of the operand by the rotate instructions recirculate through the operand. They include rcl (rotate through carry left), rcr (rotate through carry right), rol (rotate left), and ror (rotate right). These instructions all take the forms:
> 
> ```
> rcl dest, count
> rol dest, count
> rcr dest, count
> ror dest, count
> 
> ```
> 
> The specific forms are
> 
> ```
> rcl reg, 1
> rcl mem, 1
> rcl reg, imm (2)
> rcl mem, imm (2)
> rcl reg, cl
> rcl mem, cl
> 
> rol uses the same formats as rcl.
> rcr uses the same formats as rcl.
> ror uses the same formats as rcl.
> 
> ```
> 
> 2- This form is avialable on 80286 and later processors only.

---

<div class="post-metadata">

**Author:** ![WarmNPrickly](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@WarmNPrickly](https://boards.straightdope.com/u/WarmNPrickly)\
**Post date:** [January 8, 2008, 11:26pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/3 "2008-01-08T23:26:48Z")

</div>

Holy crap! I knew I was venturing into complicated territory, but I have no idea what any of that means. I left my math roots way back fifteen years ago. What is all that?

---

<div class="post-metadata">

**Author:** ![WarmNPrickly](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@WarmNPrickly](https://boards.straightdope.com/u/WarmNPrickly)\
**Post date:** [January 8, 2008, 11:34pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/4 "2008-01-08T23:34:04Z")

</div>

Allright, I get RCL and RCR, but I don’t get ROL and ROR.

---

<div class="post-metadata">

**Author:** ![Squink](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Squink](https://boards.straightdope.com/u/Squink)\
**Post date:** [January 8, 2008, 11:36pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/5 "2008-01-08T23:36:28Z")

</div>

It’s not all that complicated, just part of most [assembly languages](http://en.wikipedia.org/wiki/Assembly_language), that are used to program computer microprocessors.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 8, 2008, 11:44pm UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/6 "2008-01-08T23:44:21Z")

</div>

None of the rotation instructions work here. Rotating (a, b, c, d) left will give you (b, c, d, a), (c, d, a, b), (d, a, b, c), and finally (a, b, c, d), but not (d, c, b, a), which is what you need to get 2.31 from 13.2.

The function in the OP is easy to express in your favorite programming language as a string function, but it can’t be written as a numerical function because its value depends on the base of its input. f(2.0[sub]10[/sub]) = 0.2[sub]10[/sub] = 1/5, but f(10.0[sub]2[/sub]) = 0.01[sub]2[/sub] = 1/4.

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [January 9, 2008, 12:14am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/7 "2008-01-09T00:14:38Z")

</div>

[QUOTE=Christopher]  
Suppose a function f(x) was defined so that an inversion around the decimal point occured.

ie.

f(1.2) = 2.1  
f(13.2) = 2.31

From what I remember, this function is one to one and onto for rational numbers.  
[/QUOTE]  
Wait a minute. If x is a repeating decimal (like 1/3), what would f(x) be?

---

<div class="post-metadata">

**Author:** ![WarmNPrickly](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@WarmNPrickly](https://boards.straightdope.com/u/WarmNPrickly)\
**Post date:** [January 9, 2008, 12:15am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/8 "2008-01-09T00:15:53Z")

</div>

The real difference betwen assembly language stuff and g(x) is that g(x) is one to one and onto for the entire set of real numbers, but atleast RCL and RCR are only one to one and onto for rational numbers.

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [January 9, 2008, 12:16am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/9 "2008-01-09T00:16:26Z")

</div>

All rationals? How do you define f(1/3), or any other repeating decimal?

ETA:

OK, somebody beat me to it while I was posting. Maybe the third simulposter will at least use a different number for an example.

---

<div class="post-metadata">

**Author:** ![mks57](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mks57](https://boards.straightdope.com/u/mks57)\
**Post date:** [January 9, 2008, 12:33am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/10 "2008-01-09T00:33:08Z")

</div>

What you need is a transpose instruction, which is relatively rare on modern computers. As ultrafilter noted, the value is dependent on the base of the positional number system. Still, a similar function exists for binary numbers. Assuming a 32-bit word size and 16.16 fixed-point format, a 32-bit transpose instruction does the job in a single instruction time.

0001001000110100.0000000000000000 --\> 0000000000000000.0010110001001000

---

<div class="post-metadata">

**Author:** ![WarmNPrickly](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@WarmNPrickly](https://boards.straightdope.com/u/WarmNPrickly)\
**Post date:** [January 9, 2008, 12:40am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/11 "2008-01-09T00:40:23Z")

</div>

[QUOTE=yabob]  
All rationals? How do you define f(1/3), or any other repeating decimal?

[/QUOTE]

Good point. f(x) is not one to one and onto for all rational numbers, but for all non-repeating rational numbers. What about g(x)? Is g(x) one to one and onto for all rational numbers?

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [January 9, 2008, 12:50am UTC](https://boards.straightdope.com/t/what-type-of-mathematical-function-is-this/432790/12 "2008-01-09T00:50:05Z")

</div>

[QUOTE=Christopher]  
Good point. f(x) is not one to one and onto for all rational numbers, but for all non-repeating rational numbers. What about g(x)? Is g(x) one to one and onto for all rational numbers?  
[/QUOTE]  
You’d still have to exclude repeating decimals, since g(x) is defined in terms of f(x). (Unless there’s some tricksy way of expanding the range of f(x) to allow for things like f(1/3).)

I suspect g(x) is one-to-one and onto for all terminating-decimal numbers, because you can invert it: g[sup]-1[/sup] = f( f(x)/2 ). But that’s just off the top of my head; I hesitate to call it a proof.
