Combining numeric and symbolic computation
I'm a new Mathcad user. I'm trying to do something that's intuitively simple on paper, but potentially very tricky for a computer program (so tricky, in fact, that I'm not sure how to explain it in rigorous terms; thus the long post). Please tell me if there's a straightforward way to do this.
From a high-level point of view, I can say that I want my program to "know" both the symbolic value and the numerical value of my expression at the same time. Let me define the fictitious operators 's=' for symbolic evaluation and 'n=' for numerical evaluation. Let the assignment operator be ':=', same as in Mathcad. Equipped with these fictitious operators, I could say:
a := b^2 - 1
b := c + 2
c := 5
a s= (c + 2)^2 - 1
a n= 48
From a slightly lower-level point of view, I can say that I want to be able to "hold" or "delay" substitution of numerical values into my expressions. Let me define a different set of fictitious operators:
- ':=' - regular assignment, like we all know
- 'd:=' - delayed assignment
- '=' - full evaluation (evaluates both regular and delayed assignments)
- 'd=' - delayed evaluation (or "weak", if you will; evaluates regular assignments only)
The same example from above, recast in these terms, might look like:
a := b^2 - 1
b := c + 2
c d:= 5
a d= (c + 2)^2 - 1
a = 48
Background information (with more specific examples)
I'm coming at this from a Mathematica background. Mathematica allows symbolic manipulation with variables that haven't been defined. A purely numerical version of my example calculation might look like this (using ':=' for assignment and '->' for evaluation, which isn't quite the way Mathematica works):
a := b^2 - 1
b := c + 2
a -> (c + 2)^2 - 1
c := 5
a -> 48
This much is easy in Mathcad. The trouble is that once I've defined a value for 'c', I can no longer recall the expression on the third line in symbolic form. But Mathematica has an additional wrinkle in that it allows variables to have numerical values that are suppressed in symbolic manipulations. It all works using the function/operator 'N'. The same calculation in combined numeric-symbolic form would look like this:
a := b^2 - 1
b := c + 2
N(c) := 5
a -> (c + 2)^2 - 1
N(a) -> 48
Both the values of 'a' and 'N(a)' exist simultaneously in the workspace. By assigning a value to 'N(c)', I haven't lost the symbolic expression for 'a'.
(Syntax sticklers unfamiliar with Mathematica: the operator 'N' is overloaded. When it appears on the left-hand side of an assignment, it modifies the assignment. When it appears in an expression, it modifies the evaluation.)

