The comparison is done via a numerical grid.
compare_reply_answer( reply, answer, compare_grid = NULL, replace_comma = TRUE, ans_tol = 0.01, insert_products = TRUE, allowed_functions = getGroupMembers("Math") )
reply | user-provided reply as string |
---|---|
answer | the true answer provided as |
compare_grid | grid to perform comparisons on; must have columns |
replace_comma | Replace ',' with '.' before parsing |
ans_tol | tolerance for comparisons |
insert_products | Make implicit products explicit |
allowed_functions | functions (sequence of characters) that should not have products, e.g. |
compare_reply_answer(reply = "2yx^2", answer = Ryacas::ysym("2*y*x^2"), compare_grid = expand.grid(x = seq(-10, 10, len = 10), y = seq(-10, 10, len = 10)))#> [1] TRUEcompare_reply_answer(reply = "2.1yx^2", answer = Ryacas::ysym("2*y*x^2"), compare_grid = expand.grid(x = seq(-10, 10, len = 10), y = seq(-10, 10, len = 10)))#> [1] FALSEcompare_reply_answer(reply = "2yx^2+0.01", answer = Ryacas::ysym("2*y*x^2"), compare_grid = expand.grid(x = seq(-10, 10, len = 10), y = seq(-10, 10, len = 10)), ans_tol = 1)#> [1] TRUE