Sample implementation results to compute approximate roots of the equation \(x^4-1=0\):
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
A babylonian method (BM) is an algorithm that computes the square root.
+More...
+
#include <cassert>
+#include <iostream>
+#include "math.h"
+
+
+
A babylonian method (BM) is an algorithm that computes the square root.
+
This algorithm has an application in use case scenario where a user wants find accurate square roots of large numbers
- Author
- Ameya Chawla
+
+
+
◆ main()
+
+
+
+
+
+ | int main |
+ ( |
+ int |
+ argc, |
+
+
+ |
+ |
+ char const * |
+ argv[] |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Main function.
+
- Parameters
-
+
+ | argc | commandline argument count (ignored) |
+ | argv | commandline array of arguments (ignored) calls automated test function to test the working of fast fourier transform. |
+
+
+
+
- Returns
- 0 on exit
+
+
+
+
+
+
static void test()
Self-test implementations.
Definition: babylonian_method.cpp:63
+
+
+
+
+
+
+
◆ test()
+
+
+
+
+
+
+
+
+ | static void test |
+ ( |
+ | ) |
+ |
+
+
+ |
+
+static |
+
+
+
+
+
Self-test implementations.
+
Declaring two test cases and checking for the error in predicted and true value is less than 0.0001.
- Returns
- void
+
Testcase 1
+
Testcase 2
+
Real Output 1
+
Real Output 2
+
Test result for testcase 1
+
Test result for testcase 2
+
Testing for test Case 1
+
Testing for test Case 2
+
+
+
+
66 auto testcase1 = 125348;
+
67 auto testcase2 = 752080;
+
+
69 auto real_output1 = 354.045194855;
+
70 auto real_output2 = 867.225460881;
+
+
+
+
+
+
+
77 assert(
std::max(test_result1, real_output1) -
+
78 std::min(test_result1, real_output1) <
+
+
+
81 assert(
std::max(test_result2, real_output2) -
+
82 std::min(test_result2, real_output2) <
+
+
+
+
86 std::cout <<
"All tests have successfully passed!\n";
+
+
+
+
+
double babylonian_method(double radicand)
Babylonian methods is an iterative function which returns square root of radicand.
Definition: babylonian_method.cpp:31
+
+
+
+
+
+
+
+
+
|
+| file | babylonian_method.cpp |
+| | A babylonian method (BM) is an algorithm that computes the square root.
|
+| |
| file | bisection_method.cpp |
| | Solve the equation \(f(x)=0\) using bisection method
|
| |
diff --git a/dir_9c6faab82c22511b50177aa2e38e2780.js b/dir_9c6faab82c22511b50177aa2e38e2780.js
index 6e684e628..5c941be4a 100644
--- a/dir_9c6faab82c22511b50177aa2e38e2780.js
+++ b/dir_9c6faab82c22511b50177aa2e38e2780.js
@@ -1,5 +1,6 @@
var dir_9c6faab82c22511b50177aa2e38e2780 =
[
+ [ "babylonian_method.cpp", "dc/d9c/babylonian__method_8cpp.html", "dc/d9c/babylonian__method_8cpp" ],
[ "bisection_method.cpp", "d7/d6a/bisection__method_8cpp.html", "d7/d6a/bisection__method_8cpp" ],
[ "brent_method_extrema.cpp", "db/d01/brent__method__extrema_8cpp.html", "db/d01/brent__method__extrema_8cpp" ],
[ "composite_simpson_rule.cpp", "d4/d18/composite__simpson__rule_8cpp.html", "d4/d18/composite__simpson__rule_8cpp" ],
diff --git a/files.html b/files.html
index 8e654dbba..b78f86a28 100644
--- a/files.html
+++ b/files.html
@@ -254,27 +254,28 @@ solve-a-rat-in-a-maze-c-java-pytho/"
| vector_cross_product.cpp | Calculates the Cross Product and the magnitude of two mathematical 3D vectors |
| volume.cpp | Implmentations for the volume of various 3D shapes |
| ► numerical_methods | |
-| bisection_method.cpp | Solve the equation \(f(x)=0\) using bisection method |
-| brent_method_extrema.cpp | Find real extrema of a univariate real function in a given interval using Brent's method |
-| composite_simpson_rule.cpp | Implementation of the Composite Simpson Rule for the approximation |
-| durand_kerner_roots.cpp | Compute all possible approximate roots of any given polynomial using Durand Kerner algorithm |
-| false_position.cpp | Solve the equation \(f(x)=0\) using false position method, also known as the Secant method |
-| fast_fourier_transform.cpp | A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT) |
-| gaussian_elimination.cpp | Gaussian elimination method |
-| golden_search_extrema.cpp | Find extrema of a univariate real function in a given interval using golden section search algorithm |
-| inverse_fast_fourier_transform.cpp | An inverse fast Fourier transform (IFFT) is an algorithm that computes the inverse fourier transform |
-| lu_decompose.cpp | LU decomposition of a square matrix |
-| lu_decomposition.h | Functions associated with LU Decomposition of a square matrix |
-| midpoint_integral_method.cpp | A numerical method for easy approximation of integrals |
-| newton_raphson_method.cpp | Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions |
-| ode_forward_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using forward Euler method |
-| ode_midpoint_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method |
-| ode_semi_implicit_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler method |
-| qr_decompose.h | Library functions to compute QR decomposition of a given matrix |
-| qr_decomposition.cpp | Program to compute the QR decomposition of a given matrix |
-| qr_eigen_values.cpp | Compute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method |
-| rungekutta.cpp | Runge Kutta fourth order method implementation |
-| successive_approximation.cpp | Method of successive approximations using fixed-point iteration method |
+| babylonian_method.cpp | A babylonian method (BM) is an algorithm that computes the square root |
+| bisection_method.cpp | Solve the equation \(f(x)=0\) using bisection method |
+| brent_method_extrema.cpp | Find real extrema of a univariate real function in a given interval using Brent's method |
+| composite_simpson_rule.cpp | Implementation of the Composite Simpson Rule for the approximation |
+| durand_kerner_roots.cpp | Compute all possible approximate roots of any given polynomial using Durand Kerner algorithm |
+| false_position.cpp | Solve the equation \(f(x)=0\) using false position method, also known as the Secant method |
+| fast_fourier_transform.cpp | A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT) |
+| gaussian_elimination.cpp | Gaussian elimination method |
+| golden_search_extrema.cpp | Find extrema of a univariate real function in a given interval using golden section search algorithm |
+| inverse_fast_fourier_transform.cpp | An inverse fast Fourier transform (IFFT) is an algorithm that computes the inverse fourier transform |
+| lu_decompose.cpp | LU decomposition of a square matrix |
+| lu_decomposition.h | Functions associated with LU Decomposition of a square matrix |
+| midpoint_integral_method.cpp | A numerical method for easy approximation of integrals |
+| newton_raphson_method.cpp | Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions |
+| ode_forward_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using forward Euler method |
+| ode_midpoint_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method |
+| ode_semi_implicit_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler method |
+| qr_decompose.h | Library functions to compute QR decomposition of a given matrix |
+| qr_decomposition.cpp | Program to compute the QR decomposition of a given matrix |
+| qr_eigen_values.cpp | Compute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method |
+| rungekutta.cpp | Runge Kutta fourth order method implementation |
+| successive_approximation.cpp | Method of successive approximations using fixed-point iteration method |
| ► operations_on_datastructures | |
| array_left_rotation.cpp | Implementation for the Array Left Rotation algorithm |
| array_right_rotation.cpp | Implementation for the Array right Rotation algorithm |
diff --git a/globals_func_i.html b/globals_func_i.html
index eaac1ff58..7ce39a9c8 100644
--- a/globals_func_i.html
+++ b/globals_func_i.html
@@ -104,8 +104,8 @@ $(document).ready(function(){initNavTree('globals_func_i.html',''); initResizabl
is_happy() : happy_number.cpp
is_prime() : check_prime.cpp
is_square() : ordinary_least_squares_regressor.cpp
-IsPrime() : primality_test.cpp
isPrime() : modular_inverse_fermat_little_theorem.cpp
+IsPrime() : primality_test.cpp
it_ternary_search() : ternary_search.cpp
diff --git a/globals_func_m.html b/globals_func_m.html
index f648f6290..49b664ad3 100644
--- a/globals_func_m.html
+++ b/globals_func_m.html
@@ -93,7 +93,7 @@ $(document).ready(function(){initNavTree('globals_func_m.html',''); initResizabl
- m -