@@ -14,13 +14,13 @@ function next_variable!(f, eq)
1414end
1515
1616function transformer (eq:: SymbolicUtils.Add , f)
17- sum (transformer (t, f) for t in arguments (eq); init = 0 )
17+ return sum (transformer (t, f) for t in arguments (eq); init = 0 )
1818end
1919function transformer (eq:: SymbolicUtils.Mul , f)
20- prod (transformer (t, f) for t in arguments (eq); init = 1 )
20+ return prod (transformer (t, f) for t in arguments (eq); init = 1 )
2121end
2222function transformer (eq:: SymbolicUtils.Div , f)
23- transformer (arguments (eq)[1 ], f) * transformer (inv ( arguments (eq)[2 ]) , f)
23+ return transformer (arguments (eq)[1 ], f) * transformer (arguments (eq)[2 ]^- 1 , f)
2424end
2525
2626function transformer (eq:: SymbolicUtils.Pow , f)
@@ -63,6 +63,7 @@ function substitute_x(eq, x, sub)
6363end
6464
6565function generate_homotopy (eq, x)
66+ eq = eq isa Num ? eq. val : eq
6667 q, sub = transform (eq, x)
6768 S = 0
6869
@@ -87,30 +88,44 @@ function ∂(x)
8788 return isequal (d, 0 ) ? 1 : d
8889end
8990
90- partial_int_rules = [@rule 𝛷 (^ (sin (~ x), ~ k:: is_neg )) => 𝛷 (^ (csc (~ x), - ~ k))
91- @rule 𝛷 (^ (cos (~ x), ~ k:: is_neg )) => 𝛷 (^ (sec (~ x), - ~ k))
92- @rule 𝛷 (^ (tan (~ x), ~ k:: is_neg )) => 𝛷 (^ (cot (~ x), - ~ k))
93- @rule 𝛷 (^ (csc (~ x), ~ k:: is_neg )) => 𝛷 (^ (sin (~ x), - ~ k))
94- @rule 𝛷 (^ (sec (~ x), ~ k:: is_neg )) => 𝛷 (^ (cos (~ x), - ~ k))
95- @rule 𝛷 (^ (cot (~ x), ~ k:: is_neg )) => 𝛷 (^ (tan (~ x), - ~ k))
96- @rule 𝛷 (^ (sinh (~ x), ~ k:: is_neg )) => 𝛷 (^ (csch (~ x), - ~ k))
97- @rule 𝛷 (^ (cosh (~ x), ~ k:: is_neg )) => 𝛷 (^ (sech (~ x), - ~ k))
98- @rule 𝛷 (^ (tanh (~ x), ~ k:: is_neg )) => 𝛷 (^ (coth (~ x), - ~ k))
99- @rule 𝛷 (^ (csch (~ x), ~ k:: is_neg )) => 𝛷 (^ (sinh (~ x), - ~ k))
100- @rule 𝛷 (^ (sech (~ x), ~ k:: is_neg )) => 𝛷 (^ (cosh (~ x), - ~ k))
101- @rule 𝛷 (^ (coth (~ x), ~ k:: is_neg )) => 𝛷 (^ (tanh (~ x), - ~ k))
102- @rule 𝛷 (sin (~ x)) => (cos (~ x), ∂ (~ x))
91+ partial_int_rules = [@rule 𝛷 (sin (~ x)) => (cos (~ x), ∂ (~ x))
10392 @rule 𝛷 (cos (~ x)) => (sin (~ x), ∂ (~ x))
10493 @rule 𝛷 (tan (~ x)) => (log (cos (~ x)), ∂ (~ x))
105- @rule 𝛷 (csc (~ x)) => (log (sin (~ x)^- 1 - cos (~ x) * sin ( ~ x) ^- 1 ), ∂ (~ x))
106- @rule 𝛷 (sec (~ x)) => (log (cos (~ x)^- 1 + sin (~ x) * cos ( ~ x) ^- 1 ), ∂ (~ x))
94+ @rule 𝛷 (csc (~ x)) => (log (csc (~ x) + cot (~ x)), ∂ (~ x))
95+ @rule 𝛷 (sec (~ x)) => (log (sec (~ x) + tan (~ x)), ∂ (~ x))
10796 @rule 𝛷 (cot (~ x)) => (log (sin (~ x)), ∂ (~ x))
10897 @rule 𝛷 (sinh (~ x)) => (cosh (~ x), ∂ (~ x))
10998 @rule 𝛷 (cosh (~ x)) => (sinh (~ x), ∂ (~ x))
11099 @rule 𝛷 (tanh (~ x)) => (log (cosh (~ x)), ∂ (~ x))
111- @rule 𝛷 (csch (~ x)) => (log (sinh (~ x) ^- 1 + cosh ( ~ x) * sinh ( ~ x) ^- 1 ), ∂ (~ x))
112- @rule 𝛷 (sech (~ x)) => (log ( cosh ( ~ x) ^- 1 + sinh (~ x) * cosh ( ~ x) ^- 1 ), ∂ (~ x))
100+ @rule 𝛷 (csch (~ x)) => (log (tanh (~ x / 2 ) ), ∂ (~ x))
101+ @rule 𝛷 (sech (~ x)) => (atan ( sinh (~ x)), ∂ (~ x))
113102 @rule 𝛷 (coth (~ x)) => (log (sinh (~ x)), ∂ (~ x))
103+ @rule 𝛷 (^ (sin (~ x), - 1 )) => (log (csc (~ x) + cot (~ x)), ∂ (~ x))
104+ @rule 𝛷 (^ (cos (~ x), - 1 )) => (log (sec (~ x) + tan (~ x)), ∂ (~ x))
105+ @rule 𝛷 (^ (tan (~ x), - 1 )) => (log (sin (~ x)), ∂ (~ x))
106+ @rule 𝛷 (^ (csc (~ x), - 1 )) => (cos (~ x), ∂ (~ x))
107+ @rule 𝛷 (^ (sec (~ x), - 1 )) => (sin (~ x), ∂ (~ x))
108+ @rule 𝛷 (^ (cot (~ x), - 1 )) => (log (cos (~ x)), ∂ (~ x))
109+ @rule 𝛷 (^ (sinh (~ x), - 1 )) => (log (tanh (~ x / 2 )), ∂ (~ x))
110+ @rule 𝛷 (^ (cosh (~ x), - 1 )) => (atan (sinh (~ x)), ∂ (~ x))
111+ @rule 𝛷 (^ (tanh (~ x), - 1 )) => (log (sinh (~ x)), ∂ (~ x))
112+ @rule 𝛷 (^ (csch (~ x), - 1 )) => (cosh (~ x), ∂ (~ x))
113+ @rule 𝛷 (^ (sech (~ x), - 1 )) => (sinh (~ x), ∂ (~ x))
114+ @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+
114129 @rule 𝛷 (asin (~ x)) => (~ x * asin (~ x) + sqrt (1 - ~ x * ~ x), ∂ (~ x))
115130 @rule 𝛷 (acos (~ x)) => (~ x * acos (~ x) + sqrt (1 - ~ x * ~ x), ∂ (~ x))
116131 @rule 𝛷 (atan (~ x)) => (~ x * atan (~ x) + log (~ x * ~ x + 1 ), ∂ (~ x))
@@ -132,6 +147,8 @@ partial_int_rules = [@rule 𝛷(^(sin(~x), ~k::is_neg)) => 𝛷(^(csc(~x), -~k))
132147 @rule 𝛷 (sqrt (~ x)) => (sum (candidate_sqrt (~ x, 0.5 ); init = one (~ x)), 1 );
133148 @rule 𝛷 (^ (sqrt (~ x), - 1 )) => 𝛷 (^ (~ x, - 0.5 ))
134149 @rule 𝛷 (^ (~ x, - 1 )) => (log (~ x), ∂ (~ x))
150+ @rule 𝛷 (^ (~ x, ~ k:: is_neg_int )) => (sum (^ (~ x, i) for i in (~ k + 1 ): - 1 ),
151+ ∂ (~ x))
135152 @rule 𝛷 (1 / ~ x) => 𝛷 (^ (~ x, - 1 ))
136153 @rule 𝛷 (^ (~ x, ~ k)) => (^ (~ x, ~ k + 1 ), ∂ (~ x))
137154 @rule 𝛷 (exp (~ x)) => (exp (~ x), ∂ (~ x))
0 commit comments