*Mathematical Theorems - Boundary Value Problems and Approximations*

```
coef(n,k,o):=
/*Usage: coef(n,k,o); */
/*n: Grade of the polynomial or number that it is elevated to. */
/*k: k-th binomial term. */
/*o: Simplifying option, o = 0 yields numeric value of the calculated coefficient, */
/* with any other value, it expands the summations sequences. */
block( [x,s],
       simp:true,
       chr_(x):= concat(smake(floor(x/19),"z"),ascii(mod(x,19)+104)),
       x_:"k",
       s: [1],
       if o = 0
          then option:true
          else option:false,
       if not integerp(n) or not integerp(k)
          then return("'n' and 'k' must be integers ..."),
       if k < 0 or n < 0
          then return(0),
       if k = 0
          then (simp:option, return
       (eval_string(sconcat("sum([1],i,1,",1,")")))),
       for idx:1 thru k do
       (
          if idx = k
          then
          (
                 s:sconcat("sum"," (",s, ",",chr_(idx),",",1,",",n-k+1,")")
          )
          else
          (
                 s:sconcat("sum",",(",s,",",chr_(idx),",",1,",",chr_(idx+1),")")
          )
       ),
       simp:option,
       eval_string(s)
     );
```
#### **Figure 2.** *Program: coef.*

```
multinom(s,n,o):=
/*Usage: multinom(s,n,o); */
/*s: Amount of summands that has the polynomial, i.e., s=2 is about a binomial. */
/*n: Grade of the polynomial or number that it is elevated to. */
/*o: Simplifying option, o = 0 yields numeric value of the calculated coefficient, */
/* with any other value, it expands the sequences of the individual terms. */
block([multsum],
      simp:true,
      if o = 0
          then opt:0
          else opt:1,
      _chr_(x):=
      block( [],
             if x = 0
                 then return(n)
                 else return(concat("_",smake(floor(x/18),"z"),ascii(mod(x,18)+104))
                      )
      ),
      multsum:sconcat(x[s],"^",indx_3),
      expr:"x [1]",
      for sx:1 thru s-1 do
      (
             expr:concat("(",expr,"+",x,"[",sx+1,"]",")"),
             indx:_chr_(s-sx),
             indx_1:_chr_(s-(sx+1)),
             indx_3:_chr_(s-1),
             multsum:sconcat("sum","(","cooe__","(",indx_1,",",indx,",",opt,")","*",
             x[s-sx],"^","(",indx_1,"-",indx,")","*",
             multsum,",",indx,",",0,",",indx_1,")")
      ),
      print(eval_string(expr)^n,"="),
      CMD_:eval_string(multsum),
      return(expand(ev(CMD_,cooe__=coef)))
   );
```
The implemented algorithms (1, 2) were presented above in the code displayed in **Figures 2** and **3**, for the first and the second one, respectively. To use the code, open a Maxima instance; then for the foremost part, in order to avoid LISP errors,

*Output of multinom.mc for a binomial and a multinomial example, respectively (in electronic PDF file, this*

*Alternative Representation for Binomials and Multinomies and Coefficient Calculation*

Next save the code above as the files *coef.mc* and *multinom.mc*, respectively, and place them in the subdirectory user of the Maxima installation (< maxima\_userdir can be issued; > in the command line to display it). Following, issue the commands:

in order to be both loaded; or alternatively just copy the text from **Figures 2** and **3**, and paste it in the Maxima interface. Then use them according to each program

A pattern of outputs (binomial coefficient values) from *coef.mc* was included;

With this result an alternative way to represent binomials and multinomies alongside their respective coefficient calculations was exposed. The results obtained from [2] were extended by broading formula (1) to the multinomial instances, by showing that those results can be applied suitably to the theoretical cases of study and by the building up of two algorithms which were implemented in two programs in the CAS Maxima. What will be remaining for a subsequent research work will be

issue the following command:

*figure can be zoomed fairly enough for a better view).*

*DOI: http://dx.doi.org/10.5772/intechopen.91422*

**Figure 4.**

batch("coef"); batch("multinom");

this is displayed in Appendix B.

