May-03-2017, 03:17 AM
So what do you get when compared to a manual calculation?
If you get the same thing then what you have written could be OK (I'm not making any judgement on this - trying to show you how you can check your own work)? (And yes - there is a mistake if the formula you wrote in the OP is correct)
If not then try just one term and make sure that is correct. Then try adding another and so on.
Extra credit/learning: it is generally good practice to perform some level of error checking, especially on any value that is being input by a person. Without getting in to complex numbers, what happens if you (accidentally) enter a negative number and pass that to the 'log' function? Is that what you want to happen? If not then, once you have the code doing the correct thing with known valid numbers, what do you want to do when someone enters an invalid number?
Susan
If you get the same thing then what you have written could be OK (I'm not making any judgement on this - trying to show you how you can check your own work)? (And yes - there is a mistake if the formula you wrote in the OP is correct)
If not then try just one term and make sure that is correct. Then try adding another and so on.
Extra credit/learning: it is generally good practice to perform some level of error checking, especially on any value that is being input by a person. Without getting in to complex numbers, what happens if you (accidentally) enter a negative number and pass that to the 'log' function? Is that what you want to happen? If not then, once you have the code doing the correct thing with known valid numbers, what do you want to do when someone enters an invalid number?
Susan