openGPMP
Open Source Mathematics Package
differential.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  *
3  * Project
4  * _____ _____ __ __ _____
5  * / ____| __ \| \/ | __ \
6  * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7  * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8  *| (_) | |_) | __/ | | | |__| | | | | | | |
9  * \___/| __/ \___|_| |_|\_____|_| |_| |_|_|
10  * | |
11  * |_|
12  *
13  * Copyright (C) Akiel Aries, <akiel@akielorg>, et al.
14  *
15  * This software is licensed as described in the file LICENSE, which
16  * you should have received as part of this distribution The terms
17  * among other details are referenced in the official documentation
18  * seen here : https://akielariesgithub.io/openGPMP/ along with
19  * important files seen in this project
20  *
21  * You may opt to use, copy, modify, merge, publish, distribute
22  * and/or sell copies of the Software, and permit persons to whom
23  * the Software is furnished to do so, under the terms of the
24  * LICENSE file As this is an Open Source effort, all implementations
25  * must be of the same methodology
26  *
27  *
28  *
29  * This software is distributed on an AS IS basis, WITHOUT
30  * WARRANTY OF ANY KIND, either express or implied
31  *
32  ************************************************************************/
33 
40 #ifndef DIFFERENTIAL_HPP
41 #define DIFFERENTIAL_HPP
42 #include <string>
43 #include <vector>
44 
45 namespace gpmp {
46 
50 class Term {
51  public:
52  double coefficient;
53  int exponent;
60  Term(double coef, int exp) : coefficient(coef), exponent(exp) {
61  }
62 };
63 
67 class Differential {
68  public:
69  std::vector<Term> terms;
76  Differential operator+(const Differential &other) const;
77 
83  Differential operator*(const Differential &other) const;
84 
90  void add_term(double coefficient, int exponent);
91 
95  void display() const;
96 
101  Differential power_rule() const;
102 
109 
116 
122  Differential chain_rule(const Differential &inner) const;
123 
129  Differential nth_derivative(int n) const;
130 
136  double eval(double x) const;
137 
148  double limit_at(double x) const;
149 
160  double limit_at_infinity() const;
161 };
162 
163 } // namespace gpmp
164 
165 #endif
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 product_rule(const Differential &other) const
Computes the derivative using the product rule.
Differential chain_rule(const Differential &inner) const
Computes the derivative using the chain rule.
Differential operator+(const Differential &other) const
Overloaded addition operator for Differential objects.
void display() const
Displays the polynomial in a readable format.
Differential operator*(const Differential &other) const
Overloaded multiplication operator for Differential objects.
Differential quotient_rule(const Differential &other) const
Computes the derivative using the quotient rule.
std::vector< Term > terms
Differential nth_derivative(int n) const
Computes the nth derivative of the current Differential object.
double eval(double x) const
Evaluates the polynomial for a given value of x.
Represents a term in a polynomial.
Term(double coef, int exp)
Constructs a Term with given coefficient and exponent.
double coefficient
The source C++ openGPMP namespace.