libnumerixpp  0.1.1
A Powerful C++ Library for High-Performance Numerical Computing
mathematics::equations Namespace Reference

namespace for equation solving namespace More...

Functions

double successiveApproximationsFindingRoot (double(*f_eq)(double), double x0, int n)
 Function for solving equations by the method of successive approximations. More...
 
double f_eq (double x)
 Function f for determining the right side of solved equations. More...
 
double g_eq (double x)
 Function g for determining the right side of solved equations. More...
 
double h_eq (double x)
 Function h for determining the right side of solved equations. More...
 

Detailed Description

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() {
println("LIBNUMERIXPP");
test_eq_sa(mathematics::equations::f_eq, 0, "x=0.5cos(x)");
test_eq_sa(mathematics::equations::g_eq, 0, "x=exp(-x)");
test_eq_sa(mathematics::equations::h_eq, 1, "x=(x*x+6)/5");
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

Function Documentation

◆ f_eq()

double mathematics::equations::f_eq ( double  x)

Function f for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ g_eq()

double mathematics::equations::g_eq ( double  x)

Function g for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ h_eq()

double mathematics::equations::h_eq ( double  x)

Function h for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ successiveApproximationsFindingRoot()

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]fThe f
[in]x0The x 0
[in]nn value
Returns
equation root