SymPy Simplify Problem with a lot of symbols

Hi all,

I just want to know why simplify((a*x - b)*(a*x + b)) can’t become a^{2}x^{2} -b^{2} in Julia?

using SymPy
@syms x, a, b, c, t, u

c = (a^2 - b^2)/(2*a*b)
d = ((a*x -b)/(a*x+b))^c
f1(x) = log(d)

u = log(x^2 + x - 1)
f2(x) = integrate((cos(t)^2), (t, 1, u))

a1 = diff(f1(x),x)
a2 = diff(f2(x),x)

println("Computing symbolic derivative")
print("a. ", simplify(a1))
println("= ", a1(1))
print("b.  ", simplify(a2))
println("= ", a2(1))

The point (a) should have the answer of 1, but instead of substituting 1 into x it substitutes 1 into a

julia> simplify(a1(x=>1))
1
1 Like

Thanks for this revelation. You are my savior!