Pergunta

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!!

Foi útil?

Solução

$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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top