@@ -22,17 +22,23 @@ transformer(eq::SymbolicUtils.Div, f) = transformer(arguments(eq)[1],f) * transf
2222function transformer (eq:: SymbolicUtils.Pow , f)
2323 y, k = arguments (eq)
2424
25- r = nice_parameter (k)
26- if r isa Rational || isinteger (r)
27- a, b = numerator (r), denominator (r)
25+ # if is_poly(y)
26+ # return next_variable!(f, y)^k
27+ # end
28+
29+ # r = nice_parameter(k)
30+ # if r isa Rational || isinteger(r)
31+ if isinteger (k)
32+ a, b = k, 1
33+ # a, b = numerator(r), denominator(r)
2834 if k < 0
2935 y = inv (y)
3036 end
3137 f. deg = max (f. deg, abs (a))
3238 μ = next_variable! (f, b == 1 ? y : y ^ (1 / b))
3339 return μ ^ abs (a)
3440 else
35- return next_variable! (f, y ^ k)
41+ return next_variable! (f, y^ k)
3642 end
3743end
3844
4854function transform (eq, x)
4955 eq = substitute (eq, Dict (x => 𝑥))
5056 f = Transform (1 , Dict (), 1 , false )
51- return transformer (eq, f), f. sub, f. deg
57+ p = transformer (eq, f)
58+ if ! any (is_poly, values (f. sub))
59+ p *= next_variable! (f, 1 )
60+ end
61+ return p, f. sub, f. deg
5262end
5363
5464function homotopy_integrand (eq, x)
@@ -68,30 +78,30 @@ function homotopy_integrand(eq, x)
6878end
6979
7080function expand_integrand (I, x, deg)
71- E = sum ((Differential (x)^ i)(I) for i= 1 : deg- 1 ; init= I) # * (1+x)
72- S = Set {Any} ()
73- enqueue_expr_ex! (S, expand (expand_derivatives (E)), x)
74- return [one (x); [s for s in S]]
75-
81+ # E = sum((Differential(x)^i)(I) for i=1:deg-1; init=I) #* (1+x)
7682 # S = Set{Any}()
77- # # T = Set{Any}()
78- # Q₁ = Queue{Any}()
79- #
80- # enqueue_expr_ex!(S, Q₁, expand(I), x)
81- #
82- # D = Differential(x)
83- #
84- # for i = 1:deg
85- # Q₂ = Queue{Any}()
86- # while !isempty(Q₁) # && length(S) < max_terms
87- # y = dequeue!(Q₁)
88- # E = expand(expand_derivatives(D(y)))
89- # enqueue_expr_ex!(S, Q₂, E, x)
90- # end
91- # Q₁ = Q₂
92- # end
93- #
83+ # enqueue_expr_ex!(S, expand(expand_derivatives(E)), x)
9484 # return [one(x); [s for s in S]]
85+
86+ S = Set {Any} ()
87+ # T = Set{Any}()
88+ Q₁ = Queue {Any} ()
89+
90+ enqueue_expr_ex! (S, Q₁, expand (I), x)
91+
92+ D = Differential (x)
93+
94+ for i = 1 : deg
95+ Q₂ = Queue {Any} ()
96+ while ! isempty (Q₁) # && length(S) < max_terms
97+ y = dequeue! (Q₁)
98+ E = expand (expand_derivatives (D (y)))
99+ enqueue_expr_ex! (S, Q₂, E, x)
100+ end
101+ Q₁ = Q₂
102+ end
103+
104+ return [one (x); [s for s in S]]
95105end
96106
97107function expand_integrand (I, x, deg)
@@ -113,7 +123,8 @@ function substitute_x(eq, x, sub)
113123end
114124
115125function generate_homotopy2 (eq, x)
116- q, sub, deg = transform (eq, x)
126+ q, sub = transform (eq, x)
127+ d = degree (q)
117128 n = length (sub)
118129
119130 S = Set {Any} ()
@@ -126,17 +137,17 @@ function generate_homotopy2(eq, x)
126137 h₁ = substitute_x (h₁, x, sub)
127138 h₂ = substitute_x (h₂, x, sub)
128139
129- H = sum ((Differential (x)^ i)(h₁ * h ₂) for i= 1 : deg - 1 ; init= h₁ * h₂ )
130- I = expand (expand_derivatives (H))
140+ H = sum ((Differential (x)^ i)(h₂) for i= 1 : d - 1 ; init= ( 1 + h₂) )
141+ I = expand (expand_derivatives (( 1 + h₁) * H))
131142 enqueue_expr_ex! (S, I, x)
132143 end
133144
134- H = sum ((Differential (x)^ i)(eq) for i= 1 : deg- 1 ; init= eq)
135- I = expand ((1 + x) * expand_derivatives (H))
145+ # H = sum((Differential(x)^i)(eq) for i=1:deg-1; init=eq)
146+ # I = expand((1+x) * expand_derivatives(H))
136147 # enqueue_expr_ex!(S, I, x)
137148
138149 # return [one(x); [s for s in S]]
139- return [[x ^ i for i = 0 : deg] ; [s for s in S]]
150+ return [one (x) ; [s for s in S]]
140151end
141152
142153# #############################################################################
0 commit comments