# Only for Geniuses

## The Problem

OK, I have seen many answers. And **all** of them **are correct**!

### Why?

The problem is strangely formulated redefining the relation of “=”. But what's really meant here is that we are looking for a function $f(x)$ where:

$f(2) = 6$,

$f(3) = 12$,

$f(4) = 20$,

$f(5) = 30$, and

$f(6) = 42$.

The job is to tell the value of $f(9)$.

## First Guess

Of course, the first guess would be that

$$ f(x) = x(x+1) = x^2 + x $$

which is a quadratic function. What a genius you must be to guess this. Then the result would be 90.

## Quadratic Function

# Other functions

However, if we choose a different function complying with the task conditions, we can get **any number we want**. For example, if we want to get 150 as the result, we choose the following function:

$$ f(x) = \frac{1}{251}(6x^5-120x^4+930x^3-3229x^2+6515x-4320). $$

For zero:

$$ f(x) = \frac{1}{251}(-9x^5+180x^4-1395x^3+5471x^2-9145x+6480). $$

#### Polynomial Function 150

#### Polynomial Function 0

## How to choose the right function

We start with the original quadratic function

$$ f(x) = x(x+1) = x^2 + x $$

to which we add the following polynomial $P(x)$. We must make sure that it will be zero at the spots which are defined at the beginning, i.e.: at 2,3,4,5,6:

$$ P(x) = (x-2)(x-3)(x-4)(x-5)(x-6). $$

We can then use the function:

$$ f(x) = x^2 + x + (x-2)(x-3)(x-4)(x-5)(x-6). $$

This function definitely complies with the task conditions. You can try it yourself.

### Arbitrary Result

Now, we can get a **random result** $R$ (in plain English: **anything we want**), if we use the following function:

$$ f(x) = x^2 + x - (x-2)(x-3)(x-4)(x-5)(x-6)(90-R)/P(9), $$

where the $P(9) = 2520.$ Try it yourselves and find out that:

**It works, bitchez!**

Of course, this is just an example. In fact, there are many functions like this…

### Python Script

#!/usr/bin/env python
"""
This is a demonstration script for the "Only for Geniuses" problem.
"""
import matplotlib
import numpy as np
matplotlib.use('Qt4Agg')
import matplotlib.pyplot as plt
RESULT=0
x=[2, 3, 4, 5, 6]
y=[6, 12, 20, 30, 42]
def func(x, a, b):
return a * x**2 + b*x -((x-2)*(x-3)*(x-4)*(x-5)*(x-6)/2520*(90-RESULT))
xr = np.linspace(1.8,9.2,100)
plt.plot(x,y,'x')
plt.plot(xr,func(xr, 1, 1),'r')
plt.plot(9, func(9, 1, 1), 'o')
plt.xlabel("x")
plt.ylabel("f(x)")
plt.grid()
for i in [2,3,4,5,6,9]:
print("f(%0.2f) = %0.2f\n" % (i, func(i, 1, 1)))
plt.show()