如何使用 PHP 中的 log() 获取曲线上的点?
我有一个想要复制的图表:
我有以下 PHP 代码:
$sale_price = 25000;
$future_val = 5000;
$term = 60;
$x = $sale_price / $future_val;
$pts = array();
$pts[] = array($x,0);
for ($i=1; $i<=$term; $i++) {
$y = log($x+0.4)+2.5;
$pts[] = array($i,$y);
echo $y . " <br>\n";
}
如何使代码工作给我沿下线(黄色和蓝色区域之间)的点?不需要很精确,稍微接近即可。
公式是:
-ln(x+.4)+2.5
我通过使用在线函数绘图器 http://www.livephysicals.com/
提前致谢!!
I have a graph I am trying to replicate:
I have the following PHP code:
$sale_price = 25000;
$future_val = 5000;
$term = 60;
$x = $sale_price / $future_val;
$pts = array();
$pts[] = array($x,0);
for ($i=1; $i<=$term; $i++) {
$y = log($x+0.4)+2.5;
$pts[] = array($i,$y);
echo $y . " <br>\n";
}
How do I make the code work to give me the points along the lower line (between the yellow and blue areas)? It doesn't need to be exact, just somewhat close.
The formula is:
-ln(x+.4)+2.5
I got that by using the Online Function Grapher at http://www.livephysics.com/
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
X 值应该
是您已分配给
$i
的贷款期限。另外,为什么你的贷款期限最大值是60?你把年换算成月了吗?确保方程相应地改变。
但不太确定你的方程的有效性。查看图表: http ://www.wolframalpha.com/input/?i=y+%3D+ln%28x+%2B+0.4%29+%2B+2.5
Should be
X values are the loan term, which you have assigned to
$i
.Also, why is your loan term max value 60? Did you convert years to months? Make sure the equation is changed accordingly.
Not quite sure of the validity of your equation though. Check out graph: http://www.wolframalpha.com/input/?i=y+%3D+ln%28x+%2B+0.4%29+%2B+2.5