@@ -77,6 +77,8 @@ function generate_homotopy(eq, x)
7777
7878 S += expand ((1 + h₁) * (1 + h₂))
7979 end
80+
81+ S = simplify (S)
8082
8183 unique ([one (x); [equivalent (t, x) for t in terms (S)]])
8284end
@@ -88,70 +90,63 @@ function ∂(x)
8890 return isequal (d, 0 ) ? 1 : d
8991end
9092
91- partial_int_rules = [@rule 𝛷 (sin (~ x)) => (cos (~ x), ∂ (~ x))
93+ partial_int_rules = [
94+ # trigonometric functions
95+ @rule 𝛷 (sin (~ x)) => (cos (~ x), ∂ (~ x))
9296 @rule 𝛷 (cos (~ x)) => (sin (~ x), ∂ (~ x))
9397 @rule 𝛷 (tan (~ x)) => (log (cos (~ x)), ∂ (~ x))
9498 @rule 𝛷 (csc (~ x)) => (log (csc (~ x) + cot (~ x)), ∂ (~ x))
9599 @rule 𝛷 (sec (~ x)) => (log (sec (~ x) + tan (~ x)), ∂ (~ x))
96100 @rule 𝛷 (cot (~ x)) => (log (sin (~ x)), ∂ (~ x))
101+ # hyperbolic functions
97102 @rule 𝛷 (sinh (~ x)) => (cosh (~ x), ∂ (~ x))
98103 @rule 𝛷 (cosh (~ x)) => (sinh (~ x), ∂ (~ x))
99104 @rule 𝛷 (tanh (~ x)) => (log (cosh (~ x)), ∂ (~ x))
100105 @rule 𝛷 (csch (~ x)) => (log (tanh (~ x / 2 )), ∂ (~ x))
101106 @rule 𝛷 (sech (~ x)) => (atan (sinh (~ x)), ∂ (~ x))
102107 @rule 𝛷 (coth (~ x)) => (log (sinh (~ x)), ∂ (~ x))
108+ # 1/trigonometric functions
103109 @rule 𝛷 (^ (sin (~ x), - 1 )) => (log (csc (~ x) + cot (~ x)), ∂ (~ x))
104110 @rule 𝛷 (^ (cos (~ x), - 1 )) => (log (sec (~ x) + tan (~ x)), ∂ (~ x))
105111 @rule 𝛷 (^ (tan (~ x), - 1 )) => (log (sin (~ x)), ∂ (~ x))
106112 @rule 𝛷 (^ (csc (~ x), - 1 )) => (cos (~ x), ∂ (~ x))
107113 @rule 𝛷 (^ (sec (~ x), - 1 )) => (sin (~ x), ∂ (~ x))
108114 @rule 𝛷 (^ (cot (~ x), - 1 )) => (log (cos (~ x)), ∂ (~ x))
115+ # 1/hyperbolic functions
109116 @rule 𝛷 (^ (sinh (~ x), - 1 )) => (log (tanh (~ x / 2 )), ∂ (~ x))
110117 @rule 𝛷 (^ (cosh (~ x), - 1 )) => (atan (sinh (~ x)), ∂ (~ x))
111118 @rule 𝛷 (^ (tanh (~ x), - 1 )) => (log (sinh (~ x)), ∂ (~ x))
112119 @rule 𝛷 (^ (csch (~ x), - 1 )) => (cosh (~ x), ∂ (~ x))
113120 @rule 𝛷 (^ (sech (~ x), - 1 )) => (sinh (~ x), ∂ (~ x))
114121 @rule 𝛷 (^ (coth (~ x), - 1 )) => (log (cosh (~ x)), ∂ (~ x))
115-
116- # @rule 𝛷(^(sin(~x), ~k::is_neg)) => 𝛷(^(csc(~x), -~k))
117- # @rule 𝛷(^(cos(~x), ~k::is_neg)) => 𝛷(^(sec(~x), -~k))
118- # @rule 𝛷(^(tan(~x), ~k::is_neg)) => 𝛷(^(cot(~x), -~k))
119- # @rule 𝛷(^(csc(~x), ~k::is_neg)) => 𝛷(^(sin(~x), -~k))
120- # @rule 𝛷(^(sec(~x), ~k::is_neg)) => 𝛷(^(cos(~x), -~k))
121- # @rule 𝛷(^(cot(~x), ~k::is_neg)) => 𝛷(^(tan(~x), -~k))
122- # @rule 𝛷(^(sinh(~x), ~k::is_neg)) => 𝛷(^(csch(~x), -~k))
123- # @rule 𝛷(^(cosh(~x), ~k::is_neg)) => 𝛷(^(sech(~x), -~k))
124- # @rule 𝛷(^(tanh(~x), ~k::is_neg)) => 𝛷(^(coth(~x), -~k))
125- # @rule 𝛷(^(csch(~x), ~k::is_neg)) => 𝛷(^(sinh(~x), -~k))
126- # @rule 𝛷(^(sech(~x), ~k::is_neg)) => 𝛷(^(cosh(~x), -~k))
127- # @rule 𝛷(^(coth(~x), ~k::is_neg)) => 𝛷(^(tanh(~x), -~k))
128-
122+ # inverse trigonometric functions
129123 @rule 𝛷 (asin (~ x)) => (~ x * asin (~ x) + sqrt (1 - ~ x * ~ x), ∂ (~ x))
130124 @rule 𝛷 (acos (~ x)) => (~ x * acos (~ x) + sqrt (1 - ~ x * ~ x), ∂ (~ x))
131125 @rule 𝛷 (atan (~ x)) => (~ x * atan (~ x) + log (~ x * ~ x + 1 ), ∂ (~ x))
132- @rule 𝛷 (acsc (~ x)) => (~ x * acsc (~ x) + acosh ( ~ x) , ∂ (~ x)) # needs an abs inside acosh
133- @rule 𝛷 (asec (~ x)) => (~ x * asec (~ x) + acosh (~ x), ∂ (~ x)) # needs an abs inside acosh
126+ @rule 𝛷 (acsc (~ x)) => (~ x * acsc (~ x) + atanh ( 1 - ^ ( ~ x, - 2 )) , ∂ (~ x))
127+ @rule 𝛷 (asec (~ x)) => (~ x * asec (~ x) + acosh (~ x), ∂ (~ x))
134128 @rule 𝛷 (acot (~ x)) => (~ x * acot (~ x) + log (~ x * ~ x + 1 ), ∂ (~ x))
129+ # inverse hyperbolic functions
135130 @rule 𝛷 (asinh (~ x)) => (~ x * asinh (~ x) + sqrt (~ x * ~ x + 1 ), ∂ (~ x))
136131 @rule 𝛷 (acosh (~ x)) => (~ x * acosh (~ x) + sqrt (~ x * ~ x - 1 ), ∂ (~ x))
137132 @rule 𝛷 (atanh (~ x)) => (~ x * atanh (~ x) + log (~ x + 1 ), ∂ (~ x))
138133 @rule 𝛷 (acsch (~ x)) => (acsch (~ x), ∂ (~ x))
139134 @rule 𝛷 (asech (~ x)) => (asech (~ x), ∂ (~ x))
140135 @rule 𝛷 (acoth (~ x)) => (~ x * acot (~ x) + log (~ x + 1 ), ∂ (~ x))
141- @rule 𝛷 ( log ( ~ x)) => ( ~ x + ~ x * log ( ~ x), ∂ ( ~ x))
142- @rule 𝛷 (^ (~ x, ~ k :: is_abs_half )) => (sum (candidate_sqrt (~ x, ~ k);
143- init = one ( ~ x)), 1 );
144- @rule 𝛷 (^ (~ x :: is_poly , ~ k:: is_neg )) => (sum ( candidate_pow_minus ( ~ x,
145- ~ k);
146- init = one (~ x)), 1 )
136+ # logarithmic and exponential functions
137+ @rule 𝛷 (log (~ x)) => (~ x + ~ x * log ( ~ x) + sum (candidate_pow_minus (~ x, - 1 ); init = one ( ~ x)), ∂ ( ~ x))
138+ @rule 𝛷 ( exp ( ~ x)) => ( exp ( ~ x), ∂ ( ~ x))
139+ @rule 𝛷 (^ (exp ( ~ x) , ~ k:: is_neg )) => (^ ( exp ( - ~ x), - ~ k), ∂ ( ~ x))
140+ # square-root functions
141+ @rule 𝛷 ( ^ ( ~ x, ~ k :: is_abs_half )) => ( sum ( candidate_sqrt ( ~ x, ~ k); init = one (~ x)), 1 );
147142 @rule 𝛷 (sqrt (~ x)) => (sum (candidate_sqrt (~ x, 0.5 ); init = one (~ x)), 1 );
148- @rule 𝛷 (^ (sqrt (~ x), - 1 )) => 𝛷 (^ (~ x, - 0.5 ))
143+ @rule 𝛷 (^ (sqrt (~ x), - 1 )) => 𝛷 (^ (~ x, - 0.5 ))
144+ # rational functions
145+ @rule 𝛷 (^ (~ x:: is_poly , ~ k:: is_neg )) => (sum (candidate_pow_minus (~ x, ~ k); init = one (~ x)), 1 )
149146 @rule 𝛷 (^ (~ x, - 1 )) => (log (~ x), ∂ (~ x))
150- @rule 𝛷 (^ (~ x, ~ k:: is_neg_int )) => (sum (^ (~ x, i) for i in (~ k + 1 ): - 1 ),
151- ∂ (~ x))
147+ @rule 𝛷 (^ (~ x, ~ k:: is_neg_int )) => (sum (^ (~ x, i) for i in (~ k + 1 ): - 1 ), ∂ (~ x))
152148 @rule 𝛷 (1 / ~ x) => 𝛷 (^ (~ x, - 1 ))
153- @rule 𝛷 (^ (~ x, ~ k)) => (^ (~ x, ~ k + 1 ), ∂ (~ x))
154- @rule 𝛷 (exp (~ x)) => (exp (~ x), ∂ (~ x))
149+ @rule 𝛷 (^ (~ x, ~ k)) => (^ (~ x, ~ k + 1 ), ∂ (~ x))
155150 @rule 𝛷 (1 ) => (𝑥, 1 )
156151 @rule 𝛷 (~ x) => ((~ x + ^ (~ x, 2 )), ∂ (~ x))]
157152
0 commit comments