# Daedalus' Eleventh Challenge

## Recommended Posts

My recent work on the Collatz conjecture has lead to the development of a method that allows me to merge the outputs of two functions into one function. To construct this new function, I only use the functions being joined, and elementary operations such as addition / subraction, multiplication / division, and exponents. Furthermore, I map the output of one function to odd numbers in the domain and the output of the other function to even numbers. So, the domain is restricted to integers, but the range can be whatever the functions output. This challenge is actually pretty easy, and the goal is to formulate the mathematics to join the outputs of

$f(x)=2^x$ and $g(x)=3^x$

such that for the inputs / domain of { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... }, the new function produces the outputs / range of { 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, ... }

Edited by Daedalus

##### Share on other sites

Did my answer in steps to not spoil it all at once...

I've done similar things with programming... it's easier if you can use an "integer division remainder" operator. Then you can use the least significant bit as a switch between 2 different functions.

So I figure the first step is to find a function that alternates between two values... basically an oscillator or simple wave or whatever.

(-1)^x alternates between 1 for even x, and -1 for odd.

An alternator between 0 (for odd) and 1 (for even): $a=\frac{(-1)^x+1}{2}$

$base = a+2$

The exponent is basically ceiling(x/2), or alternately adjusting to handle the odd numbers: $exponent = (x+1-a)/2$

$answer = base^{exponent}$

$= \left(\frac{(-1)^x+5}{2}\right)^{\left(2x-((-1)^x-1)\right)/4}$

##### Share on other sites

Did my answer in steps to not spoil it all at once...

I've done similar things with programming... it's easier if you can use an "integer division remainder" operator. Then you can use the least significant bit as a switch between 2 different functions.

So I figure the first step is to find a function that alternates between two values... basically an oscillator or simple wave or whatever.

(-1)^x alternates between 1 for even x, and -1 for odd.

An alternator between 0 (for odd) and 1 (for even): $a=\frac{(-1)^x+1}{2}$

$base = a+2$

The exponent is basically ceiling(x/2), or alternately adjusting to handle the odd numbers: $exponent = (x+1-a)/2$

$answer = base^{exponent}$

$= \left(\frac{(-1)^x+5}{2}\right)^{\left(2x-((-1)^x-1)\right)/4}$

Hell yeah Md65536!!! You earned that rep. quick. I'm going to let this stand for a day or two before I post my usual break down to see if anyone posts the general solution for any $f(x)$ and $g(x)$. Since we know you can do it, let's see if anyone else can figure that one out.

##### Share on other sites

Anyone working on the general solution for this challenge?

##### Share on other sites

Anyone working on the general solution for this challenge?

I tried, thinking there must be a simpler solution than I gave...

is_even = ( (-1)^x + 1 )/2

x_odd = (x+1)/2

x_even = x/2

joined_function = (1-is_even) * f(x_odd) + is_even * g(x_even)

I think that's it... and then I was interested in whether or not this could be simplified but I gave up.

##### Share on other sites

Well, it's been long enough and Md65536 did solve the original problem. So, I will give my usual breakdown for the general solution for this challenge.

As Md65536 has shown, we can generate an equation that produces a 1 or 0 if an integer is odd or even. Let's define the equation that produces a 1 for odd numbers as

$\alpha(x)=\frac{1-(-1)^{x}}{2}$ which, starting from $x=1$, produces the sequence, $\{1,0,1,0,1,0,\text{...}\}$ [1]

and the equation that produces a 1 for even numbers as

$\beta(x)=\frac{1+(-1)^{x}}{2}$ which, starting from $x=1$, produces the sequence, $\{0,1,0,1,0,1,\text{...}\}$ [2]

If we add $\alpha(x)$ and $\beta(x)$ we can prove that the sum produces a 1 for all integers in the domain:

$\alpha(x)+\beta(x)=1$

$\frac{1-(-1)^{x}}{2} + \frac{1+(-1)^{x}}{2}= 1$

$\frac{1}{2} + \frac{1}{2}= 1$

Next, we need to take $f(x)$ and $g(x)$ and multiply each function by either $\alpha(x)$ or $\beta(x)$. We can see that multiplying $\alpha(x) \times f(x)$ will allow the range of $f(x)$ to be mapped to odd numbers in the domain, and multiplying $\beta(x) \times g(x)$ will allow the range of $g(x)$ to be mapped to even numbers. However, we need to adjust the value of $x$ so that we still input $\{1,2,3,4,\text{...}\}$ for $f(x)$ and $g(x)$. To achieve this, we must devise a single equation that will be substituted for $x$. Given the equation for odd numbers, $x = 2i-1$, and the equation for even numbers, $x=2i$, we can solve for $i$ and derive such an equation.

Odd numbers $x=2i-1$:

$i=\frac{x+1}{2}$ [3]

Even numbers $x=2i-0$:

$i=\frac{x+0}{2}$ [4]

So, if $x$ is an odd number, we calculate the index with the first equation [3] and, if $x$ is an even number, we calculate the index with the second equation [4]. However, we need a single equation for the indices. Luckily, the only difference is adding a 1 to $x$ if $x$ is odd, or adding a 0 to $x$ if $x$ is even. I hope that sounds familiar because that is exactly what the equation $\alpha(x)$ outputs, and we can now map the domain as

$i(x)=\frac{x+\alpha(x)}{2}$ [5]

Finally, after putting everything together, we arrive at the general solution:

$F(x)=\alpha(x)\,f\left(\frac{x+\alpha(x)}{2}\right)+\beta(x)\,g\left(\frac{x+\alpha(x)}{2}\right)$ [6]

or

$F(x)=\left(\frac{1-(-1)^{x}}{2}\right)\,f\left(\frac{2x-(-1)^x+1}{4}\right)+\left(\frac{1+(-1)^{x}}{2}\right)\,g\left(\frac{2x-(-1)^x+1}{4}\right)$ [7]

Considering how easy these challenges were, I will propose one more challenge that is similar in nature, but a little more complicated. Using some form of the equation

$\frac{1-(-1)^{x}}{2}$

find the function that produces a 1 for prime numbers and a 0 everywhere else. I only used elementary operations (^,*,/,+,-) along with a factorial.

Edited by Daedalus

##### Share on other sites

Surely, someone is working on finding the equation that produces a 1 for prime numbers and a 0 for all other natural numbers. Even though it's a little challenging, the answer is actually pretty cool.

Edited by Daedalus

##### Share on other sites

Surely, someone is working on finding the equation that produces a 1 for prime numbers and a 0 for all other natural numbers. Even though it's a little challenging, the answer is actually pretty cool.

I'm trying but I'm hopelessly lost, I don't think I have the basic math skills :/

Where I'm going with it:

The equation you gave equals 0 for x divisible by 2.

I can find an equation that gives 0 for only x divisible by 3.

Then if I did that for 2, 3, 4, 5, ... (x-1) and multiplied all of these functions together, they would equal 0 for all composite numbers.

The function (1 - (-1)^(2x/n))/2 is zero for numbers wholly divisible by n.

Problems:

- The functions give values somewhere in [0,1]. I don't think I can normalize it for n>3 so that the function is 1 everywhere else.

- If I had the product of a sequence of these functions, I don't think I can simplify it into one simple function.

Am I heading in the right direction? I'm stuck and might not work on this more.

Edited by md65536

##### Share on other sites

Am I heading in the right direction? I'm stuck and might not work on this more.

I figured this one out by complete accident. Think about factorials and prime numbers.

##### Share on other sites

Work has been extremely busy, but I am almost done writing the Mathematica file explaining the mathematics for this latest challenge. So, you all still have some time to try and figure this one out.

## Create an account

Register a new account