successive_approximation.cpp File Reference

Method of successive approximations using fixed-point iteration method. More...

`#include <cmath>`
`#include <iostream>`
Include dependency graph for successive_approximation.cpp:

## Functions

static float | eq (float y)
static float | eqd (float y)
int | main ()

## Detailed Description

Method of successive approximations using fixed-point iteration method.

## Function Documentation

## eq()

static float eq | ( | float | y | ) |

static

equation 1

\[f(y) = 3y - \cos y -2\]

{ return (3 * y) - cos(y) - 2; }
std::cos
T cos(T... args)

## eqd()

static float eqd | ( | float | y | ) |

static

equation 2

\[f(y) = \frac{\cos y+2}{2}\]

{ return 0.5 * (cos(y) + 2); }

## main()

int main | ( | void |  | ) |

Main function

{
float y, x1, x2, x3, sum, s, a, f1, f2, gd;
int i, n;
for (i = 0; i < 10; i++) {
sum = eq(y);
std::cout << "value of equation at " << i << " " << sum << "\n";
y++;
}
std::cout << "enter the x1->";
std::cin >> x1;
std::cout << "enter the no iteration to perform->\n";
std::cin >> n;
for (i = 0; i <= n; i++) {
x2 = eqd(x1);
std::cout << "\nenter the x2->" << x2;
x1 = x2;
}
return 0;
}
std::cin
std::cout
machine_learning::sum
T sum(const std::vector< std::valarray< T >> &A)
Definition: vector_ops.hpp:232
eq
static float eq(float y)
Definition: successive_approximation.cpp:12
eqd
static float eqd(float y)
Definition: successive_approximation.cpp:17
Here is the call graph for this function: