Skip to content

Commit 5ade47f

Browse files
committed
Generate fractions in Taylor series coefficients a bit more robustly
1 parent 779810e commit 5ade47f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/src/tutorials/perturbation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function solve_perturbed(eq, x, x₀, ϵ, order)
7979
8080
# solve higher-order equations order-by-order
8181
for i in 2:length(eqs)
82+
eqs[i] = substitute(eqs[i], sol) # substitute lower-order solutions
8283
x_coeff = Symbolics.symbolic_linear_solve(eqs[i], x_coeffs[i]) # solve linear n-th order equation for x_n
83-
x_coeff = substitute(x_coeff, sol) # substitute lower-order solutions to get numerical value
8484
sol = merge(sol, Dict(x_coeffs[i] => x_coeff)) # store solution
8585
end
8686

src/taylor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function taylor_coeff(f, x, n = missing; rationalize=true)
7272
if rationalize && unwrap(c) isa Number
7373
# TODO: make rational coefficients "organically" and not using rationalize (see https://github.com/JuliaSymbolics/Symbolics.jl/issues/1299)
7474
c = unwrap(c)
75-
c = isinteger(c) ? Int(c) : Base.rationalize(c) # convert non-integer floats to rational numbers; avoid name clash between rationalize and Base.rationalize()
75+
c = Base.rationalize(c) # convert integers/floats to rational numbers; avoid name clash between rationalize and Base.rationalize()
7676
end
7777
return c
7878
end

0 commit comments

Comments
 (0)