#include <iostream>
#include <vector>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
int main() {
double num = 100.0;
std::cout << "Square " << num << ": " << num_sq << std::endl;
std::cout << "Square root " << num << ": " << num_sqr << std::endl;
std::cout << std::endl;
double a = -2;
double b = 5;
double c = 5;
std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << std::endl;
std::cout << "D=" << d << std::endl;
std::cout << "Roots:" << std::endl;
for (double root : roots) {
std::cout << root << std::endl;
}
std::cout << std::endl;
std::cout << "100+10%: " << nump << std::endl;
std::cout << std::endl;
double bestPowVal = 100;
std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << std::endl;
std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << std::endl;
std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2]
<< std::endl;
std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << std::endl;
std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << std::endl;
for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) {
double error = bestPowVal - pow_results[i];
std::cout << "POW Algorithm #" << i << ": error=" << error << std::endl;
}
std::cout << std::endl;
return 0;
}
void credits(void)
print credits
Definition: common.cpp:8
void println(std::string string)
Print string with new line.
Definition: libnumerixpp.cpp:11
Core utils for mathematics.
double calculateDiscriminant(double a, double b, double c)
Calculates the discriminant.
Definition: quadratic_equations.cpp:12
std::vector< double > calculateRootsByDiscriminant(double discriminant, double a, double b)
Calculates the roots by discriminant.
Definition: quadratic_equations.cpp:18
int intabs(int x)
Getting the modulus of a number without a comparison operation.
Definition: core.cpp:108
double binaryPower(double base, unsigned long long exponent)
Algorithm: Binary exponentiation.
Definition: core.cpp:23
double add_percent_to_number(double number, double percentage)
Adds a percent to number.
Definition: core.cpp:76
double fastPowerFractional(double base, double exponent)
Algorithm: "Fractional fast power".
Definition: core.cpp:63
double oldApproximatePower(double base, double exponent)
Algorithm for fast exponentiation "'Old' approximation".
Definition: core.cpp:10
double fastPowerDividing(double base, double exponent)
Algorithm: "Dividing fast power".
Definition: core.cpp:36
double get_square_root(double num)
Gets the square root.
Definition: core.cpp:85
double anotherApproximatePower(double base, double exponent)
Algorithm for fast exponentiation "'Another' approximation".
Definition: core.cpp:51
double square_it_up(double num)
Gets the number square (N^2).
Definition: core.cpp:83
Quadratic utils for mathematics.