evaluationmaxima# How to force maxima to evaluate a sum? (Evaluation Logic)

```
(%i1) load("distrib");
(%o1) "/opt/homebrew/Cellar/maxima/5.46.0_11/share/maxima/5.46.0/share/distrib/distrib.mac"
(%i2) T1: sum( pdf_binomial(si,SM,p) * p^2 , si, 0, SM ) $
(%i3) float(ev(T1, [SM=7,p=0.3]));
(%o3) sum(binomial(7.0,si)*0.7^(7-si)*0.3^(si+2),si,0.0,7.0)
(%i6) SM:7 $ float(ev(T1, [p=0.3])); kill(SM) $
(%o5) sum(binomial(7.0,si)*0.7^(7-si)*0.3^(si+2),si,0.0,7.0)
(%i9) SM: 7 $ T2: sum( pdf_binomial(si,SM,p) * p^2 , si, 0, SM ) $
ev(T2, [p=0.3]);
(%o9) 0.08999999999999997
```

if I define SM before I define the expression (T2), it "works" (evaluates to a number). However, maxima no longer gives numerical values if SM is defined after T1 is defined. Not shown, if I define T2 as T1 (`T2: T1`

), I believe maxima internally stores the symbol T1 into T2, not the expression that is in T1, and this again does not evaluate. it's somehow about context. all ok --- I just need to know how to force evaluation when I need to.

advice appreciated.

Solution

Maxima represents partially-evaluated expressions as so-called noun expressions. Many mathematical functions return noun expressions when the arguments aren't specific enough to permit complete evaluations. `sum`

, `integrate`

, `diff`

, `limit`

, etc. return noun expressions; programming functions such as `length`

, `first`

, `op`

, etc., complain with an error message if arguments aren't specific enough.

Nouns can be "verbified" via `ev(expr, nouns)`

. You can also nounify just one operator (if there's more than one nounified expression present) by saying the name of the operator, e.g. `ev(expr, sum)`

to verbify just `sum`

. In this case, the appropriate incantation is:

```
ev(T2, SM = 7, p = 0.3, nouns);
```

You can explicitly construct a noun expression via the single quote `'`

applied to an operator, e.g. `'integrate(sin(x), x)`

.

- KMeans evaluation metric not converging. Is this normal behavior or no?
- Proper way to evaluate code
- Does Python's `all` function use short circuit evaluation?
- Formula evaluation returns weird value
- Why is bash evaluating my variable with an unwanted `'` inserted in it?
- What is "Call By Name"?
- How to use torcheval.metrics.FrechetInceptionDistance in pytorch for mnist dataset?
- How to use `sprintf()` in LHS during assignment
- Why do we have to reverse the string when converting from infix to prefix
- How to programmatically implement flexibility to either apply a column or use a single color to fill argument in ggplot
- cocoeval change the number of keypoints and self.kpt_oks_sigmas into 14 but receive error
- Deferred evaluation of github.com/rs/zerolog Fields
- Forcing evaluation order of `std::pair` constructors; a progress bar `struct` for a for-loop
- What's the explanation for Exercise 1.6 in SICP?
- How to pass a Dataframe as train dataframe and another dataframe as Validation to GridSearchCV
- Graphing function from string doesn't evaluate correctly at 0
- How to plot a math function from a string
- Why normal-order and applicative-order evaluation are not giving the same value?
- Is it possible to use evaluation metrics (like NDCG) as a loss function?
- F1-Score and Accuracy for Text-Similarity
- Javascript parser for simple expression
- Using metatables for adding two different types
- What is the trade-off between Lazy and Strict/Eager evaluation?
- How Expression.Evaluate works?
- Expressions in my template literal don't get updated
- In the ROUGE metrics, what do the low, mid and high values mean?
- What is call-by-need?
- Turn string into operator
- How to resolve Error in seqeval in NER bert finetuning?
- How to force maxima to evaluate a sum? (Evaluation Logic)