solve.h
Go to the documentation of this file.
1 
7 #ifndef SYMENGINE_SOLVE_H
8 #define SYMENGINE_SOLVE_H
9 
10 #include <symengine/sets.h>
13 #include <symengine/polys/uexprpoly.h>
16 #include <symengine/matrix.h>
17 
18 namespace SymEngine
19 {
20 /*
21  * Solves the given equation `f` and returns all possible values of `sym` as a
22  * Set, given
23  * they satisfy the `domain` constraint.
24  */
25 SYMENGINE_EXPORT
26 RCP<const Set> solve(const RCP<const Basic> &f, const RCP<const Symbol> &sym,
27  const RCP<const Set> &domain = universalset());
28 
29 // Solves rational equations.
30 SYMENGINE_EXPORT
31 RCP<const Set> solve_rational(const RCP<const Basic> &f,
32  const RCP<const Symbol> &sym,
33  const RCP<const Set> &domain = universalset());
34 
35 // Solves Trigonometric equations.
36 SYMENGINE_EXPORT
37 RCP<const Set> solve_trig(const RCP<const Basic> &f,
38  const RCP<const Symbol> &sym,
39  const RCP<const Set> &domain = universalset());
40 
41 // Solves Polynomial equations.
42 // Use this method, If you know for sure that `f` is a Polynomial.
43 SYMENGINE_EXPORT
44 RCP<const Set> solve_poly(const RCP<const Basic> &f,
45  const RCP<const Symbol> &sym,
46  const RCP<const Set> &domain = universalset());
47 
48 // Helper method for solving lower order polynomials using known formulae.
49 SYMENGINE_EXPORT
50 RCP<const Set> solve_poly_heuristics(const vec_basic &coeffs,
51  const RCP<const Set> &domain
52  = universalset());
53 
54 // Helper method for solving linear equations.
55 SYMENGINE_EXPORT
56 RCP<const Set> solve_poly_linear(const vec_basic &coeffs,
57  const RCP<const Set> &domain = universalset());
58 
59 // Helper method for solving quadratic equations.
60 SYMENGINE_EXPORT
61 RCP<const Set> solve_poly_quadratic(const vec_basic &coeffs,
62  const RCP<const Set> &domain
63  = universalset());
64 
65 // Helper method for solving cubic equations.
66 SYMENGINE_EXPORT
67 RCP<const Set> solve_poly_cubic(const vec_basic &coeffs,
68  const RCP<const Set> &domain = universalset());
69 
70 // Helper method for solving quartic(degree-4) equations.
71 SYMENGINE_EXPORT
72 RCP<const Set> solve_poly_quartic(const vec_basic &coeffs,
73  const RCP<const Set> &domain
74  = universalset());
75 
76 /*
77  * Helper method to decide if solve_trig can solve a particular equation.
78  * Checks the argument of Trigonometric part, and returns false if it is
79  * non-linear;
80  * true otherwise.
81  */
82 SYMENGINE_EXPORT bool is_a_LinearArgTrigEquation(const Basic &b,
83  const Symbol &x);
84 
85 /* returns Inverse of a complex equation `fX = gY` wrt symbol `sym`.
86  * It is like a solver developed specifically to solve equations of the
87  * form `exp(f(x)) = gY`(required for trig solvers).
88  * For example : invertComplex(exp(x), {1}, x) would give you
89  * `{2*I*pi*n | n in (-oo, oo)}` aka values of `x` when `exp(x) = 1`.
90  * Dummy `nD` is used as the symbol for `ImageSet` while returning the solution
91  * set.
92  */
93 SYMENGINE_EXPORT
94 RCP<const Set> invertComplex(const RCP<const Basic> &fX,
95  const RCP<const Set> &gY,
96  const RCP<const Symbol> &sym,
97  const RCP<const Dummy> &nD = dummy("n"),
98  const RCP<const Set> &domain = universalset());
99 
100 // Solver for System of Equations
101 // TODO : solve systems that have infinitely many solutions or no solution.
102 // Input as an Augmented Matrix. (A|b) to solve `Ax=b`.
103 SYMENGINE_EXPORT vec_basic linsolve(const DenseMatrix &system,
104  const vec_sym &syms);
105 
106 // Input as a vector of linear equations.
107 SYMENGINE_EXPORT vec_basic linsolve(const vec_basic &system,
108  const vec_sym &syms);
109 
110 // converts system of linear equations into Matrix form.
111 // first Matrix is for `A` and second one is for `b`.
112 SYMENGINE_EXPORT
113 std::pair<DenseMatrix, DenseMatrix>
114 linear_eqns_to_matrix(const vec_basic &equations, const vec_sym &syms);
115 } // namespace SymEngine
116 
117 #endif // SYMENGINE_SOLVE_H
Main namespace for SymEngine package.
Definition: add.cpp:19
RCP< const Dummy > dummy()
inline version to return Dummy
Definition: symbol.h:93
RCP< const UniversalSet > universalset()
Definition: sets.h:596