MathNot , MathAnd , MathOr , BitAnd, BitOr, BitXor , Equals , GreaterThan, LessThan , Math... , Fast... , ShiftLeft, ShiftRight , IsPromptShown , MathLibrary , GetTime .

# Built-in (core) functions

Yacas comes with a small core of built-in functions and a large library of user-defined functions. Some of these core functions are documented in this chapter.

MathNot | built-in logical "not"
MathAnd | built-in logical "and"
MathOr | built-in logical "or"
BitAnd, BitOr, BitXor | bitwise arithmetic
Equals | check equality
GreaterThan, LessThan | comparison predicates
Math... | arbitrary-precision math functions
Fast... | double-precision math functions
ShiftLeft, ShiftRight | built-in bit shifts
IsPromptShown | test for the Yacas prompt option
MathLibrary | obtain current math library name
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 `yacasapi.cpp` in the `src/` subdirectory of the Yacas source tree. The declarations typically look like this:

    SetCommand(LispSubtract, "MathSubtract");

Here `LispSubtract` is the Yacas internal name for the function and `MathSubtract` is the name visible to the Yacas language. Built-in bodied functions and infix operators are declared in the same file.

###

MathNot -- built-in logical "not"

##### Internal function

##### Calling format:

    MathNot(expression)

##### Description:

Returns "False" if "expression" evaluates to "True", and vice versa.

###

MathAnd -- built-in logical "and"

##### Calling format:

    MathAnd(...)

##### Description:

Lazy logical `And`: returns `True` if all args evaluate to `True`, and does this by looking at first, and then at the second argument, until one is `False`. If one of the arguments is `False`, `And` immediately returns `False` without evaluating the rest. This is faster, but also means that none of the arguments should cause side effects when they are evaluated.

###

MathOr -- built-in logical "or"

##### Internal function

##### Calling format:

    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, BitOr, BitXor -- bitwise arithmetic

##### Internal function

##### Calling format:

    BitAnd(n,m)
    BitOr(n,m)
    BitXor(n,m)

##### Description:

These functions return bitwise "and", "or" and "xor" of two numbers.

###

Equals -- check equality

##### Internal function

##### Calling format:

    Equals(a,b)

##### Description:

Compares evaluated `a` and `b` recursively (stepping into expressions). So "Equals(a,b)" returns "True" if the expressions would be printed exactly the same, and "False" otherwise.

###

GreaterThan, LessThan -- comparison predicates

##### Internal function

##### Calling format:

    LessThan(a,b), GreaterThan(a,b)

##### Parameters:

`a`, `b` -- numbers or strings

##### Description:

Comparing numbers or strings (lexicographically).

##### Example:

    In> LessThan(1,1)
    Out> False;
    In> LessThan("a","b")
    Out> True;

###

Math... -- arbitrary-precision math functions

##### Internal function

##### Calling format:

MathGcd(n,m) (Greatest Common Divisor), MathAdd(x,y), MathSubtract(x,y), MathMultiply(x,y), MathDivide(x,y), MathSqrt(x) (square root), MathFloor(x), MathCeil(x), MathAbs(x), MathExp(x), MathLog(x) (natural logarithm), MathPower(x,y), MathSin(x), MathCos(x), MathTan(x), MathArcSin(x), MathArcCos(x), MathArcTan(x), MathDiv(x,y), MathMod(x,y)

##### Description:

Calculation of sin, cos, tan and other mathematical functions. The argument must be a number. The reason for the prefix `Math` is that the library needs to define equivalent non-numerical functions for symbolic computations, such as `Exp`, `Sin` and so on.

###

Fast... -- double-precision math functions

##### Internal function

##### Calling format:

FastExp(x), FastLog(x) (natural logarithm), FastPower(x,y), FastSin(x), FastCos(x), FastTan(x), FastArcSin(x), FastArcCos(x), FastArcTan(x)

##### Description:

Versions of these functions using the C++ library. These should then at least be faster than the arbitrary precision versions.

###

ShiftLeft, ShiftRight -- built-in bit shifts

##### Internal function

##### Calling format:

    ShiftLeft(expr,bits)
    ShiftRight(expr,bits)

##### Description:

Shift bits to the left or to the right.

###

IsPromptShown -- test for the Yacas prompt option

##### Internal function

##### Calling format:

    IsPromptShown()

##### Description:

Returns `False` if Yacas has been started with the option to suppress the prompt, and `True` otherwise.

###

MathLibrary -- obtain current math library name

##### Internal function

##### Calling format:

    MathLibrary()

##### Description:

Returns a string that describes the currently used arbitrary-precision arithmetic library name.

Possible names are `"Internal"` and `"Gmp"`, indicating the internal math library `libyacasnumbers` and the GNU Multiple Precision library `libgmp`.

##### Example:

    In>  MathLibrary()
    Out> "Internal";

###

GetTime -- measure the time taken by an evaluation

##### Internal function

##### Calling format:

    GetTime(expr)

