Results 1 to 10 of 10
Like Tree6Thanks
  • 2 Post By Soroban
  • 2 Post By emakarov
  • 1 Post By HallsofIvy
  • 1 Post By Pietbot

Math Help - Comparing ratios to the Golden Ratio

  1. #1
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Comparing ratios to the Golden Ratio

    Hi all,

    I'm currently trying to write an equation or piece of logic which will allow me to test ratios against the Golden Ratio to find the closest match. The ratios I need to test range from 1:255 to 255:1 (to several decimal places) and I want to convert these ratios into a decimal (z) between 0 & 1, such that 0 is a perfect match (1:1.618) and 1 is a the furthest possible (255:1). All the z values should be positive, such that a ratio of 10:1 will return a result similar to 1:11.

    The application of this is in testing whether the brightness of two parts of an image conform to the Golden Ratio. In practice most of the ratios will be much closer, say between 5:1 and 1:5, so it might suit a log(10) solution?

    So, where x = left side of ratio and y = right side, how do I define z as this number between 0 & 1?

    This is keeping me up at night!
    Also mods, please move this thread if I'm in the wrong place. ***Have reposted this in Calculus Forum***
    Thanks,
    Pietbot
    Last edited by Pietbot; June 8th 2013 at 03:25 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member

    Joined
    May 2006
    From
    Lexington, MA (USA)
    Posts
    11,735
    Thanks
    642

    Re: Comparing ratios to the Golden Ratio

    Hello, Pietbot!

    I don't know if all this is what you're looking for.


    We know that: . \phi \:=\:\frac{1+\sqrt{5}}{2} \:=\:1.618\,033\,989\,...
    . . . .And that: . \frac{1}{\phi} \:=\: \phi - 1 \:=\:0.618\,033\,989\,...


    Consider the Fibonacci sequence:
    . . 1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,159  7,2584,4181\;\hdots

    The ratios of consecutive Fibonacci numbers approaches \frac{1}{\phi}

    . . \begin{array}{ccc}144:233 &=& 0.618\,025\,751 \\ \\ 233:377 &=& 0.618\,037\,135 \\ \\ 377:610 &=& 0.618\,032\,787 \\ \\ 610:987 &=& 0.618\,034\,448 \\ \\ 987:1597 &=& 0.618\,033\,813 \\ \\ 1597:2584 &=& 0.618\,034\,056 \\ \\ 2584:4181 &=& 0.618\,033\,963 \\ \\ \vdots && \vdots \end{array}
    Thanks from topsquark and Pietbot
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    Thanks Soroban,

    What I'm looking for is a difference generator to tell me the difference between ratios: so between 1:1.618033989 and any given ratio. However I want it to make sense in the context of brightness, such that 5 times darker and 5 times brighter give the same result, e.g. if 1:1 was the perfect ratio, 1:5 and 5:1 would generate the same difference value. The complication is that I'm looking to test images with a perfect result being that (avg. brightness of area 1) = 1.618x brighter than (avg. brightness of area 2). The equation needs to show how close or far from the Golden Ratio any given ratio is.

    Thanks,
    Pietbot
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,535
    Thanks
    778

    Re: Comparing ratios to the Golden Ratio

    As far I as understand, you need a function f(x), where x is a ratio that needs to be compared with the golden ratio φ, such that:

    (1) f(x) is defined for 1/255 ≤ x ≤ 255,
    (2) 0 ≤ f(x) ≤ 1,
    (3) f(φ) = 0, and
    (4) f(aφ) = f((1/a)φ).

    Property (4) means that ratios, say, twice φ and half φ produce the same score. Since you are saying that most often (1/5)φ ≤ x ≤ 5φ, I assume it is also desirable to have

    (5) f((1/5)φ) = f(5φ) is close to 1.

    Otherwise, if, say, f(5φ) = 0.25, then most often you will work with scores that are between 0 and 0.25, while 3/4 of the scale are left mostly unused.

    For starters, we can consider f(x) of the form g(x/φ) for some function g since working with 1 is easier than with φ. Then (1)(5) become

    (1') g(x) is defined for 1/(255φ) ≤ x ≤ 255/φ,
    (2') 0 ≤ g(x) ≤ 1,
    (3') g(1) = 0,
    (4') g(1/x) = g(x), and
    (5') g(1/5) = g(5) ≈ 1.

    Using logarithm (together with absolute value) is not a bad idea because |log(x)| satisfies (3') and (4'). We could define g(x) = |log(x)|/log(255φ) using logarithm to some base. This g(x) satisfies (1')(4') (though g(1/(255φ)) = 1, but g(255/φ) ≈ 0.84). Unfortunately, log(5)/log(255φ) < log(5)/log(125) = log(5)/log(53) = log(5)/(3log(5)) = 1/3 regardless of the base, so (5') does not hold. Also, computing logarithm can be computationally expensive if it is done for every pixel in a region.

    We could manufacture a rational function instead. For example, let h(x) = x if x ≥ 1 and h(x) = 1/x otherwise, and let k(x) = (x - 1)/x = 1 - 1/x. Then let g(x) = k(h(x)). I suggest checking whether g(x) satisfies (1')(5').
    Thanks from topsquark and Pietbot
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor

    Joined
    Apr 2005
    Posts
    15,693
    Thanks
    1466

    Re: Comparing ratios to the Golden Ratio

    It seems to me that the simplest way to "compare" a ratio to the golden ratio is to divide the number by the golden ratio. The close to 1 that number is, the closer your ratio is to the golden ratio. For example, if one of your ratios is 8/5= 1.6 then dividing by \phi= 1.618034 gives 0.9889. If another is 41/25= 1.64 then dividing but \phi= 1.618034 gives 1.0136. The first is 1- 0.9889= 0.0111 from 1 while the second is 1.0136- 1= .0136 from 1. The first is closer to 1 so 8/5 is closer to the golden ratio than 41/25.
    Thanks from topsquark
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    Wow thanks emakarov, you seem to have understood very well what I'm trying to do and thanks for writing out properly the conditions I was explaining. I'm glad it wasn't missing an easy answer...

    Regarding computing logarithms - I won't be testing every pixel but rather averaged brightness of areas, so we would be talking about 15,000 calcs per second at 15fps rather than millions. The code I'm using (Processing language) seems able to cope with that kind of work.

    My hunch is that in order to satisfy (4) a rational function is probably needed. I'll take a look at your suggestion and see g(x) is feasible.

    Anyone else who fancies a go at this now emakarov has set out the problem nicely is very welcome to try!

    Thanks,
    Pietbot
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    Hi HallsofIvy, I'm not sure that will always give me the 'difference' between a given ratio and 1:φ?

    I want to apply this to a brightness test such that

    Twice as bright = 1:2φ = half as bright = 1:φ/2

    and so on,

    1:x(φ) = 1:φ/x

    For my purposes, ratios range between 1:255 and 255:1 and the output number needs to be a value between 0 and 1, so:

    Best = 0 = 1:1.618
    Worst = 1 = 255:1

    I think what you're saying though is similar to emakarov's g(x/φ) idea, so possibly that is the way to go.

    Thanks,
    Pietbot
    Last edited by Pietbot; June 12th 2013 at 08:19 AM.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    Then again HallsofIvy, looking at your credentials I wonder if the answer to this is actually really that simple and I'm making it more complicated than it is...

    Pietbot
    Last edited by Pietbot; June 12th 2013 at 08:45 AM.
    Thanks from topsquark
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    OK guys I think I have something...

    x = left side of ratio
    y = right side of ratio
    r = solution (our factor of comparison)

    First make the left side of the ratio = 1, so our ratio looks like

    1:y/x

    Then test if the left side (y/x) >= φ

    If yes,

    r = (y/x)/φ

    As in HallsofIvy's solution.

    However, if no, and (y/x) < φ

    We need the reciprocal, so

    r = 10/10((y/x)/φ)

    Then it's just a matter of converting r to fit my scale of 0-1. Is that correct? Can anyone confirm the logic here?

    Thanks,
    Pietbot
    Last edited by Pietbot; June 12th 2013 at 10:15 AM.
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Newbie
    Joined
    Jun 2013
    From
    Brighton
    Posts
    9
    Thanks
    1

    Re: Comparing ratios to the Golden Ratio

    Quote Originally Posted by Pietbot View Post

    Then test if the left side (y/x) >= φ
    ..I mean the right side of course...
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: April 10th 2012, 06:35 PM
  2. About the golden ratio
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: July 3rd 2011, 02:33 AM
  3. [SOLVED] Golden Ratio
    Posted in the Number Theory Forum
    Replies: 6
    Last Post: June 11th 2011, 06:00 PM
  4. Golden Ratios (Q Fields)
    Posted in the Number Theory Forum
    Replies: 10
    Last Post: July 14th 2010, 06:46 AM
  5. Golden ratio
    Posted in the Number Theory Forum
    Replies: 3
    Last Post: August 17th 2008, 05:15 AM

Search Tags


/mathhelpforum @mathhelpforum