|
|
|
last edited 12 years ago by test1 |
| 1 2 3 4 5 6 | ||
|
Editor: Bill Page
Time: 2008/08/21 07:40:59 GMT-7 |
||
| Note: rewrite rules | ||
removed: - added: Rules and Pattern Matching (from WesterProblemSet) Trigonometric manipulations---these are typically difficult for students \begin{axiom} r:= cos(3*x)/cos(x) \end{axiom} => cos(x)^2 - 3 sin(x)^2 or similar \begin{axiom} real(complexNormalize(r)) \end{axiom} => 2 cos(2 x) - 1 \begin{axiom} real(normalize(simplify(complexNormalize(r)))) \end{axiom} Use rewrite rules => cos(x)^2 - 3 sin(x)^2 \begin{axiom} 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) ) \end{axiom} \begin{axiom} sincosAngles r \end{axiom}
The domain InputForm can be quite useful for manipulating parts of expressions. For examplefricas(1) -> ex1:=integrate(log(x)+x,\begin{equation} \label{eq1}\frac{{2 \ x \ {\log \left({x}\right)}}+{{x}^{2}}-{2 \ x}}{2}\end{equation}x) Type: Union(Expression(Integer),...) fricas%::InputForm\begin{equation} \label{eq2}\left(/ \ {\left(+ \ {\left( \ {\left( \ 2 \ x \right)}\ {\left(\log \ x \right)}\right)}\ {\left(+ \ {\left(^\ x \ 2 \right)}\ {\left( \ - 2 \ x \right)}\right)}\right)}\ 2 \right)\end{equation*}Type: InputForm?fricasex2:=interpret((%::InputForm).2.2)\begin{equation} \label{eq3}2 \ x \ {\log \left({x}\right)}\end{equation}Type: Expression(Integer)If you would like to do this with a more common type of expression and hide the details, you can define
fricasop(n,x) == interpret((x::InputForm).(n+1)) Type: VoidThen manipulating expressions looks like this:
fricasop(1,ex1) \begin{equation} \label{eq4}{2 \ x \ {\log \left({x}\right)}}+{{x}^{2}}-{2 \ x}\end{equation}fricasCompiling function op with type (PositiveInteger,Expression(Integer )) -> Any Type: Expression(Integer)fricasop(1,%) \begin{equation} \label{eq5}2 \ x \ {\log \left({x}\right)}\end{equation}fricasCompiling function op with type (PositiveInteger,Any) -> Any Type: Expression(Integer)fricas(op(1,\begin{equation} \label{eq6}\frac{{2 \ x \ {\log \left({x}\right)}}-{{x}^{2}}+{2 \ x}}{2}\end{equation}op(1, ex1))-op(2, op(1, ex1)))/op(2, ex1) Type: Expression(Integer)Rules and Pattern Matching (from WesterProblemSet?)
Trigonometric manipulations---these are typically difficult for students
fricasr:= cos(3*x)/cos(x)\begin{equation} \label{eq7}\frac{\cos \left({3 \ x}\right)}{\cos \left({x}\right)}\end{equation}Type: Expression(Integer)=> cos(x)^2 - 3 sin(x)^2 or similar
fricasreal(complexNormalize(r))\begin{equation} \label{eq8}-{2 \ {{\sin \left({x}\right)}^{2}}}+{2 \ {{\cos \left({x}\right)}^{2}}}- 1\end{equation}Type: Expression(Integer)=> 2 cos(2 x) - 1
fricasreal(normalize(simplify(complexNormalize(r))))\begin{equation} \label{eq9}{2 \ {\cos \left({2 \ x}\right)}}- 1\end{equation}Type: Expression(Integer)Use rewrite rules => cos(x)^2 - 3 sin(x)^2
fricassincosAngles:= 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) )\begin{equation*} \label{eq10}\begin{array}{@{}l} \displaystyle \left\{{= = \left({{\cos \left({n \ x}\right)}, \:{-{{\sin \left({x}\right)}\ {\sin \left({{\left(n - 1 \right)}\ x}\right)}}+{{\cos \left({x}\right)}\ {\cos \left({{\left(n - 1 \right)}\ x}\right)}}}}\right)}, \right. \ \ \displaystyle \left.\: \right. \ \ \displaystyle \left.{= = \left({{\sin \left({n \ x}\right)}, \:{{{\cos \left({x}\right)}\ {\sin \left({{\left(n - 1 \right)}\ x}\right)}}+{{\cos \left({{\left(n - 1 \right)}\ x}\right)}\ {\sin \left({x}\right)}}}}\right)}\right\} \end{array} \end{equation*}Type: Ruleset(Integer,Integer, Expression(Integer)) fricassincosAngles r\begin{equation} \label{eq11}-{3 \ {{\sin \left({x}\right)}^{2}}}+{{\cos \left({x}\right)}^{2}}\end{equation}Type: Expression(Integer)Other Operations
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 > 1If these conditions are not met, then the above operations return "failed".
For example,
fricasisMult(3*x)
There are 1 exposed and 0 unexposed library operations named isMult having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op isMult to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named isMult with argument type(s) Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. but
fricasisMult(x*y)
There are 1 exposed and 0 unexposed library operations named isMult having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op isMult to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named isMult with argument type(s) Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. In the context of
Expression Integer, orPolynomial Integerthe parameter n must be an Integer. The Symbolyis not anInteger.Not exactly analogously
fricasisPower(x**y)
There are no library operations named ** Use HyperDoc Browse or issue )what op ** to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named ** with argument type(s) Variable(x) Variable(y)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. whereas
fricasisPower(x**10)
There are no library operations named ** Use HyperDoc Browse or issue )what op ** to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named ** with argument type(s) Variable(x) PositiveInteger
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. In the first case the
Integeris assume to be 1.We have:
fricasisTimes(x*y*z)\begin{equation*} \label{eq12}\left[ z , \: y , \: x \right]?\end{equation*}Type: Union(List(Polynomial(Integer)),...) fricasisPlus(x+y+z*y)\begin{equation*} \label{eq13}\left[{y \ z}, \: y , \: x \right]?\end{equation*}Type: Union(List(Polynomial(Integer)),...) Whereas
fricasisTimes((x+y)*z)\begin{equation} \label{eq14}\verb#"failed"#\end{equation}Type: Union("failed",...) That is because the expression is internally treated as a
MultivariatePolynomiallike this:fricas((x+y)*z)::MPOLY([x,\begin{equation} \label{eq15}{z \ x}+{z \ y}\end{equation}y, z], INT) If you say:
fricasisPlus((x+y)*z)\begin{equation*} \label{eq16}\left[{y \ z}, \:{x \ z}\right]?\end{equation*}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
dvito see the documentation.You can also enter expressions like
isTimesin the search box on the upper right and see all the places in the algebra where this operation is defined and used.
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./3916401588212527705-16.0px.tex LaTeX2e <2022-11-01> patch level 1 L3 programming layer <2023-01-16> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2022/07/02 v1.4n Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty (/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty (/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def)) (/usr/share/texlive/texmf-dist/tex/latex/bbm-macros/bbm.sty) (/usr/share/texlive/texmf-dist/tex/latex/jknapltx/mathrsfs.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/pstricks/pstricks.sty (/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty) (/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/share/texlive/texmf-dist/tex/latex/graphics-def/dvips.def) (/usr/share/texlive/texmf-dist/tex/latex/graphics/mathcolor.ltx) (/usr/share/texlive/texmf-dist/tex/latex/graphics/dvipsnam.def)) (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/pst-xkey.tex (/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex (/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex))))) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks.tex (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pst-fp.tex `pst-fp' v0.06, 2020/11/20 (hv)) (/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgffor.sty (/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex (/usr/share/texlive/texmf-dist/tex/generic/pgf/pgf.revision.tex))) (/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeyslibraryfiltered .code.tex))) (/usr/share/texlive/texmf-dist/tex/latex/pgf/math/pgfmath.sty (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code .tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonomet ric.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.cod e.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison .code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code. tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code .tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code. tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerari thmetics.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex) (/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex))) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex)) `PSTricks' v3.18 <2022/11/28> (tvz,hv) --- We are running latex or xelatex --- (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks.con) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks-color.tex) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks-arrows.tex) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks-dots.tex) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks.con)) (/usr/share/texlive/texmf-dist/tex/generic/pstricks/pst-fp.tex `pst-fp' v0.06, 2020/11/20 (hv))) (/usr/share/texlive/texmf-dist/tex/latex/graphics/epsfig.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty) (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)))) (/usr/share/texlive/texmf-dist/tex/latex/pst-grad/pst-grad.sty (/usr/share/texlive/texmf-dist/tex/generic/pst-grad/pst-grad.tex `pst-grad' v1.06, 2006/11/27 (tvz,dg,hv))) (/usr/share/texlive/texmf-dist/tex/latex/pst-plot/pst-plot.sty (/usr/share/texlive/texmf-dist/tex/latex/xkeyval/pst-xkey.sty) (/usr/share/texlive/texmf-dist/tex/latex/multido/multido.sty (/usr/share/texlive/texmf-dist/tex/generic/multido/multido.tex v1.42, 2010/05/14 <tvz>)) (/usr/share/texlive/texmf-dist/tex/generic/pst-plot/pst-plot.tex (/usr/share/texlive/texmf-dist/tex/generic/pst-tools/pst-tools.tex `PST-tools' v0.12, 2021/09/23 (hv)) (/usr/share/texlive/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex (/usr/share/texlive/texmf-dist/tex/generic/pst-node/pst-node.tex v1.43, 2022/01/31) (/usr/share/texlive/texmf-dist/tex/generic/pst-arrow/pst-arrow.tex `pst-arrow' v0.05, 2021/11/16 (dr,hv)) (/usr/share/texlive/texmf-dist/tex/generic/pst-3d/pst-3d.tex `PST-3d' v1.11, 2010/02/14 (tvz)) (/usr/share/texlive/texmf-dist/tex/generic/pst-math/pst-math.tex `pst-math' v0.66 , (CJ,hv)) `pstricks-add' v3.93, 2022/11/21 (dr,hv)) v1.94, 2022/11/21 (tvz,hv))) (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty (/usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty)Package geometry Warning: `lmargin' and `rmargin' result in NEGATIVE (-108.405p t). `width' should be shortened in length.
) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/setspace/setspace.sty) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xy.sty (/usr/share/texlive/texmf-dist/tex/generic/xypic/xy.tex Bootstrap'ing: catcodes, docmode, (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyrecat.tex ) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyidioms.tex)
Xy-pic version 3.8.9 <2013/10/06> Copyright (c) 1991-2013 by Kristoffer H. Rose <krisrose@tug.org> and others Xy-pic is free software: see the User's Guide for details.
Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded) (/usr/share/texlive/texmf-dist/tex/generic/iftex/ifpdf.sty)) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyall.tex Xy-pic option: All features v.3.8 (/usr/share/texlive/texmf-dist/tex/generic/xypic/xycurve.tex Xy-pic option: Curve and Spline extension v.3.12 curve, circles, loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyframe.tex Xy-pic option: Frame and Bracket extension v.3.14 loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xycmtip.tex Xy-pic option: Computer Modern tip extension v.3.7 (/usr/share/texlive/texmf-dist/tex/generic/xypic/xytips.tex Xy-pic option: More Tips extension v.3.11 loaded) loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyline.tex Xy-pic option: Line styles extension v.3.10 loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyrotate.tex Xy-pic option: Rotate and Scale extension v.3.8 loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xycolor.tex Xy-pic option: Colour extension v.3.11 loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xymatrix.tex Xy-pic option: Matrix feature v.3.14 loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xyarrow.tex Xy-pic option: Arrow and Path feature v.3.9 path, \ar, loaded) (/usr/share/texlive/texmf-dist/tex/generic/xypic/xygraph.tex Xy-pic option: Graph feature v.3.11 loaded) loaded) (/usr/share/texlive/texmf-dist/tex/latex/tools/verbatim.sty) (/usr/share/texlive/texmf-dist/tex/latex/graphviz/graphviz.sty (/usr/share/texlive/texmf-dist/tex/latex/psfrag/psfrag.sty)) (/usr/share/texmf/tex/latex/sagetex.sty Writing sage input file 3916401588212527705-16.0px.sage ) (/usr/share/texlive/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty (/usr/share/texlive/texmf-dist/tex/latex/moreverb/moreverb.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty) (/usr/share/texlive/texmf-dist/tex/generic/catchfile/catchfile.sty (/usr/share/texlive/texmf-dist/tex/generic/infwarerr/infwarerr.sty) (/usr/share/texlive/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty) (/usr/share/texlive/texmf-dist/tex/generic/etexcmds/etexcmds.sty))
Package gnuplottex Warning: Shell escape not enabled. (gnuplottex) You'll need to convert the graphs yourself.
) (/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./3916401588212527705-16.0px.aux) (/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def) geometry driver: auto-detecting geometry detected driver: dvips (/usr/share/texlive/texmf-dist/tex/latex/jknapltx/ursfs.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
Package amsmath Warning: Foreign command \over; (amsmath) \frac or \genfrac should be used instead (amsmath) on input line 123.
[1] Missing { inserted. <to be read again> \ l.125 ...x \right)}\right)}\ {\left(+ \ {\left(^\ x \ 2 \right)}\ {\left(*...
Missing } inserted. <inserted text> } l.125 ...ht)}\ {\left(+ \ {\left(^\ x \ 2 \right )}\ {\left(* \ - 2 \ x \...
[2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] (/usr/share/texlive/texmf-dist/tex/latex/base/t1cmtt.fd) [14] [15] [16] (./3916401588212527705-16.0px.aux) ) (see the transcript file for additional information) Output written on 3916401588212527705-16.0px.dvi (16 pages, 5668 bytes). Transcript written on 3916401588212527705-16.0px.log.