The domain InputForm can be quite useful for manipulating parts of expressions. For example fricas (1) -> ex1:=integrate(log(x)+x,
Type: Union(Expression(Integer),
fricas )set output tex off fricas )set output algebra on Type: InputForm
fricas )set output tex on fricas )set output algebra off
Type: Expression(Integer)
If you would like to do this with a more common type of expression and hide the details, you can define fricas op(n, Type: Void
Then manipulating expressions looks like this: fricas op(1, fricas Compiling function op with type (PositiveInteger,
Type: Expression(Integer)
fricas op(1, fricas Compiling function op with type (PositiveInteger,
Type: Expression(Integer)
fricas (op(1,
Type: Expression(Integer)
Rules and Pattern Matching (from WesterProblemSet)Trigonometric manipulations---these are typically difficult for students fricas r:= cos(3*x)/cos(x)
Type: Expression(Integer)
=> cos(x)^2 - 3 sin(x)^2 or similar fricas real(complexNormalize(r))
Type: Expression(Integer)
=> 2 cos(2 x) - 1 fricas real(normalize(simplify(complexNormalize(r))))
Type: Expression(Integer)
Use rewrite rules => cos(x)^2 - 3 sin(x)^2 fricas sincosAngles:= rule cos((n | integer?(n)) * x) == cos((n - 1)*x) * cos(x) - sin((n - 1)*x) * sin(x) sin((n | integer?(n)) * x) == sin((n - 1)*x) * cos(x) + cos((n - 1)*x) * sin(x)
Type: Ruleset(Integer,
fricas sincosAngles r
Type: Expression(Integer)
Other OperationsThe domain FunctionSpace? includes the following operations: isExpt(p,f:Symbol) returns [x, n] if p = x^n and n <> 0 and x = f(a) isExpt(p,op:BasicOperator) returns [x, n] if p = x^n and n <> 0 and x = op(a) isExpt(p) returns [x, n] if p = x^n and n <> 0 isMult(p) returns [n, x] if p = n * x and n <> 0 isPlus(p) returns [m1,...,mn] if p = m1 +...+ mn and n > 1 isPower(p) returns [x, n] if p = x^n and n <> 0 isTimes(p) returns [a1,...,an] if p = a1*...*an and n > 1 If these conditions are not met, then the above operations return "failed". For example, fricas isMult(3*x)
Type: Union(Record(coef: Integer,
but fricas isMult(x*y)
Type: Union("failed",
In the context of Not exactly analogously fricas isPower(x^y)
Type: Union(Record(val: Expression(Integer),
whereas fricas isPower(x^10)
Type: Union(Record(val: Expression(Integer),
In the first case the We have: fricas isTimes(x*y*z)
Type: Union(List(Polynomial(Integer)),
fricas isPlus(x+y+z*y)
Type: Union(List(Polynomial(Integer)),
Whereas fricas isTimes((x+y)*z)
Type: Union("failed",
That is because the expression is internally treated as a
fricas ((x+y)*z)::MPOLY([x,
If you say: fricas isPlus((x+y)*z)
Type: Union(List(Polynomial(Integer)),
perhaps the result makes sense? For some of the details of these operations I consulted the actual algebra code at: http://axiom-wiki.newsynthesis.org/axiom--test--1/src/algebra/FspaceSpad Click on You can also enter expressions like |