I am trying to create formulae for products with, say, p sub k as symbols. These are the results from two, at least naively identical formulae: fricas (1+p[1])*(1+p[2])
Type: Polynomial(Integer)fricas product(1+p[k],
Type: Expression(Integer)But perhaps unexpectedly, the 2nd command is interpreted as just . How could one use "product" (or "sum" for that reason) and an indexed way to denote variables? -------------- In FriCAS fricas product(sin(k),
Type: Expression(Integer)But despite appearances the symbol in in the previous command
is not what FriCAS considers a fricas p[k]
Type: Symbolfricas 1+p[k]
Type: Polynomial(Integer)fricas p[k]:=1 Understanding this distinction is somethimes important to understand why FriCAS does what it does. is assumed to be a polynomial over not . In fact, much more complicated indexed symbols can be created in FriCAS. For example fricas P ==> script(p, Type: Voidfricas reduce(+,
Type: Polynomial(Integer)Within this MathAction FriCAS wiki it is also possible to create symbols that will be displayed as superscripted or subscripted variables which can be assigned values. In fact any LaTeX symbol can be generated by using the underscore charact to "protect" special charactes such as \. For example fricas Q:=p_^_\alpha___\beta
Type: Variable(p^\alpha_\beta)fricas 1+Q
Type: Polynomial(Integer)In the above the first underscore protects the second underscore which is then handled by LaTeX as the beginning of a subscript and next underscore protects the \ which begins a Greek letter, etc. FriCAS treats the entire thing as a long variable name. Note however that this only works here and not within stand alone FriCAS. Probably what you should write is fricas reduce(*,
Type: Polynomial(Integer)Here the operation of 1+p[k] as a polynomial over but the final result is a polynomial. The same comments apply to sum() which represents a Alternatively, and more generally, one can use BasicOperator fricas p:=operator 'p
Type: BasicOperatorfricas p(1)
Type: Expression(Integer)fricas p(k)
Type: Expression(Integer)fricas product(1+p(k),
Type: Expression(Integer)You can attach a display property so that the argument to p appears as a subscript fricas displayOfp(l:List OUTFORM):OUTFORM == subscript('p, Type: Voidfricas display(p, fricas Compiling function displayOfp with type List(OutputForm) -> OutputForm
Type: BasicOperatorfricas product(1+p(k),
Type: Expression(Integer)You can also attach an evaluation property to handle particular values of the argument fricas evalOfp(a:EXPR INT):EXPR INT == {one? a => 1 ; kernel(p, Type: Voidfricas evaluate(p, fricas Compiling function evalOfp with type Expression(Integer) -> Expression(Integer)
Type: BasicOperatorfricas [p 1,
Type: List(Expression(Integer))fricas product(1+p(k),
Type: Expression(Integer)fricas l:=[1,
Type: List(PositiveInteger)fricas sum(l.(1+2*k), |

likewise for indexing into lists--Christian Sievers, Tue, 23 May 2006 07:02:10 -0500 reply