##### Parameters:

`expr` -- any expression

##### Description:

The function `GetTime(expr)` evaluates the expression `expr` and returns the time needed for the evaluation. The result is returned as a floating-point number of seconds. The value of the expression `expr` is lost.

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`.

##### Example:

    In> GetTime(Simplify((a*b)/(b*a)))
    Out> 0.09;

##### See also:

Time .

##

Full listing of core functions

The following Yacas functions are currently declared in `yacasapi.cpp` as core functions:

    =
    And
    ApplyPure
    ArrayCreate
    ArrayGet
    ArraySet
    ArraySize
    Atom
    Berlekamp
    BitAnd
    BitOr
    BitXor
    Bodied
    CTokenizer
    Check
    Clear
    CommonLispTokenizer
    Concat
    ConcatStrings
    CurrentFile
    CurrentLine
    CustomEval
    CustomEval'Expression
    CustomEval'Locals
    CustomEval'Result
    CustomEval'Stop
    DefLoad
    DefLoadFunction
    DefMacroRuleBase
    DefMacroRuleBaseListed
    DefaultDirectory
    DefaultTokenizer
    Delete
    DestructiveDelete
    DestructiveInsert
    DestructiveReplace
    DestructiveReverse
    DllEnumerate
    DllLoad
    DllUnload
    Equals
    Eval
    FastArcCos
    FastArcSin
    FastArcTan
    FastAssoc
    FastCos
    FastExp
    FastIsPrime
    FastLog
    FastPower
    FastSin
    FastTan
    FindFile
    FindFunction
    FlatCopy
    FromBase
    FromFile
    FromString
    FullForm
    GarbageCollect
    GenericTypeName
    GetExtraInfo
    GetPrecision
    GreaterThan
    Head
    Hold
    HoldArg
    If
    Infix
    Insert
    IsAtom
    IsBodied
    IsBound
    IsFunction
    IsGeneric
    IsInfix
    IsInteger
    IsList
    IsNumber
    IsPostfix
    IsPrefix
    IsString
    LazyGlobal
    LeftPrecedence
    Length
    LessThan
    LispRead
    LispReadListed
    List
    Listify
    Load
    Local
    LocalSymbols
    MacroClear
    MacroLocal
    MacroRule
    MacroRuleBase
    MacroRuleBaseListed
    MacroRulePattern
    MacroSet
    MathAbs
    MathAdd
    MathAnd
    MathArcCos
    MathArcSin
    MathArcTan
    MathCeil
    MathCos
    MathDiv
    MathDivide
    MathExp
    MathFac
    MathFloor
    MathGcd
    MathGetExactBits
    MathLibrary
    MathLog
    MathMod
    MathMultiply
    MathNot
    MathNth
    MathOr
    MathPi
    MathPower
    MathSetExactBits
    MathSin
    MathSqrt
    MathSubtract
    MathTan
    MaxEvalDepth
    Not
    OpLeftPrecedence
    OpPrecedence
    OpRightPrecedence
    Or
    PatchLoad
    PatchString
    PatternCreate
    PatternMatches
    Postfix
    Precision
    Prefix
    PrettyPrinter
    Prog
    Read
    ReadToken
    Replace
    Retract
    RightAssociative
    RightPrecedence
    Rule
    RuleBase
    RuleBaseArgList
    RuleBaseDefined
    RuleBaseListed
    RulePattern
    Secure
    Set
    SetExtraInfo
    SetStringMid
    ShiftLeft
    ShiftRight
    String
    StringMid
    Subst
    SystemCall
    Tail
    ToBase
    ToFile
    ToString
    TraceRule
    TraceStack
    Type
    UnFence
    UnList
    Use
    Version
    While
    Write
    WriteString
    XmlExplodeTag
    XmlTokenizer
    `

In addition, the following functions are declared with special syntax and precedence:

`@` --- prefix (prec. `0`).

`BackQuote` --- bodied (prec. `KMaxPrecedence`).

`FromFile` --- bodied (prec. `KMaxPrecedence`).

`FromString` --- bodied (prec. `KMaxPrecedence`).

`LocalSymbols` --- bodied (prec. `KMaxPrecedence`).

`MacroRule` --- bodied (prec. `KMaxPrecedence`).

`MacroRulePattern` --- bodied (prec. `KMaxPrecedence`).

`Rule` --- bodied (prec. `KMaxPrecedence`).

`RulePattern` --- bodied (prec. `KMaxPrecedence`).

`Subst` --- bodied (prec. `KMaxPrecedence`).

`ToFile` --- bodied (prec. `KMaxPrecedence`).

`ToString` --- bodied (prec. `KMaxPrecedence`).

`TraceRule` --- bodied (prec. `KMaxPrecedence`).

`While` --- bodied (prec. `KMaxPrecedence`).

`_` --- prefix (prec. `0`).

`_` --- infix (prec. `0`).

``` --- prefix (prec. `0`).