Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:39:33+00:00 2026-05-14T02:39:33+00:00

I’m trying to get this expression to work, I’m pretty sure its not the

  • 0

I’m trying to get this expression to work, I’m pretty sure its not the parenthesis because I counted all of them. Perhaps there something I’m doing wrong involving the parameter pow (x,y).

double calculatePeriodicPayment()
{
 periodicPaymentcalc = (loan * ((interestRate / yearlyPayment)))  / (1-((pow ((1+(interestRate / yearlyPayment)))),(-(yearlyPayment * numOfYearLoan))));

 return periodicPaymentcalc;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:39:33+00:00Added an answer on May 14, 2026 at 2:39 am

    Notice how much easier it is to figure out what the function is doing if you break each step up into pieces:
    (I find it even easier if your variables match the source material, so I’ll name my variables after the ones Wikipedia uses.)

    // amortization calculator
    // uses annuity formula (http://en.wikipedia.org/wiki/Amortization_calculator)
    // A = (P x i) / (1 - pow(1 + i,-n))
    // Where:
    //   A = periodic payment amount
    //   P = amount of principal
    //   i = periodic interest rate
    //   n = total number of payments
    double calculatePeriodicPayment()
    { 
      const double P = loan;
      const double i = interestRate / yearlyPayment;
      const double n = yearlyPayment * numOfYearLoan;
    
      const double A = (P * i) / (1 - pow(1.0 + i, -n));
    
      return A; 
    } 
    

    It’s much easier to confirm that the logic of this function does what it should this way.

    If you’re curious, substituting my variable names in, your parenthises problem is as follows:

      const double A = (P * i) / (1 - pow(1 + i)), -n; // <- this is how you have it
      const double A = (P * i) / (1 - pow(1 + i, -n)); // <- this is how it should be
    

    With this grouping, you’re only passing one argument to pow, which is why the compiler says no overloaded function takes 1 arguments.

    Edit: You mentioned I used more variables. However, your compiler will use temporary variables much like I did. Your complex statement will be broken up into pieces, and may look something like this:

    double calculatePeriodicPayment() 
    {
      const double temp1 = interestRate / yearlyPayment;
      const double temp2 = loan * temp1;
      const double temp3 = interestRate / yearlyPayment;
      const double temp4 = 1.0 + temp3;
      const double temp5 = yearlyPayment * numOfYearLoan;
      const double temp6 = -temp5;
      const double temp7 = pow(temp4, temp5);
      const double temp8 = 1 - temp7;
      const double temp9 = temp2 / temp8;
    
      periodicPaymentcalc = temp9; 
      return periodicPaymentcalc; 
    } 
    

    Mine will also be broken up, and will look like:

    double calculatePeriodicPayment()
    { 
      const double P = loan;
      const double i = interestRate / yearlyPayment;
      const double n = yearlyPayment * numOfYearLoan;
    
      const double temp1 = P * i;
      const double temp2 = 1.0 + i;
      const double temp3 = -n;
      const double temp4 = pow(temp2, temp3);
      const double temp5 = 1 - temp4;
      const double temp6 = temp1 / temp5;
      const double A = temp6;
    
      return A; 
    } 
    

    Perhaps there are some optimizations that the compiler will use, such as noticing that it uses interestRate / yearlyPayment twice in your function, and use the same temporary for both places, but there’s no gurantee this will happen. Notice that we use pretty much the same number of variables in both of our functions. I just used more named variables, and fewer unnamed temporaries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.