sokobo
Loading...
Searching...
No Matches
calculus.h
1#include "expression.h"
2#include "polynomial.h"
3#include <functional>
4#include <vector>
5
6class Calculus {
7public:
8 // Symbolic differentiation
9 static std::shared_ptr<Expression> differentiate(std::shared_ptr<Expression> expr, const std::string& var);
10 static std::shared_ptr<Expression> partialDerivative(std::shared_ptr<Expression> expr, const std::string& var);
11
12 // Symbolic integration (limited cases)
13 static std::shared_ptr<Expression> integrate(std::shared_ptr<Expression> expr, const std::string& var);
14
15 // Numerical integration
16 static double trapezoidalRule(std::function<double(double)> f, double a, double b, int n = 1000);
17 static double simpsonsRule(std::function<double(double)> f, double a, double b, int n = 1000);
18 static double gaussianQuadrature(std::function<double(double)> f, double a, double b, int n = 10);
19 static double monteCarloIntegration(std::function<double(double)> f, double a, double b, int samples = 100000);
20
21 // Multiple integrals
22 static double doubleIntegral(std::function<double(double, double)> f,
23 double x1, double x2, double y1, double y2, int nx = 100, int ny = 100);
24
25 // Series expansions
26 static Polynomial taylorSeries(std::function<double(double)> f, double center, int degree);
27 static Polynomial chebyshevSeries(std::function<double(double)> f, double a, double b, int degree);
28
29 // Limits
30 static double limit(std::function<double(double)> f, double x, double h = 1e-10);
31};