如何使用 PHP 中的 log() 获取曲线上的点?

发布于 2024-10-11 17:08:40 字数 743 浏览 9 评论 0原文

我有一个想要复制的图表:

GAP Graph

我有以下 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:

GAP Graph

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∝单色的世界 2024-10-18 17:08:40
$y = log($x+0.4)+2.5;

X 值应该

$y = 2.5 - log($i + .4)

是您已分配给 $i 的贷款期限。

另外,为什么你的贷款期限最大值是60?你把年换算成月了吗?确保方程相应地改变。

但不太确定你的方程的有效性。查看图表: http ://www.wolframalpha.com/input/?i=y+%3D+ln%28x+%2B+0.4%29+%2B+2.5

$y = log($x+0.4)+2.5;

Should be

$y = 2.5 - log($i + .4)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文