@@ -20,9 +20,12 @@ transformer(eq::SymbolicUtils.Div, f) = transformer(arguments(eq)[1],f) * transf
2020function transformer (eq:: SymbolicUtils.Pow , f)
2121 y, k = arguments (eq)
2222
23- if isinteger (k)
24- μ = next_variable! (f, k < 0 ? inv (y) : y)
25- return μ ^ abs (k)
23+ if is_pos_int (k)
24+ μ = next_variable! (f, y)
25+ return μ ^ k
26+ elseif is_neg_int (k)
27+ μ = next_variable! (f, inv (y))
28+ return μ ^ - k
2629 else
2730 return next_variable! (f, y^ k)
2831 end
@@ -54,32 +57,29 @@ function substitute_x(eq, x, sub)
5457end
5558
5659function generate_homotopy (eq, x)
57- q, sub = transform (eq, x)
58- d = degree (q)
59- n = length (sub)
60+ q, sub = transform (eq, x)
61+ S = 0
6062
61- S = Set {Any} ()
62-
63- for i = 1 : n
63+ for i = 1 : length (sub)
6464 μ = u[i]
6565 h₁, ∂h₁ = apply_partial_int_rules (sub[μ])
6666 h₂ = expand_derivatives (Differential (μ)(q))
6767
6868 h₁ = substitute_x (h₁, x, sub)
6969 h₂ = substitute_x (h₂ * ∂h₁^- 1 , x, sub)
7070
71- H = sum ((Differential (x)^ i)(h₂) for i= 1 : d- 1 ; init= (1 + h₂))
72- I = expand (expand_derivatives ((1 + h₁) * H))
73- enqueue_expr! (S, I, x)
71+ S += expand ((1 + h₁) * (1 + h₂))
7472 end
7573
76- return [one (x); [s for s in S]]
74+ unique ( [one (x); [equivalent (t,x) for t in terms (S)]])
7775end
7876
7977# #############################################################################
8078
81- ∂ (x) = expand_derivatives (Differential (𝑥)(x))
82- cabs (x) = sqrt (x * conj (x))
79+ function ∂ (x)
80+ d = expand_derivatives (Differential (𝑥)(x))
81+ return isequal (d, 0 ) ? 1 : d
82+ end
8383
8484partial_int_rules = [
8585 @rule 𝛷 (^ (sin (~ x), ~ k:: is_neg )) => 𝛷 (^ (csc (~ x), - ~ k))
@@ -131,7 +131,6 @@ partial_int_rules = [
131131 @rule 𝛷 (sqrt (~ x)) => (sum (candidate_sqrt (~ x,0.5 ); init= one (~ x)), 1 )
132132 @rule 𝛷 (^ (sqrt (~ x),- 1 )) => 𝛷 (^ (~ x,- 0.5 ))
133133
134-
135134 @rule 𝛷 (^ (~ x, - 1 )) => (log (~ x), ∂ (~ x))
136135 @rule 𝛷 (1 / ~ x) => 𝛷 (^ (~ x, - 1 ))
137136 @rule 𝛷 (^ (~ x, ~ k)) => (^ (~ x, ~ k+ 1 ), ∂ (~ x))
0 commit comments