Implementation Details
----------------------
Both [eval] and [until] process expressions using the same four steps:

    [parse] the source vector to produce a parse-tree,
    [evaluate] any constant subnodes in the tree, for example: (1+2),
    [reduce] the tree using reduction rules defined in the source vector.
    [show] the result: a number or a reduced expression tree.

→reduce← is particularly important for →Differentiation←.  Compare the following
results,  with and without reduction (reduction lines were commented out for the
second case):

    load math

With reduction:

    eval'(1/x)∆x∆x∆x'       ⍝ third differential of 1/x.
-6*x∧-4

Without reduction:

    eval'(1/x)∆x∆x∆x'       ⍝ third differential of 1/x.
0/x-0/x∧2-(0/x∧2-0*(2*x∧1+0*ln(x)*x∧2)/(x∧2)∧2)-(0/x∧2-0*(2*x∧1+0*ln(x)*x∧2)/(x∧
      2)∧2-((0*(2*x∧1+0*ln(x)*x∧2)+1*(0*x∧1+2*(1*x∧0+0*ln(x)*x∧1)+((0*ln(x)+0*(1
      /x))*x∧2+0*ln(x)*(2*x∧1+0*ln(x)*x∧2))))/(x∧2)∧2-1*(2*x∧1+0*ln(x)*x∧2)*((2*
      x∧1+0*ln(x)*x∧2)*2*(x∧2)∧1+0*ln(x∧2)*(x∧2)∧2)/((x∧2)∧2)∧2))

Workspace map
¯¯¯¯¯¯¯¯¯¯¯¯¯
#
·   ~ bta math roman sba soroban std tasman
·   ∇ eval load test until
·   ∘ script trace
·   aux
·   ·   ∇ pcomp
·   exp
·   ·   ~ defns pchks pvars rules
·   ·   ∇ evalexp evaluate parse reduce show strip
·   notes
·   ·   ~ ··· Contents ···

Funtion calling structure
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

      eval─────┬───────.───────┐
               │               │
            ┌─exp─────────────────────────────────┐
            │                  │                  │
            │              ┌───┴────┐             │
            │              │evalexp │             │
            │              └───┬────┘             │
            │       ┌──────────┼────────────┐     │
      numb──←─┐   ┌────┐   ┌────────┐   ┌─────┐   │
            │ ├─←─┤show├─←─┤evaluate├─←─┤parse├───←──expr
      expr──←─┘   └────┘   └─┬────┬─┘   └─────┘   │
            │       └───┬────↓─┴──↑─────────┘     │
            │           │  ┌─┴────┴─┐             │
            │           │  │ reduce │             │
            │           │  └────────┘             │
            │           │      │                  │
            │         defns  rules                │
            │           │      │                  │
            └─────────────────────────────────────┘
                        │      │
      load──────────────┴──────┘

Key:

    [eval] is [exp].[evalexp]

    [load] compiles its text argument to produce [defns], a 4-vector of:

        binding strengths       0 1 2 3 ···
        association orders      ← → ↑
        function name/symbols   + - * / ··· ceiling floor ···
        function code           + = × ÷ ··· {···}   {···} ···

    and [rules], reduction rules pattern trees.

    [evalexp] calls:

        [parse]:  takes  a character vector expression and refers to [defns] for
        function  definitions  to produce an expression tree. Each function node
        in  the  tree  is  marked with its position in the expression vector, in
        order to place an error marker if things go wrong.

        [evaluate] to evaluate constant (sub)-expressions.

        [reduce] to reduce symbolic expressions, using [rules].

        [show] to format an expression tree result.

See also: →parse←
          →reduce←
          →Long_division←
          →Expression_simplification←
Back to:  →Contents