Notebooks · lib/cas/check/acceptance_check
lib/ cas/ check/ acceptance_check.viv
lib/cas/check/acceptance_check.viv · 1 code cellOpen in the workbenchDownload .vivLook inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.
[1]lines 1–211
# Written by `viv check --phrases`: each phrase of the program held to the # closed form lib/cas finds for it (lang/viv/src/cas_check.rs). from cas.phrases import ( cas_check_deriv, cas_check_holds, cas_check_integral, cas_check_root, cas_check_summary, cas_check_value, ) pi = 3.141592653589793 c = 2.0 k = 3.0 M = [[4.0, 1.0, 2.0], [1.5, 5.0, 3.0], [2.0, 3.5, 6.0]] u = [1.0, -2.0, 2.0] v = [3.0, 0.5, 4.0] cas_got_0 = integrate x^2 from 1 to 2 cas_check_integral(0, 25, "integrate x^2 from 1 to 2", "(x)^(2)", "x", "1", "2", cas_got_0, "q_gauss", 0) cas_got_1 = integrate 3*x^2 - 2*x + 1 from 0 to 2 cas_check_integral(1, 26, "integrate 3*x^2 - 2*x + 1 from 0 to 2", "(((3 * (x)^(2)) - (2 * x)) + 1)", "x", "0", "2", cas_got_1, "q_gauss", 0) cas_got_2 = take the integral of x^5 - x from -1 to 2 using romberg cas_check_integral(2, 27, "take the integral of x^5 - x from -1 to 2 using romberg", "((x)^(5) - x)", "x", "(-1)", "2", cas_got_2, "q_romberg", 0) cas_got_3 = integrate x^4 from 0 to 1 using simpson with 10 intervals cas_check_integral(3, 28, "integrate x^4 from 0 to 1 using simpson with 10 intervals", "(x)^(4)", "x", "0", "1", cas_got_3, "simpson", 10) cas_got_4 = integrate sin(x) from 0 to pi cas_check_integral(4, 30, "integrate sin(x) from 0 to pi", "sin(x)", "x", "0", "pi", cas_got_4, "q_gauss", 0) cas_got_5 = integrate cos(2*x) from 0 to pi/4 cas_check_integral(5, 31, "integrate cos(2*x) from 0 to pi/4", "cos((2 * x))", "x", "0", "(pi / 4)", cas_got_5, "q_gauss", 0) cas_got_6 = integrate sin(x)*cos(x) from 0 to pi/2 cas_check_integral(6, 32, "integrate sin(x)*cos(x) from 0 to pi/2", "(sin(x) * cos(x))", "x", "0", "(pi / 2)", cas_got_6, "q_gauss", 0) cas_got_7 = integrate x*sin(x) from 0 to pi using adaptive simpson cas_check_integral(7, 33, "integrate x*sin(x) from 0 to pi using adaptive simpson", "(x * sin(x))", "x", "0", "pi", cas_got_7, "q_adaptive", 0) cas_got_8 = take the integral of 1/(1 + x^2) from 0 to 1 cas_check_integral(8, 34, "take the integral of 1/(1 + x^2) from 0 to 1", "(1 / (1 + (x)^(2)))", "x", "0", "1", cas_got_8, "q_gauss", 0) cas_got_9 = integrate 1/sqrt(1 - x^2) from 0 to 0.5 cas_check_integral(9, 35, "integrate 1/sqrt(1 - x^2) from 0 to 0.5", "(1 / sqrt((1 - (x)^(2))))", "x", "0", "0.5", cas_got_9, "q_gauss", 0) cas_got_10 = integrate exp(x) from 0 to 1 cas_check_integral(10, 37, "integrate exp(x) from 0 to 1", "exp(x)", "x", "0", "1", cas_got_10, "q_gauss", 0) cas_got_11 = integrate x*exp(-x) from 0 to 1 cas_check_integral(11, 38, "integrate x*exp(-x) from 0 to 1", "(x * exp((-x)))", "x", "0", "1", cas_got_11, "q_gauss", 0) cas_got_12 = integrate exp(x) from 0 to 1 using the trapezoid rule with 100 intervals cas_check_integral(12, 39, "integrate exp(x) from 0 to 1 using the trapezoid rule with 100 intervals", "exp(x)", "x", "0", "1", cas_got_12, "trapezoid", 100) cas_got_13 = integrate 1/x from 1 to 3 cas_check_integral(13, 40, "integrate 1/x from 1 to 3", "(1 / x)", "x", "1", "3", cas_got_13, "q_gauss", 0) cas_got_14 = integrate cosh(x) from 0 to 1 using every method cas_check_integral(14, 41, "integrate cosh(x) from 0 to 1 using every method", "cosh(x)", "x", "0", "1", cas_got_14, "integrate", 0) cas_got_15 = integrate exp(-x^2) from 0 to 1 cas_check_integral(15, 43, "integrate exp(-x^2) from 0 to 1", "exp((-(x)^(2)))", "x", "0", "1", cas_got_15, "q_gauss", 0) cas_got_16 = integrate x*exp(-x^2) from 0 to 2 cas_check_integral(16, 44, "integrate x*exp(-x^2) from 0 to 2", "(x * exp((-(x)^(2))))", "x", "0", "2", cas_got_16, "q_gauss", 0) cas_got_17 = integrate x^2*exp(-k*x^2) from 0 to 1 cas_check_integral(17, 45, "integrate x^2*exp(-k*x^2) from 0 to 1", "((x)^(2) * exp(((-(3)) * (x)^(2))))", "x", "0", "1", cas_got_17, "q_gauss", 0) cas_got_18 = differentiate x^3 - 2*x at 2 cas_check_deriv(18, 47, "differentiate x^3 - 2*x at 2", "((x)^(3) - (2 * x))", "x", "2", cas_got_18, "deriv") cas_got_19 = take the derivative of sin(x)*exp(x) at 0.5 cas_check_deriv(19, 48, "take the derivative of sin(x)*exp(x) at 0.5", "(sin(x) * exp(x))", "x", "0.5", cas_got_19, "deriv") cas_got_20 = differentiate log(1 + x^2) at 1 cas_check_deriv(20, 49, "differentiate log(1 + x^2) at 1", "log((1 + (x)^(2)))", "x", "1", cas_got_20, "deriv") cas_got_21 = differentiate atan(x) at 1 using the symbolic derivative cas_check_deriv(21, 51, "differentiate atan(x) at 1 using the symbolic derivative", "atan(x)", "x", "1", cas_got_21, "cas_deriv_at") cas_got_22 = differentiate erf(x) at 0 using the symbolic derivative cas_check_deriv(22, 52, "differentiate erf(x) at 0 using the symbolic derivative", "erf(x)", "x", "0", cas_got_22, "cas_deriv_at") cas_got_23 = differentiate sqrt(x) at 4 using the symbolic derivative cas_check_deriv(23, 53, "differentiate sqrt(x) at 4 using the symbolic derivative", "sqrt(x)", "x", "4", cas_got_23, "cas_deriv_at") cas_got_24 = take the derivative of k*x^3 + sin(x) at 0.5 using the symbolic derivative cas_check_deriv(24, 54, "take the derivative of k*x^3 + sin(x) at 0.5 using the symbolic derivative", "(((3) * (x)^(3)) + sin(x))", "x", "0.5", cas_got_24, "cas_deriv_at") cas_got_25 = solve x^2 = c between 0 and 2 cas_check_root(25, 56, "solve x^2 = c between 0 and 2", "((x)^(2) - (2))", "x", "0", "2", cas_got_25, "r_safe") cas_got_26 = solve x^2 - 5*x + 6 between 2.5 and 4 using bisection cas_check_root(26, 57, "solve x^2 - 5*x + 6 between 2.5 and 4 using bisection", "(((x)^(2) - (5 * x)) + 6)", "x", "2.5", "4", cas_got_26, "r_bisect") cas_got_27 = solve 2*x^2 + 3*x - 2 = 0 starting at 1 cas_check_root(27, 58, "solve 2*x^2 + 3*x - 2 = 0 starting at 1", "((((2 * (x)^(2)) + (3 * x)) - 2) - 0)", "x", "1", "", cas_got_27, "r_newton") cas_got_28 = solve x^2 - 2*x + 1 starting at 3 using newton cas_check_root(28, 59, "solve x^2 - 2*x + 1 starting at 3 using newton", "(((x)^(2) - (2 * x)) + 1)", "x", "3", "", cas_got_28, "r_newton") cas_got_29 = solve x^3 - 6*x^2 + 11*x - 6 between 2.5 and 3.5 using illinois cas_check_root(29, 61, "solve x^3 - 6*x^2 + 11*x - 6 between 2.5 and 3.5 using illinois", "((((x)^(3) - (6 * (x)^(2))) + (11 * x)) - 6)", "x", "2.5", "3.5", cas_got_29, "r_illinois") cas_got_30 = solve x^3 - 2*x - 5 between 2 and 3 cas_check_root(30, 62, "solve x^3 - 2*x - 5 between 2 and 3", "(((x)^(3) - (2 * x)) - 5)", "x", "2", "3", cas_got_30, "r_safe") cas_got_31 = solve x^3 - 3*x + 1 between 0 and 1 using every method cas_check_root(31, 63, "solve x^3 - 3*x + 1 between 0 and 1 using every method", "(((x)^(3) - (3 * x)) + 1)", "x", "0", "1", cas_got_31, "find_root") cas_got_32 = take the trace of M cas_check_value(32, 65, "take the trace of M", "(4) + (5) + (6)", cas_got_32, "trace", "the sum of the diagonal") cas_got_33 = take the norm of [3.0, 4.0] cas_check_value(33, 66, "take the norm of [3.0, 4.0]", "sqrt((3)^2 + (4)^2)", cas_got_33, "norm", "the square root of the sum of the squares") cas_got_34 = take the dot product of u and v cas_check_value(34, 67, "take the dot product of u and v", "(1) * (3) + ((-2)) * (0.5) + (2) * (4)", cas_got_34, "dot", "the sum of the products of the entries") cas_got_35 = take the mean of [1.0, 2.0, 4.0] cas_check_value(35, 68, "take the mean of [1.0, 2.0, 4.0]", "((1) + (2) + (4)) / 3", cas_got_35, "mean", "the sum of the entries over their number") cas_got_36 = take the distance between u and v cas_check_value(36, 69, "take the distance between u and v", "sqrt(((1) - (3))^2 + (((-2)) - (0.5))^2 + ((2) - (4))^2)", cas_got_36, "norm", "the norm of the difference") cas_got_37 = integrate exp(x^3) from 0 to 1 cas_check_integral(37, 71, "integrate exp(x^3) from 0 to 1", "exp((x)^(3))", "x", "0", "1", cas_got_37, "q_gauss", 0) cas_got_38 = solve x^5 - x - 1 between 1 and 2 cas_check_root(38, 72, "solve x^5 - x - 1 between 1 and 2", "(((x)^(5) - x) - 1)", "x", "1", "2", cas_got_38, "r_safe") cas_check_summary() test "line 25: integrate x^2 from 1 to 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(0)) } test "line 26: integrate 3*x^2 - 2*x + 1 from 0 to 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(1)) } test "line 27: take the integral of x^5 - x from -1 to 2 using romberg agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(2)) } test "line 28: integrate x^4 from 0 to 1 using simpson with 10 intervals agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(3)) } test "line 30: integrate sin(x) from 0 to pi agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(4)) } test "line 31: integrate cos(2*x) from 0 to pi/4 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(5)) } test "line 32: integrate sin(x)*cos(x) from 0 to pi/2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(6)) } test "line 33: integrate x*sin(x) from 0 to pi using adaptive simpson agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(7)) } test "line 34: take the integral of 1/(1 + x^2) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(8)) } test "line 35: integrate 1/sqrt(1 - x^2) from 0 to 0.5 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(9)) } test "line 37: integrate exp(x) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(10)) } test "line 38: integrate x*exp(-x) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(11)) } test "line 39: integrate exp(x) from 0 to 1 using the trapezoid rule with 100 intervals agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(12)) } test "line 40: integrate 1/x from 1 to 3 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(13)) } test "line 41: integrate cosh(x) from 0 to 1 using every method agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(14)) } test "line 43: integrate exp(-x^2) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(15)) } test "line 44: integrate x*exp(-x^2) from 0 to 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(16)) } test "line 45: integrate x^2*exp(-k*x^2) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(17)) } test "line 47: differentiate x^3 - 2*x at 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(18)) } test "line 48: take the derivative of sin(x)*exp(x) at 0.5 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(19)) } test "line 49: differentiate log(1 + x^2) at 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(20)) } test "line 51: differentiate atan(x) at 1 using the symbolic derivative agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(21)) } test "line 52: differentiate erf(x) at 0 using the symbolic derivative agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(22)) } test "line 53: differentiate sqrt(x) at 4 using the symbolic derivative agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(23)) } test "line 54: take the derivative of k*x^3 + sin(x) at 0.5 using the symbolic derivative agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(24)) } test "line 56: solve x^2 = c between 0 and 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(25)) } test "line 57: solve x^2 - 5*x + 6 between 2.5 and 4 using bisection agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(26)) } test "line 58: solve 2*x^2 + 3*x - 2 = 0 starting at 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(27)) } test "line 59: solve x^2 - 2*x + 1 starting at 3 using newton agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(28)) } test "line 61: solve x^3 - 6*x^2 + 11*x - 6 between 2.5 and 3.5 using illinois agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(29)) } test "line 62: solve x^3 - 2*x - 5 between 2 and 3 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(30)) } test "line 63: solve x^3 - 3*x + 1 between 0 and 1 using every method agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(31)) } test "line 65: take the trace of M agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(32)) } test "line 66: take the norm of [3.0, 4.0] agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(33)) } test "line 67: take the dot product of u and v agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(34)) } test "line 68: take the mean of [1.0, 2.0, 4.0] agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(35)) } test "line 69: take the distance between u and v agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(36)) } test "line 71: integrate exp(x^3) from 0 to 1 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(37)) } test "line 72: solve x^5 - x - 1 between 1 and 2 agrees with the CAS, or the CAS has no closed form" { assert_true(cas_check_holds(38)) }