namespace for equation solving namespace
#include <iostream>
#include <string>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
void test_eq_sa(
double (*
f_eq)(
double),
double x0, std::string eq) {
int iterations = 100;
double z;
std::cout << "Equation solution " << eq << ":\t";
std::cout << z << std::endl;
std::cout << "Check finding solution:\t";
std::cout << z <<
" = " <<
f_eq(z) << std::endl;
for (int i = 0; i <= 50; i++) {
std::cout << "-";
}
std::cout << std::endl;
}
int main() {
return 0;
}
void credits(void)
print credits
Definition: common.cpp:8
Mathematics utils for equations.
void println(std::string string)
Print string with new line.
Definition: libnumerixpp.cpp:11
Core utils for mathematics.
double successiveApproximationsFindingRoot(double(*f_eq)(double), double x0, int n)
Function for solving equations by the method of successive approximations.
Definition: equations.cpp:9
double h_eq(double x)
Function h for determining the right side of solved equations.
Definition: equations.cpp:23
double f_eq(double x)
Function f for determining the right side of solved equations.
Definition: equations.cpp:19
double g_eq(double x)
Function g for determining the right side of solved equations.
Definition: equations.cpp:21
double mathematics::equations::successiveApproximationsFindingRoot |
( |
double(*)(double) |
f_eq, |
|
|
double |
x0, |
|
|
int |
n |
|
) |
| |
Function for solving equations by the method of successive approximations.
When solving an equation ( \(x = \Phi(x)\)), under some additional conditions, the method of successive approximations can be used. Its essence boils down to the fact that the initial position x0 is specified for the root of the equation, after which, using an iterative procedure, each subsequent approximation is calculated based on the previous one in accordance with the formula \(x_{n + 1} = \Phi(x_{n})\). Example equations: \(x = 0,5 * \cos(x)\); \(x = \exp(-x)\); \(x = (x^{2} + 6) / 5\).
- Parameters
-
[in] | f | The f |
[in] | x0 | The x 0 |
[in] | n | n value |
- Returns
- equation root