Daedalus 329 Posted February 18, 2015 (edited) 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 [math]f(x)=2^x[/math] and [math]g(x)=3^x[/math] 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 February 18, 2015 by Daedalus 0 Share this post Link to post Share on other sites

md65536 330 Posted February 18, 2015 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): [math]a=\frac{(-1)^x+1}{2}[/math] [math]base = a+2[/math] The exponent is basically ceiling(x/2), or alternately adjusting to handle the odd numbers: [math]exponent = (x+1-a)/2[/math] [math]answer = base^{exponent}[/math] [math]= \left(\frac{(-1)^x+5}{2}\right)^{\left(2x-((-1)^x-1)\right)/4}[/math] 1 Share this post Link to post Share on other sites

Daedalus 329 Posted February 18, 2015 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): [math]a=\frac{(-1)^x+1}{2}[/math] [math]base = a+2[/math] The exponent is basically ceiling(x/2), or alternately adjusting to handle the odd numbers: [math]exponent = (x+1-a)/2[/math] [math]answer = base^{exponent}[/math] [math]= \left(\frac{(-1)^x+5}{2}\right)^{\left(2x-((-1)^x-1)\right)/4}[/math] 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 [math]f(x)[/math] and [math]g(x)[/math]. Since we know you can do it, let's see if anyone else can figure that one out. 0 Share this post Link to post Share on other sites

Daedalus 329 Posted February 21, 2015 Anyone working on the general solution for this challenge? 0 Share this post Link to post Share on other sites

md65536 330 Posted February 21, 2015 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. 0 Share this post Link to post Share on other sites

Daedalus 329 Posted February 28, 2015 (edited) 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 [math]\alpha(x)=\frac{1-(-1)^{x}}{2}[/math] which, starting from [math]x=1[/math], produces the sequence, [math]\{1,0,1,0,1,0,\text{...}\}[/math] [1] and the equation that produces a 1 for even numbers as [math]\beta(x)=\frac{1+(-1)^{x}}{2}[/math] which, starting from [math]x=1[/math], produces the sequence, [math]\{0,1,0,1,0,1,\text{...}\}[/math] [2] If we add [math]\alpha(x)[/math] and [math]\beta(x)[/math] we can prove that the sum produces a 1 for all integers in the domain: [math]\alpha(x)+\beta(x)=1[/math] [math]\frac{1-(-1)^{x}}{2} + \frac{1+(-1)^{x}}{2}= 1[/math] [math]\frac{1}{2} + \frac{1}{2}= 1[/math] Next, we need to take [math]f(x)[/math] and [math]g(x)[/math] and multiply each function by either [math]\alpha(x)[/math] or [math]\beta(x)[/math]. We can see that multiplying [math]\alpha(x) \times f(x)[/math] will allow the range of [math]f(x)[/math] to be mapped to odd numbers in the domain, and multiplying [math]\beta(x) \times g(x)[/math] will allow the range of [math]g(x)[/math] to be mapped to even numbers. However, we need to adjust the value of [math]x[/math] so that we still input [math]\{1,2,3,4,\text{...}\}[/math] for [math]f(x)[/math] and [math]g(x)[/math]. To achieve this, we must devise a single equation that will be substituted for [math]x[/math]. Given the equation for odd numbers, [math]x = 2i-1[/math], and the equation for even numbers, [math]x=2i[/math], we can solve for [math]i[/math] and derive such an equation. Odd numbers [math]x=2i-1[/math]: [math]i=\frac{x+1}{2}[/math] [3] Even numbers [math]x=2i-0[/math]: [math]i=\frac{x+0}{2}[/math] [4] So, if [math]x[/math] is an odd number, we calculate the index with the first equation [3] and, if [math]x[/math] 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 [math]x[/math] if [math]x[/math] is odd, or adding a 0 to [math]x[/math] if [math]x[/math] is even. I hope that sounds familiar because that is exactly what the equation [math]\alpha(x)[/math] outputs, and we can now map the domain as [math]i(x)=\frac{x+\alpha(x)}{2}[/math] [5] Finally, after putting everything together, we arrive at the general solution: [math]F(x)=\alpha(x)\,f\left(\frac{x+\alpha(x)}{2}\right)+\beta(x)\,g\left(\frac{x+\alpha(x)}{2}\right)[/math] [6] or [math]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)[/math] [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 [math]\frac{1-(-1)^{x}}{2}[/math] 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 February 28, 2015 by Daedalus 1 Share this post Link to post Share on other sites

Daedalus 329 Posted March 2, 2015 (edited) 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 March 2, 2015 by Daedalus 0 Share this post Link to post Share on other sites

md65536 330 Posted March 3, 2015 (edited) 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 March 3, 2015 by md65536 0 Share this post Link to post Share on other sites

Daedalus 329 Posted March 4, 2015 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. 0 Share this post Link to post Share on other sites

Daedalus 329 Posted March 13, 2015 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. 0 Share this post Link to post Share on other sites