MathNot | built-in logical "not" |
MathAnd | built-in logical "and" |
MathOr | built-in logical "or" |
BitAnd | bitwise and operation |
BitOr | bitwise or operation |
BitXor | bitwise xor operation |
Equals | check equality |
GreaterThan | comparison predicate |
LessThan | comparison predicate |
Math... | arbitrary-precision math functions |
Fast... | double-precision math functions |
ShiftLeft | built-in bitwise shift left operation |
ShiftRight | built-in bitwise shift right operation |
IsPromptShown | test for the Yacas prompt option |
GetTime | measure the time taken by an evaluation |
It is important for a developer to know which functions are built-in and cannot be redefined or Retract-ed. Also, core functions may be somewhat faster to execute than functions defined in the script library. All core functions are listed in the file corefunctions.h in the src/ subdirectory of the Yacas source tree. The declarations typically look like this:
SetCommand(LispSubtract, "MathSubtract"); |
MathNot(expression) |
MathAnd(...) |
MathOr(...) |
MathOr is the basic logical "or" function. Similarly to And, it is lazy-evaluated. And(...) and Or(...) do also exist, defined in the script library. You can redefine them as infix operators yourself, so you have the choice of precedence. In the standard scripts they are in fact declared as infix operators, so you can write expr1 And expr.
BitAnd(n,m) BitOr(n,m) BitXor(n,m) |
Equals(a,b) |
GreaterThan(a,b) LessThan(a,b) |
In> LessThan(1,1) Out> False; In> LessThan("a","b") Out> True; |
MathGcd(n,m) (Greatest Common Divisor) MathAdd(x,y) (add two numbers) MathSubtract(x,y) (subtract two numbers) MathMultiply(x,y) (multiply two numbers) MathDivide(x,y) (divide two numbers) MathSqrt(x) (square root, must be x>=0) MathFloor(x) (largest integer not larger than x) MathCeil(x) (smallest integer not smaller than x) MathAbs(x) (absolute value of x, or |x| ) MathExp(x) (exponential, base 2.718...) MathLog(x) (natural logarithm, for x>0) MathPower(x,y) (power, x ^ y) MathSin(x) (sine) MathCos(x) (cosine) MathTan(x) (tangent) MathSinh(x) (hyperbolic sine) MathCosh(x) (hyperbolic cosine) MathTanh(x) (hyperbolic tangent) MathArcSin(x) (inverse sine) MathArcCos(x) (inverse cosine) MathArcTan(x) (inverse tangent) MathArcSinh(x) (inverse hyperbolic sine) MathArcCosh(x) (inverse hyperbolic cosine) MathArcTanh(x) (inverse hyperbolic tangent) MathDiv(x,y) (integer division, result is an integer) MathMod(x,y) (remainder of division, or x mod y) |
Note that all functions, such as the MathPower, MathSqrt, MathAdd etc., accept integers as well as floating-point numbers. The resulting values may be integers or floats. If the mathematical result is an exact integer, then the integer is returned. For example, MathSqrt(25) returns the integer 5, and MathPower(2,3) returns the integer 8. In such cases, the integer result is returned even if the calculation requires more digits than set by Builtin'Precision'Set. However, when the result is mathematically not an integer, the functions return a floating-point result which is correct only to the current precision.
In> Builtin'Precision'Set(10) Out> True In> Sqrt(10) Out> Sqrt(10) In> MathSqrt(10) Out> 3.16227766 In> MathSqrt(490000*2^150) Out> 26445252304070013196697600 In> MathSqrt(490000*2^150+1) Out> 0.264452523e26 In> MathPower(2,3) Out> 8 In> MathPower(2,-3) Out> 0.125 |
FastLog(x) (natural logarithm), FastPower(x,y), FastArcSin(x)
ShiftLeft(expr,bits) ShiftRight(expr,bits) |
IsPromptShown() |
GetTime(expr) |
The result is the "user time" as reported by the OS, not the real ("wall clock") time. Therefore, any CPU-intensive processes running alongside Yacas will not significantly affect the result of GetTime.
In> GetTime(Simplify((a*b)/(b*a))) Out> 0.09; |