-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
For example the following gives Float64 instead of rational values:
julia> @variables x y;
julia> Symbolics.solve_for([x + y ~ 2, x - y ~ 1], [x, y])
2-element Vector{Float64}:
1.5
0.5
julia> Symbolics.solve_for([x + y ~ 2//1, x - y ~ 1//1], [x, y])
2-element Vector{Float64}:
1.5
0.5Here using rational coefficients makes no difference.
Note that the behavior depends on the values of the coefficients. Here's a case where using rational literals results in a mix of Rational and Float64:
julia> Symbolics.solve_for([x + y ~ 3, x - y ~ 1], [x, y])
2-element Vector{Float64}:
2.0
1.0
julia> Symbolics.solve_for([x + y ~ 3//1, x - y ~ 1//1], [x, y])
2-element Vector{Real}:
2
1.0And here's one where a rational coefficient gives all-rational output:
julia> Symbolics.solve_for([x + 2y ~ 2, x - y ~ 1], [x, y])
2-element Vector{Float64}:
1.3333333333333335
0.3333333333333333
julia> Symbolics.solve_for([x + 2//1*y ~ 2, x - y ~ 1], [x, y])
2-element Vector{Rational{Int64}}:
4/3
1/3┆Issue is synchronized with this Trello card by Unito
zmoitier
Metadata
Metadata
Assignees
Labels
No labels