mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-15 03:10:07 +08:00
formatting source-code for d7af6fdc8c
This commit is contained in:
@@ -21,18 +21,21 @@
|
||||
|
||||
/** define \f$f(x)\f$ to find root for
|
||||
*/
|
||||
static double eq(double i) {
|
||||
static double eq(double i)
|
||||
{
|
||||
return (std::pow(i, 3) - (4 * i) - 9); // original equation
|
||||
}
|
||||
|
||||
/** define the derivative function \f$f'(x)\f$
|
||||
*/
|
||||
static double eq_der(double i) {
|
||||
static double eq_der(double i)
|
||||
{
|
||||
return ((3 * std::pow(i, 2)) - 4); // derivative of equation
|
||||
}
|
||||
|
||||
/** Main function */
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
std::srand(std::time(nullptr)); // initialize randomizer
|
||||
|
||||
double z, c = std::rand() % 100, m, n;
|
||||
@@ -41,7 +44,8 @@ int main() {
|
||||
std::cout << "\nInitial approximation: " << c;
|
||||
|
||||
// start iterations
|
||||
for (i = 0; i < MAX_ITERATIONS; i++) {
|
||||
for (i = 0; i < MAX_ITERATIONS; i++)
|
||||
{
|
||||
m = eq(c);
|
||||
n = eq_der(c);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user