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) -> (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 variable. In FriCAS is assumed to be of type symbol, is assumed to be a variable but variables can be coerced to be a symbol. Only variables can be assigned values but any symbol can "stand for" unknown values in expressions. fricas p[k]
Type: Symbol
fricas 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: Void
fricas 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: BasicOperator?
fricas 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: Void
fricas display(p, fricas Compiling function displayOfp with type List(OutputForm) -> OutputForm
Type: BasicOperator?
fricas 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: Void
fricas evaluate(p, fricas Compiling function evalOfp with type Expression(Integer) -> Expression(Integer)
Type: BasicOperator?
fricas [p 1,
Type: List(Expression(Integer))
fricas product(1+p(k),
Type: Expression(Integer)
likewise for indexing into lists --Christian Sievers, Tue, 23 May 2006 07:02:10 -0500 reply This is related:
fricas l:=[1,
Type: List(PositiveInteger?)
fricas sum(l.(1+2*k), |