Verify, TestYacas, LogicVerify | Verifying equivalence of two expressions |
KnownFailure | Mark a test as a known failure |
RoundTo | Round a real-valued result to a set number of digits |
VerifyArithmetic, VerifyDiv | Special purpose arithmetic verifiers |
make test |
on the command line after Yacas was built will run the test. This test can be run even before make install, as it only uses files in the local directory of the Yacas source tree. The default extension for test scripts is .yts, (Yacas test script).
The verification commands described in this chapter only display the expressions that don't match. They don't terminate the current execution, and they don't return a value representing success and failure, since they are meant to be used in test scripts.
Verify(question,answer) TestYacas(question,answer) LogicVerify(question,answer) |
answer - expected result after evaluation
For most calculations, the demand that two expressions are equal syntactically is too stringent. The Yacas system might change at various places in the future, but 1+x would still be equivalent, from a mathematical point of view, to x+1.
The general problem of deciding that two expressions a and b are equivalent, which is the same as saying that a-b=0 , is generally hard to decide on. The following commands solve this by having domain-specific comparisons.
The comparison commands do the following comparison types:
In> Verify(1+2,3) Out> True; In> Verify(x*(1+x),x^2+x) ****************** x*(x+1) evaluates to x*(x+1) which differs from x^2+x ****************** Out> False; In> TestYacas(x*(1+x),x^2+x) Out> True; In> Verify(a And c Or b And Not c,a Or b) ****************** a And c Or b And Not c evaluates to a And c Or b And Not c which differs from a Or b ****************** Out> False; In> LogicVerify(a And c Or b And Not c,a Or b) Out> True; In> LogicVerify(a And c Or b And Not c,b Or a) Out> True; |
KnownFailure(test) |
This might be used by a developer when he doesn't have time to fix the defect, but doesn't wish to alarm users who download Yacas and type make test.
In> KnownFailure(Verify(1,2)) Known failure: ****************** 1 evaluates to 1 which differs from 2 ****************** Out> False; In> KnownFailure(Verify(1,1)) Known failure: Failure resolved! Out> True; |
RoundTo(number,precision) |
precision - precision to use for round-off
In> N(RoundTo(Exp(1),30),30) Out> 2.71828182110230114951959786552; In> N(RoundTo(Exp(1),20),20) Out> 2.71828182796964237096; |
VerifyArithmetic VerifyDiv |
VerifyArithmetic(x,n,m) RandVerifyArithmetic(n) VerifyDiv(u,v) |
VerifyArithmetic verifies for an arbitrary set of numbers x, n and m that
The left and right side represent two ways to arrive at the same result, and so an arithmetic module actually doing the calculation does the calculation in two different ways. The result should be exactly equal.
RandVerifyArithmetic calls VerifyArithmetic n times, with random values.
VerifyDiv checks that
In> VerifyArithmetic(100,50,60) Out> True; In> RandVerifyArithmetic(4) Out> True; In> VerifyDiv(x^2+2*x+3,x+1) Out> True; In> VerifyDiv(3,2) Out> True; |