Skip to main content

Friday Quiz maths question, 24 Jun 2022, a day late.

 

There is just one pair of numbers (x,y) where when you add them together, multiply them together or divide x by y, the answers are all equal.  What are those numbers?

If you'd like to have a go at finding the answer, please do, and I'd love to hear how you did it.

Below are my thoughts, experiments and answer.

I should have found the answer sooner than I did.  First of all I used BASIC, set up a couple of loops for x and y and tested for meeting the conditions. That didn't produce an answer and so I did try smaller steps and included negative numbers. I now know that I should have found the answer then but for some reason my program didn't produce the result. 

Wanting to at least find the ballpark , I thought about ways to plot these three conditions on a graph. A 2d graph wouldn't really do it because we want to test all values of x and y. I tried using some 3d graphing systems to plot z=x+y, z=x*y and z=x/y,  to see where they all intersected.  But it was way too difficult to see what was going on. 

I devised a way to get a 'Z' value which will be zero when the answers to all three tests are zero. I was hoping to at least be able to see roughly where the answer lies and you can see that there's clearly one point where this graph comes close to z=0.


Using this graph and twirling it around a lot, you can just about tell that the answer is somewhere around y = -1 and x = 0.5.  And these numbers do fit the question.


I then went back to BASIC and used this program to produce the answer.

There's a pitfall when using floats (which we need to do here). You can't reliably test for equality or equality with zero. However, after experimenting with this, it does seem that the "if a=b and b=c" does work here in commodore basic.

Line 35 avoids the division by zero (which would give a syntax error) and in the absence of an 'else' in this basic, C is set to an extreme value by default. 










Comments

  1. My solution on paper with algebra!:
    x+y = xy = x/y start
    xy+y^2 = xy^2 = x mul by y
    y+y^2/x = y^2 = 1 div by x
    y^2 = 1 *hence y = ±1*

    ±1 + 1/x = 1 substitute y = ±1 in
    ±x + 1 = x mul by x
    x + 1 = x does not work since then 1 = 0
    hence 1 - x = x
    1 = 2x
    x = 0.5

    if y is positive 1 the values dont work (1.5 = 0.5 = 0.5)
    if y is negative 1 the values do work (-0.5 = -0.5 = -0.5)
    hence y = -1 and x = 0.5

    ReplyDelete
  2. Thank you so much for this. I didn't think this question could be solved this way.

    ReplyDelete
    Replies
    1. yep! and for completeness, my python solution to bruteforce it:

      # python range() is only for ints
      def fltrange(start, end, step):
      res = []
      i = start
      while i < end:
      res.append(i)
      i += step

      return res

      sampmin = -5
      sampmax = 5
      precision = .005

      bestmatch = [] # the match x, y
      matchthres = 99999 # how accurate it was

      # sample a load of points and find the best match
      for x in fltrange(sampmin, sampmax, precision):
      for y in fltrange(sampmin, sampmax, precision):
      diff1 = (x+y) - (x*y)
      diff2 = (x+y) - (x/y)
      diff3 = (x*y) - (x/y)
      meanDiff = (abs(diff1) + abs(diff2) + abs(diff3)) / 3

      if meanDiff < matchthres:
      matchthres = meanDiff
      bestmatch = [x, y]

      # its not perfect, but it gets almost there
      # bestmatch.Select(n => round(n)).ToArray()
      # this rounds to 10 decimal places and hits the exact result
      list(map(lambda n: round(n, 10), bestmatch))

      Delete

Post a Comment

Popular posts from this blog

RC2024/10 - my entry

A while ago I made this MIDI module for RC2014: It works but a better design would have its own serial chip and port decoding.  As it is, it provides the MIDI interface and a clock signal for the second SIO2 serial port. This means that it requires a little setting up and will only work for RC2014s with an SIO2 (and port B not already used). I think people might reasonably expect it to be plug-and-play and self-contained, ie do all the serial itself. My challenge to myself is to:  learn how to connect a serial chip (probably 68B50 ACIA) to receive the incoming MIDI and to serialise outgoing MIDI design the module, including the port decoding write a library so that it can easily be used on any RC2014. Potential applications include a MIDI sequencer and using incoming MIDI to trigger notes on the AY or SID sound chips. Entering the Retro Challenge 2024 (aka RC2024/10)  has given me an incentive to get on with this! I'm happy to see several more entries in the RC2014 category, includ

How to convert images for TMS9918A graphics on the RC2014

For me, graphics capability is essential for an 8-bit computer. My graphics chip of choice for the RC2014 is the very capable TMS9918A. It has 15 colours, sprites, several modes and a max resolution of 256x192. It makes arcade-style games possible, such as Tut-Tut above.  I enjoy simply displaying images and have a bunch on my CF card (my 'hard drive') and have written image viewer and slideshow apps to display them. Some useful links: Convert9918 Tutorial of Convert9918's settings Multipaint J B Langston's TMS9918A video module my own TMSEMU video module my respository of TMS9918A software, games and .s2/.sc3 images Image conversion I did dabble in writing my own utility to convert .png images but then settled on the Multipaint app which can open a png in a MSX 'screen 2', allow you to tidy it up with paint tools and save as a .sc2 file. (An sc2 file is little more than a video-memory dump and so it's easy to blast that back into vram to display the image.

IM53 8080 birthday cake

 Each year I've been trying to get more creative with ideas for Spencer's birthday cake. The plan this year was to incorporate LEDs in place of candles. I eventually settled on an Altair / IMSAI / PDP -style computer since those are the type of computers that inspired his RC2014. The IMSAI 8080 has the most colourful switches as well as a name that I could twist. The thought that it could show randomly flashing lights (as if the computer were running) and that it could also play a game of 'kill the bit' was very appealing. A plan formed to use a capacitive touch pad on the cake itself. The first job is to bake the fruitcake. I often use a 7" square tin and one of those cut in half and rearranged makes a cake of suitable proportions.  Even after taking a slice off the faces to make them nice and square, there are still some rounded corners, so after putting on the marzipan, I used more marzipan as a filler to flatten the whole thing. Even though I wanted to end up w