I'm trying to use this formula in PHP code, But I can't find a way to represent it.
phi = (A+B)/A = A/B
Say I have a number:
$a = 275;
I want the value of $b to be in the golden ratio with relation to $a; I know I can find the PHI constant by:
$phi = (1+sqrt(5))/2;
I don't know how to apply it.
as you have mentioned in your question, the formula of phi
is (a+b)/a = a/b
and you have the value of the phi
from (1+sqrt(5))/2
if you have the value of a
, then you can find the value of b derived from phi = a/b
to be b = phi/a
in PHP that would be
define('PHI', (1+sqrt(5))/2);
function goldenRatio($num){
return PHI/$num;
}
var_dump(goldenRatio(1)); // returns 0.618033989
var_dump(goldenRatio(2)); // returns 1.236067977
var_dump(goldenRatio(3)); // returns 1.854101966
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.