Evaluate a yacas expression by replacing variables with values as for the given list.
y_eval(expr, ..., as.r = FALSE)
a valid yacas expression
a list of assignements (see example)
if TRUE, then the expression is evaluated as R (if any variable to be substituted in the expression is a vector, then a vector is returned). If it is FALSE (default), a yacc expression is returned, replacing scalar variables.
# Evaluate as yacas object
eq <- ysym("2*y+x^2+2*x-3")
y_eval(eq, x=3, y=2)
#> y: 16
# Evaluate as R expression:
y_eval(eq, x=3, y=2, as.r=TRUE)
#> [1] 16
# This allows to use vectors:
y_eval(eq, x=1:10, y=2, as.r=TRUE)
#> [1] 4 9 16 25 36 49 64 81 100 121
# and to plot functions:
curve(y_eval(eq, x=x, y=2, as.r=TRUE), xlim=c(0,10))