
I made this. Here’s how…
Rob Eastaway tweeted a little curiosity he had been given by Tim Rowett – an equation that works as an equation when rotated 180°.
To make this isn’t completely trivial. It seems clear that
You also have to consider the order of operations and ensure this makes sense both ways up. For example, you can’t start one side of the equation like
So far, so curious. But Rob posed an interesting question: does a similar equation exist that has the same solution both ways?
I realised that the arrangement of fractions in the equation Tim gave Rob were leading to one solution one way up and two solutions the other way up, meaning there was no possibility of a complete match. So I wondered if it might be possible to find a set of four constants with appropriate values for which one solution matched.
That is, we want equations of the form
with
Say the rotated form is
Such that
And
First, we solve the non-rotated version of the equation in general form:
Then we solve the rotated version:
So, applying the quadratic formula,
I wrote a little Python 3 program to exhaustively search, testing each of the possible values of
Here is my rotate(n)
function, which take a number n
and returns its rotated version.
def rotate(n): if n==1 or n==5 or n==8: return n elif n==6: return 9 elif n==9: return 6 else: raise ValueError("Input should be 1, 5, 6, 8 or 9")
And here is the code for running the search. It uses SciPy for the square root to deal with any potential complex numbers.
import scipy as sp candidatevalues = (1,5,6,8,9) for a in candidatevalues: for b in candidatevalues: for c in candidatevalues: for d in candidatevalues: if d!=a and a!=1 and d!=1: # mustn't divide by zero! Also a and d !=1 so not trivially reducible e = rotate(d) f = rotate(c) g = rotate(b) h = rotate(a) x1 = (a*b*d - a*c) / (d-a) # solution a,b,c,d x2 = ( (f*g+e-h) + sp.sqrt( (h-e-f*g)**2 + 4*f*g*h ) )/(2*g) # +ve solution e,f,g,h x3 = ( (f*g+e-h) - sp.sqrt( (h-e-f*g)**2 + 4*f*g*h ) )/(2*g) # -ve solution e,f,g,h if x1==x2 or x1==x3: print(a,b,c,d," / ",e,f,g,h," / ",x1,x2,x3)
This method found three solutions.
I figure you could set up a neat trick where you say “solve this equation” (the
But it isn’t completely satisfying, is it?
Playing around on paper, I came up with an equation format that would yield two solutions in either case and ran a similar piece of code. This found eight non-trivial equations that had the same pair of solutions either way. Really, this is four pairs of equations, where each pair are a trivial rearrangement of the each other.
Non-rotated | Rotated | Solutions |
---|---|---|
So far, so good, but the solutions were all complex. In some ways, complex number solutions are fine. But, really, it’d be nicer and more accessible as a trick to have real solutions.
Finally, I did a bit of tweaking to try to increase the chances the discriminant was positive, essentially by changing the minuses to pluses, and found some with real solutions.
Non-rotated | Rotated | Solutions (2 d.p.) |
---|---|---|
From these, I picked one with integer solutions which I found fairly pleasing symmetrically, and tweeted it.
I’m sure there will be other equation formats out there that yield solutions with this property, but that’ll do for me. Here’s the full code that found the eight real solutions.
# non-rotated: (x+a)/b = c/(d+x) # rotated: (x+e)/f = g/(h+x) import scipy as sp def rotate(n): if n==1 or n==5 or n==8: return n elif n==6: return 9 elif n==9: return 6 else: raise ValueError("Number should be 1, 5, 6, 8 or 9") candidatevalues = (1,5,6,8,9) for a in candidatevalues: for b in candidatevalues: for c in candidatevalues: for d in candidatevalues: e = rotate(d) f = rotate(c) g = rotate(b) h = rotate(a) if (not (a==h and b==g and c==f and d==e)) and (not (a==e and b==f and c==g and d==h)) and b!=1 and c!=1: # only test cases that aren't boring and b and c !=1 so not reducible x1 = (-(d+a) + sp.sqrt((d+a)**2 - 4*(a*d-b*c)))/2 # a,b,c,d +ve x2 = (-(d+a) - sp.sqrt((d+a)**2 - 4*(a*d-b*c)))/2 # a,b,c,d -ve x3 = (-(h+e) + sp.sqrt((h+e)**2 - 4*(e*h-f*g)))/2 # e,f,g,h +ve x4 = (-(h+e) - sp.sqrt((h+e)**2 - 4*(e*h-g*f)))/2 # e,f,g,h -ve if (x1==x3 and x2==x4) or (x1==x4 and x2==x3): print(a,b,c,d," / ",e,f,g,h,"/",x1,x2)
Well, calculator-style 2 looks like 2 when rotated.
Yes, I suppose so. It is a trivial change to the code to allow and search for 2 also as its own rotation. Doing so finds another 10 equations in this format with real solutions. So if you are happy to typeset in a calculator font, you can make equations from the following:
For example, the third of these (2 6 9 5) yields:
and reversed (5 6 9 2):
both of which have solutions .
It is not immediately obvious to me that the program will not lose some solutions due to floating point precision errors. I do not think anything bad could happen in this particular case, but it is something you have to be careful about in general when writing programs like this. I would rather write the test as (d+a) == (h+e) and (d+a)**2 – 4*(a*d-b*c) == (h+e)**2 – 4*(e*h-f*g) (or use a symbolic computation library) — this should be safe.
What one really wants is rotated equations with the same solutions where one is very easy to solve and the other very difficult. Then you challenge your friend and your enemy to solve them fastest, but rotate the question for your enemy. Your friend announces the solution very quickly, your enemy checks it works and credits your friend with great mathematical powers.