Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify_fractions throws error #380

Closed
itsdfish opened this issue Sep 28, 2021 · 3 comments
Closed

simplify_fractions throws error #380

itsdfish opened this issue Sep 28, 2021 · 3 comments
Labels
bug Something isn't working simplify

Comments

@itsdfish
Copy link

As discussed on Discourse, simplify_fractions does not work in the example below. Also, as far as I can tell, simplify_fractions is not in the documentation.

Example

using Symbolics

@variables a b c d e f g
x1 = (a+b) / (c + d) + (g+f) / (e + d)

simplify_fractions(x1)

Version

Julia 1.6.3, Symbolics 3.4.1

@jw3126
Copy link

jw3126 commented Oct 1, 2021

Here is another example, that throws a different error:

using Symbolics
normal01(x) = 1/√(2pi)*exp(-x^2/2)
normal(x,μ,σ) = 1/σ*normal01((x-μ)/σ)

@syms x μ t
f = normal(x,μ,(t))
f1 = Symbolics.derivative(f, t)
display(f1)
Symbolics.simplify_fractions(f1)

image

DivideError: integer division error

@YingboMa YingboMa transferred this issue from JuliaSymbolics/Symbolics.jl Oct 10, 2021
@YingboMa YingboMa added bug Something isn't working simplify labels Oct 10, 2021
@t0rny
Copy link

t0rny commented Nov 17, 2021

This is another example, which throws the same error as @jw3126 's case.

using Symbolics
@variables a b
x = (-48*a - 4*a*(b^2)) / (a*(b^3)) - 2*b*(12/(b^4))
simplify_fractions(x)
ERROR: DivideError: integer division error

And, I found that the following part of the function rm_gcds accidentally changed the type of coefficients from integer to floating point, which might be not expected.

# ns[i] = -4(b^6)*a - 72(b^4)*a, g = a
ns[i] = div(ns[i], g)    # line: 466
# ns[i] = -4.0(b^6) - 72.0(b^4)
ds[j] = div(ds[j], g)    # line: 467 (Error occurs at this line)

The function rm_gcds is used in simplify_div, which is included in simplify_fractions.

@hersle
Copy link

hersle commented May 9, 2024

All three examples given here work now. Maybe this can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working simplify
Projects
None yet
Development

No branches or pull requests

6 participants