__init__.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # This file is part of TRS (http://math.kompiler.org)
  2. #
  3. # TRS is free software: you can redistribute it and/or modify it under the
  4. # terms of the GNU Affero General Public License as published by the Free
  5. # Software Foundation, either version 3 of the License, or (at your option) any
  6. # later version.
  7. #
  8. # TRS is distributed in the hope that it will be useful, but WITHOUT ANY
  9. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  10. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  11. # details.
  12. #
  13. # You should have received a copy of the GNU Affero General Public License
  14. # along with TRS. If not, see <http://www.gnu.org/licenses/>.
  15. from ..node import OP_ADD, OP_MUL, OP_DIV, OP_POW, OP_NEG, OP_SIN, OP_COS, \
  16. OP_TAN, OP_DER, OP_LOG, OP_INT, OP_INT_INDEF, OP_EQ, OP_ABS, OP_SQRT, \
  17. OP_AND, OP_OR
  18. from .groups import match_combine_groups
  19. from .factors import match_expand
  20. from .powers import match_add_exponents, match_subtract_exponents, \
  21. match_multiply_exponents, match_duplicate_exponent, \
  22. match_raised_fraction, match_remove_negative_exponent, \
  23. match_exponent_to_root, match_extend_exponent, match_constant_exponent
  24. from .numerics import match_add_numerics, match_divide_numerics, \
  25. match_multiply_numerics, match_raise_numerics
  26. from .fractions import match_constant_division, match_add_fractions, \
  27. match_multiply_fractions, match_divide_fractions, \
  28. match_extract_fraction_terms, match_division_in_denominator
  29. from .negation import match_negated_factor, match_negate_polynome, \
  30. match_negated_division
  31. from .sort import match_sort_polynome, match_sort_monomial
  32. from .goniometry import match_add_quadrants, match_negated_parameter, \
  33. match_half_pi_subtraction, match_standard_radian
  34. from .derivatives import match_zero_derivative, \
  35. match_one_derivative, match_variable_power, \
  36. match_const_deriv_multiplication, match_logarithmic, \
  37. match_goniometric, match_sum_product_rule, match_quotient_rule
  38. from .logarithmic import match_constant_logarithm, \
  39. match_add_logarithms, match_raised_base, match_factor_out_exponent, \
  40. match_factor_in_multiplicant, match_expand_terms
  41. from .integrals import match_solve_indef, match_constant_integral, \
  42. match_integrate_variable_power, match_factor_out_constant, \
  43. match_division_integral, match_function_integral, \
  44. match_sum_rule_integral, match_remove_indef_constant
  45. from .lineq import match_move_term, match_multiple_equations, match_double_case
  46. from .absolute import match_factor_out_abs_term
  47. from .sqrt import match_reduce_sqrt
  48. RULES = {
  49. OP_ADD: [match_add_numerics, match_add_fractions,
  50. match_combine_groups, match_add_quadrants,
  51. match_add_logarithms, match_sort_polynome],
  52. OP_MUL: [match_multiply_numerics, match_expand, match_add_exponents,
  53. match_negated_factor, match_multiply_fractions,
  54. match_factor_in_multiplicant, match_sort_monomial],
  55. OP_DIV: [match_subtract_exponents, match_divide_numerics,
  56. match_constant_division, match_divide_fractions,
  57. match_negated_division, match_extract_fraction_terms,
  58. match_division_in_denominator],
  59. OP_POW: [match_multiply_exponents, match_duplicate_exponent,
  60. match_raised_fraction, match_remove_negative_exponent,
  61. match_exponent_to_root, match_extend_exponent,
  62. match_constant_exponent, match_raise_numerics,
  63. match_raised_base],
  64. OP_NEG: [match_negate_polynome],
  65. OP_SIN: [match_negated_parameter, match_half_pi_subtraction,
  66. match_standard_radian],
  67. OP_COS: [match_negated_parameter, match_half_pi_subtraction,
  68. match_standard_radian],
  69. OP_TAN: [match_standard_radian],
  70. OP_DER: [match_zero_derivative, match_one_derivative,
  71. match_variable_power, match_const_deriv_multiplication,
  72. match_logarithmic, match_goniometric, match_sum_product_rule,
  73. match_quotient_rule],
  74. OP_LOG: [match_constant_logarithm, match_factor_out_exponent,
  75. match_expand_terms],
  76. OP_INT: [match_integrate_variable_power, match_constant_integral,
  77. match_factor_out_constant, match_division_integral,
  78. match_function_integral, match_sum_rule_integral],
  79. OP_INT_INDEF: [match_remove_indef_constant, match_solve_indef],
  80. OP_EQ: [match_move_term],
  81. OP_ABS: [match_factor_out_abs_term],
  82. OP_SQRT: [match_reduce_sqrt],
  83. OP_AND: [match_multiple_equations, match_double_case],
  84. OP_OR: [match_double_case],
  85. }