When I evaluate the following with explicit coefficients, I get the correct answer,
# This works:
x = ysym("x")
p = -2 + -1.5*x + 0.75*x^2 + 0.25*x^3
res = yac_expr(paste0("PSolve(", p,",",x, ")"))
eval(res)
#[1] 2 -4 -1
However, if I replace the -1.5 coefficient with a symbol y, the following evaluation at y=-1.5 outputs something different,
# Now try to plug in one of the coefficients:
x = ysym("x")
y = ysym("y")
p = yac_expr(-2 + y*x + 0.75*x^2 + 0.25*x^3)
res = yac_expr(paste0("PSolve(", p,",",x, ")"))
eval(res, list(y = -1.5))
#[1] NaN+ 0i NaN+NaNi NaN+NaNi
With warnings about NaNs produced from sqrts.
What am I doing wrong?