**4. Conclusions**

**109**

:lisp (setf(get '%sum 'operators) nil)

syntax. The program *multinom.mc* outputs are shown in **Figure 4**.

#### **Figure 3.** *Program: multinom.*

*Alternative Representation for Binomials and Multinomies and Coefficient Calculation DOI: http://dx.doi.org/10.5772/intechopen.91422*

#### **Figure 4.**

coef(n,k,o):=

block( [x,s],

/\*Usage: coef(n,k,o); \*/

simp:true,

then option:true else option:false,

if k < 0 or n < 0 then return(0),

for idx:1 thru k do

if idx = k then (

if not integerp(n) or not integerp(k)

then (simp:option, return

x\_:"k", s: [1], if o = 0

if k = 0

) else (

) ),

);

multinom(s,n,o):=

block([multsum], simp:true, if o = 0 then opt:0 else opt:1, \_chr\_(x):= block( [],

),

(

),

);

**Figure 3.** *Program: multinom.*

**108**

**Figure 2.** *Program: coef.*

simp:option, eval\_string(s)

/\*Usage: multinom(s,n,o); \*/

if x = 0

expr:"x [1]", for sx:1 thru s-1 do

then return(n)

multsum:sconcat(x[s],"^",indx\_3),

)

indx:\_chr\_(s-sx), indx\_1:\_chr\_(s-(sx+1)), indx\_3:\_chr\_(s-1),

print(eval\_string(expr)^n,"="), CMD\_:eval\_string(multsum),

return(expand(ev(CMD\_,cooe\_\_=coef)))

(

/\*k: k-th binomial term. \*/

/\*n: Grade of the polynomial or number that it is elevated to. \*/

/\* with any other value, it expands the summations sequences. \*/

then return("'n' and 'k' must be integers ..."),

(eval\_string(sconcat("sum([1],i,1,",1,")")))),

/\*o: Simplifying option, o = 0 yields numeric value of the calculated coefficient, \*/

s:sconcat("sum"," (",s, ",",chr\_(idx),",",1,",",n-k+1,")")

/\*s: Amount of summands that has the polynomial, i.e., s=2 is about a binomial. \*/

expr:concat("(",expr,"+",x,"[",sx+1,"]",")"),

x[s-sx],"^","(",indx\_1,"-",indx,")","\*", multsum,",",indx,",",0,",",indx\_1,")")

/\*o: Simplifying option, o = 0 yields numeric value of the calculated coefficient, \*/ /\* with any other value, it expands the sequences of the individual terms. \*/

/\*n: Grade of the polynomial or number that it is elevated to. \*/

s:sconcat("sum",",(",s,",",chr\_(idx),",",1,",",chr\_(idx+1),")")

else return(concat("\_",smake(floor(x/18),"z"),ascii(mod(x,18)+104))

multsum:sconcat("sum","(","cooe\_\_","(",indx\_1,",",indx,",",opt,")","\*",

chr\_(x):= concat(smake(floor(x/19),"z"),ascii(mod(x,19)+104)),

*Mathematical Theorems - Boundary Value Problems and Approximations*

*Output of multinom.mc for a binomial and a multinomial example, respectively (in electronic PDF file, this figure can be zoomed fairly enough for a better view).*

The implemented algorithms (1, 2) were presented above in the code displayed in **Figures 2** and **3**, for the first and the second one, respectively. To use the code, open a Maxima instance; then for the foremost part, in order to avoid LISP errors, issue the following command:

:lisp (setf(get '%sum 'operators) nil)

Next save the code above as the files *coef.mc* and *multinom.mc*, respectively, and place them in the subdirectory user of the Maxima installation (< maxima\_userdir can be issued; > in the command line to display it). Following, issue the commands:

```
batch("coef");
```

```
batch("multinom");
```
in order to be both loaded; or alternatively just copy the text from **Figures 2** and **3**, and paste it in the Maxima interface. Then use them according to each program syntax. The program *multinom.mc* outputs are shown in **Figure 4**.

A pattern of outputs (binomial coefficient values) from *coef.mc* was included; this is displayed in Appendix B.
