How do I get points on a curve in PHP with log()?
Posted
by
Erick
on Stack Overflow
See other posts from Stack Overflow
or by Erick
Published on 2011-01-12T03:15:48Z
Indexed on
2011/01/12
3:54 UTC
Read the original article
Hit count: 171
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!!
© Stack Overflow or respective owner