“Adsterra”/ “CPA
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Any Mathematicians Here? >>>see this

Discussion in 'Programming and Scripts' started by Graybeard, Oct 22, 2018.

  1. Graybeard

    Graybeard Well-Known Member affiliate

    8,371
    6,159
    113
    PHP:
    function calcPayment(
        
    float $loanAmount,
        
    int $totalPayments,
        
    float $interest
    )
    {
        
    //***********************************************************
        //              INTEREST * ((1 + INTEREST) ^ TOTALPAYMENTS)
        // PMT = LOAN * -------------------------------------------
        //                  ((1 + INTEREST) ^ TOTALPAYMENTS) - 1
        //***********************************************************

        
    $value1 $interest pow(($interest), $totalPayments);
        
    $value2 pow(($interest), $totalPayments) - 1;
        
    $pmt    $loanAmount * ($value1 $value2);
        return 
    $pmt;
    Im MySQL

    Code:
    mysql> select 0.0249/12*170000*power(1+0.0249/12,25*12)/(power(1+0.0249/12,25*12)-1);
    +------------------------------------------------------------------------+
    | 0.0249/12*170000*power(1+0.0249/12,25*12)/(power(1+0.0249/12,25*12)-1) |
    +------------------------------------------------------------------------+
    |                                                       761.792586559163 |
    +------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    fine knowing the principal BUT --
    Say I want to how much I could borrow?

    $payment = 75
    $term = 120 #months
    $interest = 0.06/12

    $loan_origination_principal = ? (return {answer})

    Anyone have an idea?
     
    Last edited: Oct 22, 2018
    tyoussef likes this.
  2. Voluum
  3. Graybeard

    Graybeard Well-Known Member affiliate

    8,371
    6,159
    113
    I solved it
    What a headache too many hours

    PHP:
    $bill 70;//solar replacement :)
    $p 0// start amount
    $i = (0.08); // Interest rate
    $c 12// interest frequency set to monthly
    $n 120/12// term
    $r $bill// payment
    //secret sauce
    $total_apply = (70 120);
    $loanCost =  round($vf2PHP_ROUND_HALF_UP);
    $borrow = ($total_apply $loanCost);
    $loan_ammt = ($borrow $total_apply);

    //secret sauce
    output
    Your electric bill use minus the distribution cost: $70 @8%APR you can borrow $5546.7991525724
    proof
    =fv(8%/12,120,5546.7991525724/120,0,0)
    ($8,456)
    I am off by $16 sue me LOL

    grrr
     
    Last edited: Oct 22, 2018
    tyoussef and T J Tutor like this.
  4. Graybeard

    Graybeard Well-Known Member affiliate

    8,371
    6,159
    113
    here is the right stuff :eek: pear/Math_Finance
    Took too long to find it -- this class mimics the Excel and other spreadsheet formulas
     
MI