[英]How to represent PHI formula in PHP
I'm trying to use this formula in PHP code, But I can't find a way to represent it. 我正在尝试在PHP代码中使用此公式,但是我找不到代表它的方法。
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; 我希望$ b的值相对于$ a处于黄金比例; I know I can find the PHI constant by:
我知道我可以通过以下方式找到PHI常数:
$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
正如您在问题中提到的那样,
phi
的公式为(a+b)/a = a/b
,您的phi
的值为(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
如果有值
a
,那么可以发现衍生自b的值phi = a/b
被b = phi/a
in PHP that would be 在PHP中
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.