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 |
Yacas comes with a test suite which can be found in the directory tests/. Typing
make test |
The verification commands described in this chapter only display the expressions that do not evaluate correctly. Errors do not terminate the execution of the Yacas script that uses these testing commands, 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 some calculations, the demand that two expressions are identical 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 problem 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 developers when they have no time to fix the defect, but do not 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(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 results should be exactly equal.
RandVerifyArithmetic(n) calls VerifyArithmetic with random values, n times.
VerifyDiv(u,v) 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; |