Test driver showing how to use different derivative-based operations in openGPMP.
#include <cassert>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
std::cout << "DERIVATIVE EXAMPLE\n\n";
std::cout << "Original Polynomial 1: \n";
std::cout << "Derivative 1: \n";
delete poly1;
std::cout << "Original Polynomial 2: \n";
std::cout << "Derivative 2: \n";
delete poly2;
std::cout << "<------------>\n";
double x_value = 2.0;
double result = derivative2.
eval(x_value);
std::cout << "Derivative2 at x = " << x_value << ": " << result
<< std::endl;
std::cout << "Original Polynomial 3: \n";
std::cout << "Second derivative of Polynomial 3: \n";
delete poly3;
std::cout << "<------------>\n";
std::cout << "Original Polynomial 4: \n";
std::cout << "Limit at x = 2: " << limitAtX << std::endl;
std::cout << "Limit as x approaches infinity: " << limitAtInfinity
<< std::endl;
std::cout << "Second derivative of Polynomial 4: \n";
delete poly4;
std::cout << "<------------>\n";
std::cout << "Derivative of (4x^2 + 1)^5 is: ";
return 0;
}
User API for OpenGPMP CALCULUS MODULE.
Calculus Class with methods pertaining to basic operations.
double limit_at_infinity() const
Calculate the limit of the polynomial as x approaches infinity.
Differential power_rule() const
Computes the derivative using the power rule.
double limit_at(double x) const
Calculate the limit of the polynomial at a specific point.
void add_term(double coefficient, int exponent)
Adds a term to the Differential object.
Differential chain_rule(const Differential &inner) const
Computes the derivative using the chain rule.
void display() const
Displays the polynomial in a readable format.
double eval(double x) const
Evaluates the polynomial for a given value of x.