[Question]
  [
For this challenge you need to implement two functions, **f** and **g**, on the integers, such that **f ∘ g** is a strictly decreasing function while **g ∘ f** is a strictly increasing function. In other words, if you take any two integers **a < b**, then **f(g(a)) > f(g(b))** and **g(f(a)) < g(f(b))**. There are no restrictions on **f** and **g** individually, except that they must each map one integer to another integer.
Please include a short description of **f** and **g** and an argument for why they have the required property.
**Credit:** This challenge was inspired by a problem in the 2011 Romanian Master of Mathematics competition (which asks the same thing but on the real numbers, instead of integers). If you really want spoilers, you now know what to search for.
## Rules
* The word "function" in this challenge should be taken in the mathematical sense of mapping one integer to another: you may either write [two programs or two functions](https://codegolf.meta.stackexchange.com/q/2419) and use any of the [standard methods](https://codegolf.meta.stackexchange.com/q/2447) of receiving input and providing output, as usual. You may use string representations of integers instead of actual integer variables, but the types of input and output should be identical, so that the functions can be composed without manually converting types in between. Remember that conceptually, **f** and **g** still need to be functions on ℤ, so you can't cheat by using two different string representations of the same number or anything like that.
* Remember that [functions may be unnamed](http://meta.codegolf.stackexchange.com/questions/1501/should-function-literals-be-allowed-when-a-function-is-asked-for/1503#1503), as long as their name isn't needed by itself or another function you define. If you do name one or both of the functions, you may assume that they exist in the same program, so that they may refer to each other in their implementation (e.g `def f(x): return -g(x)` in Python).
* The usual integer overflow rules apply: your solution must be able to work for arbitrarily large integers in a hypothetical (or perhaps real) version of your language in which all integers are unbounded by default, but if your program fails in practice due to the implementation not supporting integers that large, that doesn't invalidate the solution.
* You may use any [programming language](https://codegolf.meta.stackexchange.com/q/2028), but note that [these loopholes](https://codegolf.meta.stackexchange.com/q/1061/) are forbidden by default.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so your score is the sum of the *number of bytes* of both functions and the shortest valid answer wins.
  
[Answer]
# Python, 68 characters
```
f=lambda x:(1-x%2*2)*(2*x*x+(x<0))
g=lambda x:(1-x%2*2)*(2*x*x+(x>0))
```
f maps negative numbers to odd numbers and positive numbers to even numbers, and even numbers to positive numbers and odd numbers to negative numbers, with the output magnitude increasing strictly with the input magnitude.
g does the same, except it maps negative numbers to even numbers and positive numbers to odd numbers.
f ∘ g maps negative → even → positive and positive → odd → negative.  
g ∘ f maps negative → odd → negative and positive → even → positive.
Therefore f and g have the desired properties.
[Answer]
## CJam (17 bytes)
Function f (named `F` because CJam only allows upper-case names):
```
{W1$2b,#*}:F
```
Function g (anonymous):
```
{F2*}
```
[Online demo](http://cjam.aditsu.net/#code=%7BW1%242b%2C%23*%7D%3AF%7BF2*%7D%0A%0A%3AG%3B%3B%0A21%2C10f-%7BFG%7D%25p%0A21%2C10f-%7BGF%7D%25p%0A)
This saves a byte by relying on a implementation detail of CJam which is arguably a bug: when doing base conversions it uses absolute value. `2b,` therefore gives the number of bits in the absolute value of its argument, so f negates precisely those numbers whose absolute value has an odd number of bits. g applies f and then doubles (changing the parity of the number of bits).
So applying f and then g leaves sign unchanged and doubles, mapping `x` to `2x`. Applying g and then f changes the sign exactly once and doubles, mapping `x` to `-2x`.
[Answer]
# [Python](https://docs.python.org/2/), 40 bytes
```
f=lambda x:x*(-1)**x
g=lambda x:3*f(x)+1
```
[Try it online!](https://tio.run/nexus/haskell#@5@mUGFboaWha6ippVXBlQ7kGWobawFF/@cmZuYp2CrkJhb4KhQUZeaVKKgoRAN5CoUK0bqGBnp6hgaxCjUKhTa60Wl66ToK6XppsbH/AQ "Haskell – TIO Nexus") Some outputs are floats that equal integers because `(-1)**(-3)` gives a float for instance.
Based off [ideas from Peter Taylor](https://codegolf.stackexchange.com/a/115558/20260). The function `f` negates odd numbers and leaves even ones unchanged. The function `g` does the same, then applies the monotonic parity-switching map `x -> 3*x + 1`.
Since `f(f(x)) = x`, we have `g(f(x)) = 3*f(f(x))+1 = 3*x+1` increasing.
For `f(g(x)) = f(3*f(x)+1)`, the idea is that exactly one of the inner and outer `f` flips sign, making it decreasing. 
* For even `x`, `f(x) = x`, but `f(3*x+1) = -3*x-1` because `3*x+1` is odd.
* For odd `x`, `f(x) = -x`, and `f(-3*x+1) = -3*x+1` because `-3*x+1` is even.
We now only need the even and odd inputs interleave in a decreasing way, which holds because `-3*x±1` is decreasing regardless of how the signs are chosen. This is why the `3*` is needed.
A Haskell port is 25 bytes:
```
f x=x*(-1)**x
g x=1+3*f x
```
[Try it online!](https://tio.run/nexus/haskell#@5@mUGFboaWha6ippVXBlQ7kGWobawFF/@cmZuYp2CrkJhb4KhQUZeaVKKgoRAN5CoUK0bqGBnp6hgaxCjUKhTa60Wl66ToK6XppsbH/AQ "Haskell – TIO Nexus")
[Answer]
# Pyth, 34 Bytes
This is just a direct translation of my Python answer.
```
*-1*2%Q2+*2*QQ<Q0
*-1*2%Q2+*2*QQ>Q0
```
]