|
|
last edited 10 years ago by test1 |
1 2 3 4 5 6 | ||
Editor: test1
Time: 2014/10/07 13:07:50 GMT+0 |
||
Note: |
changed: - 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 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 changed: - isPower(p) returns [x, n] if p = x**n and n <> 0 isPower(p) returns [x, n] if p = x^n and n <> 0 changed: -isPower(x**y) isPower(x^y) changed: -isPower(x**10) isPower(x^10)
The domain InputForm can be quite useful for manipulating parts of expressions. For example
(1) -> ex1:=integrate(log(x)+x,x)
(1) |
)set output tex off
)set output algebra on
%::InputForm
(2) (/ (+ (* (* 2 x) (log x)) (+ (^ x 2) (* - 2 x))) 2)
)set output tex on
)set output algebra off
ex2:=interpret((%::InputForm).2.2)
(2) |
If you would like to do this with a more common type of expression and hide the details, you can define
op(n,x) == interpret((x::InputForm).(n+1))
Then manipulating expressions looks like this:
op(1,ex1)
Compiling function op with type (PositiveInteger,Expression(Integer )) -> Any
(3) |
op(1,%)
Compiling function op with type (PositiveInteger,Any) -> Any
(4) |
(op(1,op(1, ex1))-op(2, op(1, ex1)))/op(2, ex1)
(5) |
Trigonometric manipulations---these are typically difficult for students
r:= cos(3*x)/cos(x)
(6) |
=> cos(x)^2 - 3 sin(x)^2 or similar
real(complexNormalize(r))
(7) |
=> 2 cos(2 x) - 1
real(normalize(simplify(complexNormalize(r))))
(8) |
Use rewrite rules => cos(x)^2 - 3 sin(x)^2
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)
(9) |
sincosAngles r
(10) |
The 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,
isMult(3*x)
(11) |
but
isMult(x*y)
(12) |
In the context of Expression Integer
, or Polynomial Integer
the parameter n must be an Integer. The Symbol y
is not an
Integer
.
Not exactly analogously
isPower(x^y)
(13) |
whereas
isPower(x^10)
(14) |
In the first case the Integer
is assume to be 1.
We have:
isTimes(x*y*z)
(15) |
isPlus(x+y+z*y)
(16) |
Whereas
isTimes((x+y)*z)
(17) |
That is because the expression is internally treated as a
MultivariatePolynomial
like this:
((x+y)*z)::MPOLY([x,y, z], INT)
(18) |
If you say:
isPlus((x+y)*z)
(19) |
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 pdf
or dvi
to see the documentation.
You can also enter expressions like isTimes
in the search box
on the upper right and see all the places in the algebra where
this operation is defined and used.