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

namespace for equation solving namespace More...

Functions

auto successive_approximations_finding_root (double(*f_eq)(double), double x0, int n) -> double
 Function for solving equations by the method of successive approximations. More...
 
auto half_division_finding_root (double(*f_hd_eq)(double), double a, double b, double dx) -> double
 Function for solving equations by the method of half division. More...
 
auto f_hd_eq (double x) -> double
 Function f for determining the right side of solved equations (half division) More...
 
auto g_hd_eq (double x) -> double
 Function g for determining the right side of solved equations (half division) More...
 
auto h_hg_eq (double x) -> double
 Function h for determining the right side of solved equations (half division) More...
 
auto f_eq (double x) -> double
 Function f for determining the right side of solved equations. More...
 
auto g_eq (double x) -> double
 Function g for determining the right side of solved equations. More...
 
auto h_eq (double x) -> double
 Function h for determining the right side of solved equations. More...
 

Detailed Description

namespace for equation solving namespace

#include <cmath>
#include <iostream>
#include <string>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) {
int const iterations = 100;
double z = NAN;
std::cout << "Equation solution " << eq << ":\t";
std::cout << z << '\n';
std::cout << "Check finding solution:\t";
std::cout << z << " = " << f_eq(z) << '\n';
for (int i = 0; i <= 50; i++) {
std::cout << "-";
}
std::cout << '\n';
}
auto main() -> int {
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()
print credits
Definition: common.cpp:8
Mathematics utils for equations.
auto h_eq(double x) -> double
Function h for determining the right side of solved equations.
Definition: equations.cpp:59
auto successive_approximations_finding_root(double(*f_eq)(double), double x0, int n) -> double
Function for solving equations by the method of successive approximations.
Definition: equations.cpp:9
auto f_eq(double x) -> double
Function f for determining the right side of solved equations.
Definition: equations.cpp:55
auto g_eq(double x) -> double
Function g for determining the right side of solved equations.
Definition: equations.cpp:57

Function Documentation

◆ f_eq()

auto mathematics::equations::f_eq ( double  x) -> double

Function f for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ f_hd_eq()

auto mathematics::equations::f_hd_eq ( double  x) -> double

Function f for determining the right side of solved equations (half division)

Parameters
[in]xx value
Returns
value

◆ g_eq()

auto mathematics::equations::g_eq ( double  x) -> double

Function g for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ g_hd_eq()

auto mathematics::equations::g_hd_eq ( double  x) -> double

Function g for determining the right side of solved equations (half division)

Parameters
[in]xx value
Returns
value

◆ h_eq()

auto mathematics::equations::h_eq ( double  x) -> double

Function h for determining the right side of solved equations.

Parameters
[in]xx value
Returns
value

◆ h_hg_eq()

auto mathematics::equations::h_hg_eq ( double  x) -> double

Function h for determining the right side of solved equations (half division)

Parameters
[in]xx value
Returns
value

◆ half_division_finding_root()

auto mathematics::equations::half_division_finding_root ( double(*)(double)  f_hd_eq,
double  a,
double  b,
double  dx 
) -> double

Function for solving equations by the method of half division.

The half division method for solving an algebraic equation of the form f(x) = 0 implies that the sought root is localized in the interval a <= x <= b, and at the boundaries of the root search interval the function f(x) must take values of different signs (which can be written as the condition f(a)f(b) < 0).

Parameters
[in]f_hd_eqThe f_eq function for half division
[in]aa value
[in]bb value
[in]dxdx value
Returns
equation root

◆ successive_approximations_finding_root()

auto mathematics::equations::successive_approximations_finding_root ( double(*)(double)  f_eq,
double  x0,
int  n 
) -> double

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