diff --git a/changelog b/changelog index 05f3faa..1f43604 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ +20100309 tpd src/axiom-website/patches.html 2010309.01.tpd.patch +20100309 tpd src/input/wester.input reformat into regression test file 20100306 tpd src/axiom-website/patches.html 2010306.01.tzk.patch 20100306 tpd src/interp/vmlisp.lisp treeshake 20100306 tpd src/interp/util.lisp treeshake diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 4dbae87..7eab972 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -2509,7 +2509,9 @@ src/interp/*.lisp.pamphlet remove MAKESTRING macro
books/bookvol10.3 fix IndexedBits range error
20100304.01.tzk.patch src/axiom-website/download.html git-clone to git clone
-20100306.01.tpd.patch +20100306.01.tzk.patch books/bookvol5 treeshake vmlisp, bookvol10.3 defstream bug fix
+20100309.01.tpd.patch +src/input/wester.input reformat into regression test file
diff --git a/src/input/wester.input.pamphlet b/src/input/wester.input.pamphlet index 13ed2c6..db12578 100644 --- a/src/input/wester.input.pamphlet +++ b/src/input/wester.input.pamphlet @@ -9,385 +9,3060 @@ \eject \tableofcontents \eject -\section{License} -\begin{chunk}{license} ---Copyright The Numerical Algorithms Group Limited 1996. -\end{chunk} \begin{chunk}{*} -\getchunk{license} - - --- ----------[ A x i o m ]---------- --- ---------- Initialization ---------- )set break resume )set messages autoload off -)set messages time on -)set quit unprotected )set streams calculate 7 +)sys rm -f wester.output +)spool wester.output +)clear all + -- ---------- Numbers ---------- --- Let's begin by playing with numbers: infinite precision integers -factorial(50) -factor(%) --- Infinite precision rational numbers +--Let's begin by playing with numbers: infinite precision integers +--S 1 of 216 +t1:=factorial(50) +--R +--R +--R (1) 30414093201713378043612608166064768844377641568960512000000000000 +--R Type: PositiveInteger +--E 1 + +--S 2 of 216 +factor(t1) +--R +--R +--R 47 22 12 8 4 3 2 2 2 +--R (2) 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 +--R Type: Factored Integer +--E 2 + +--Infinite precision rational numbers +--S 3 of 216 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10 +--R +--R +--R 4861 +--R (3) ---- +--R 2520 +--R Type: Fraction Integer +--E 3 + -- Arbitrary precision floating point numbers +--S 4 of 216 digits(50); +--R +--R +--R Type: PositiveInteger +--E 4 + -- This number is nearly an integer +--S 5 of 216 exp(sqrt(163.)*%pi) +--R +--R +--R (5) 26253741 2640768743.9999999999 9925007259 7198185688 9 +--R Type: Float +--E 5 + +--S 6 of 216 digits(20); +--R +--R +--R Type: PositiveInteger +--E 6 + -- Special functions +--S 7 of 216 besselJ(2, 1 + %i) +--R +--R +--R (7) 4.1579886943962155E-2 + 0.24739764151330637 %i +--R Type: Complex DoubleFloat +--E 7 + -- Complete decimal expansion of a rational number +--S 8 of 216 decimal(1/7) +--R +--R +--R ______ +--R (8) 0.142857 +--R Type: DecimalExpansion +--E 8 + -- Continued fractions +--S 9 of 216 continuedFraction(%pi) +--R +--R +--R 1 | 1 | 1 | 1 | 1 | 1 | 1 | +--R (9) 3 + +---+ + +----+ + +---+ + +-----+ + +---+ + +---+ + +---+ + ... +--R | 7 | 15 | 1 | 292 | 1 | 1 | 1 +--R Type: ContinuedFraction Integer +--E 9 + -- Simplify an expression with nested square roots +--S 10 of 216 s1:=sqrt(2*sqrt(3) + 4) +--R +--R +--R +---------+ +--R | +-+ +--R (10) \|2\|3 + 4 +--R Type: AlgebraicNumber +--E 10 + +--S 11 of 216 p:POLY FRAC INT:= (ratPoly(s1::Expression Integer)::SUP FRAC INT).'z +--R +--R +--R 4 2 +--R (11) z - 8z + 4 +--R Type: Polynomial Fraction Integer +--E 11 + +--S 12 of 216 solp:=radicalSolve p +--R +--R +--R +-+ +-+ +-+ +-+ +--R (12) [z= - \|3 - 1,z= \|3 - 1,z= - \|3 + 1,z= \|3 + 1] +--R Type: List Equation Expression Integer +--E 12 + +--S 13 of 216 rhs select (z+-> real abs (complexNumeric rhs z - complexNumeric s1) < 1.E-19,solp).1 +--R +--R +--R +-+ +--R (13) \|3 + 1 +--R Type: Expression Integer +--E 13 + +--S 14 of 216 simplify(s1) +--R +--R +--R +---------+ +--R | +-+ +--R (14) \|2\|3 + 4 +--R Type: Expression Integer +--E 14 + -- Try a more complicated example (from the Putnam exam) +--S 15 of 216 s1:=sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2))))) +--R +--R +--R +---------------------------------------+ +--R | +------------------------------+ +--R | | +----------------------+ +--R | | | +-----------+ +--R | | | | +-+ +--R (15) \|3\|2\|- 12\|- 2\|2 + 3 + 5 + 3 + 14 +--R Type: AlgebraicNumber +--E 15 + +--S 16 of 216 p:POLY FRAC INT:= (ratPoly(s1::Expression Integer)::SUP FRAC INT).'z +--R +--R +--R (16) +--R 32 30 28 26 24 22 +--R z - 224z + 23304z - 1494304z + 66078476z - 2135811552z +--R + +--R 20 18 16 14 +--R 52170542296z - 981761299232z + 14373744925878z - 164123059536800z +--R + +--R 12 10 8 +--R 1455002985999736z - 9894174058819680z + 50472762054977900z +--R + +--R 6 4 2 +--R - 186014091485754784z + 464209556778289704z - 693994526414475104z +--R + +--R 461208414302655313 +--R Type: Polynomial Fraction Integer +--E 16 + +--S 17 of 216 solp:=radicalSolve p +--R +--R +--R (17) +--R +--------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|\|18\|- 23 - 54 - \|- 18\|- 23 - 54 + 28 +--R [z= -----------------------------------------------, +--R +-+ +--R \|2 +--R +--------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|\|18\|- 23 - 54 - \|- 18\|- 23 - 54 + 28 +--R z= - -----------------------------------------------, +--R +-+ +--R \|2 +--R +--------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|\|18\|- 23 - 54 + \|- 18\|- 23 - 54 + 28 +--R z= -----------------------------------------------, +--R +-+ +--R \|2 +--R +--------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|\|18\|- 23 - 54 + \|- 18\|- 23 - 54 + 28 +--R z= - -----------------------------------------------, +--R +-+ +--R \|2 +--R +----------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|- \|18\|- 23 - 54 - \|- 18\|- 23 - 54 + 28 +--R z= -------------------------------------------------, +--R +-+ +--R \|2 +--R +----------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|- \|18\|- 23 - 54 - \|- 18\|- 23 - 54 + 28 +--R z= - -------------------------------------------------, +--R +-+ +--R \|2 +--R +----------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +--R \|- \|18\|- 23 - 54 + \|- 18\|- 23 - 54 + 28 +--R z= -------------------------------------------------, +--R +-+ +--R \|2 +--R +----------------------------------------------+ +--R | +--------------+ +----------------+ +--R | | +----+ | +----+ +------------+ +--R \|- \|18\|- 23 - 54 + \|- 18\|- 23 - 54 + 28 | +-+ +--R z= - -------------------------------------------------, z= \|- 6\|2 + 17 , +--R +-+ +--R \|2 +--R +------------+ +----------+ +----------+ +--R | +-+ | +-+ | +-+ +-+ +--R z= - \|- 6\|2 + 17 , z= \|6\|2 + 17 , z= - \|6\|2 + 17 , z= - \|2 - 3, +--R +-+ +-+ +-+ +--R z= \|2 - 3, z= - \|2 + 3, z= \|2 + 3] +--R Type: List Equation Expression Integer +--E 17 + +--S 18 of 216 rhs select (z+-> real abs (complexNumeric rhs z - complexNumeric s1) < 1.E-19,solp).1 +--R +--R +--R +-+ +--R (18) \|2 + 3 +--R Type: Expression Integer +--E 18 + +--S 19 of 216 simplify(s1) +--R +--R +--R +---------------------------------------+ +--R | +------------------------------+ +--R | | +----------------------+ +--R | | | +-----------+ +--R | | | | +-+ +--R (19) \|3\|2\|- 12\|- 2\|2 + 3 + 5 + 3 + 14 +--R Type: Expression Integer +--E 19 + -- Cardinal numbers +--S 20 of 216 2*Aleph(0) - 3 +--R +--R +--R (20) Aleph(0) +--R Type: Union(CardinalNumber,...) +--E 20 + -- ---------- Statistics ---------- -- ---------- Algebra ---------- -- Numbers are nice, but symbols allow for variability---try some high school -- algebra: rational simplification +--S 21 of 216 (x**2 - 4)/(x**2 + 4*x + 4) +--R +--R +--R x - 2 +--R (21) ----- +--R x + 2 +--R Type: Fraction Polynomial Integer +--E 21 + -- This example requires more sophistication +--S 22 of 216 (%e**x - 1)/(%e**(x/2) + 1) +--R +--R +--R x +--R %e - 1 +--R (22) ------- +--R x +--R - +--R 2 +--R %e + 1 +--R Type: Expression Integer +--E 22 + +--S 23 of 216 normalize(%) +--R +--R +--R x +--R - +--R 2 +--R (23) %e - 1 +--R Type: Expression Integer +--E 23 + -- Expand and factor polynomials +--S 24 of 216 (x + 1)**20 +--R +--R +--R (24) +--R 20 19 18 17 16 15 14 13 +--R x + 20x + 190x + 1140x + 4845x + 15504x + 38760x + 77520x +--R + +--R 12 11 10 9 8 7 6 +--R 125970x + 167960x + 184756x + 167960x + 125970x + 77520x + 38760x +--R + +--R 5 4 3 2 +--R 15504x + 4845x + 1140x + 190x + 20x + 1 +--R Type: Polynomial Integer +--E 24 + +--S 25 of 216 D(%, x) +--R +--R +--R (25) +--R 19 18 17 16 15 14 13 +--R 20x + 380x + 3420x + 19380x + 77520x + 232560x + 542640x +--R + +--R 12 11 10 9 8 7 +--R 1007760x + 1511640x + 1847560x + 1847560x + 1511640x + 1007760x +--R + +--R 6 5 4 3 2 +--R 542640x + 232560x + 77520x + 19380x + 3420x + 380x + 20 +--R Type: Polynomial Integer +--E 25 + +--S 26 of 216 factor(%) +--R +--R +--R 19 +--R (26) 20(x + 1) +--R Type: Factored Polynomial Integer +--E 26 + +--S 27 of 216 x**100 - 1 +--R +--R +--R 100 +--R (27) x - 1 +--R Type: Polynomial Integer +--E 27 + +--S 28 of 216 factor(%) +--R +--R +--R (28) +--R 2 4 3 2 4 3 2 +--R (x - 1)(x + 1)(x + 1)(x - x + x - x + 1)(x + x + x + x + 1) +--R * +--R 8 6 4 2 20 15 10 5 20 15 10 5 +--R (x - x + x - x + 1)(x - x + x - x + 1)(x + x + x + x + 1) +--R * +--R 40 30 20 10 +--R (x - x + x - x + 1) +--R Type: Factored Polynomial Integer +--E 28 + -- Factor polynomials over finite fields and field extensions +--S 29 of 216 p:= x**4 - 3*x**2 + 1 +--R +--R +--R 4 2 +--R (29) x - 3x + 1 +--R Type: Polynomial Fraction Integer +--E 29 + +--S 30 of 216 factor(p) +--R +--R +--R 2 2 +--R (30) (x - x - 1)(x + x - 1) +--R Type: Factored Polynomial Fraction Integer +--E 30 + +--S 31 of 216 phi:= rootOf(phi**2 - phi - 1); +--R +--R +--R Type: AlgebraicNumber +--E 31 + +--S 32 of 216 factor(p, [phi]) +--R +--R +--R (32) (x - phi)(x - phi + 1)(x + phi - 1)(x + phi) +--R Type: Factored Polynomial AlgebraicNumber +--E 32 + +--S 33 of 216 factor(p :: Polynomial(PrimeField(5))) +--R +--R +--R 2 2 +--R (33) (x + 2) (x + 3) +--R Type: Factored Polynomial PrimeField 5 +--E 33 + +--S 34 of 216 expand(%) +--R +--R +--R 4 2 +--R (34) x + 2x + 1 +--R Type: Polynomial PrimeField 5 +--E 34 + -- Partial fraction decomposition +--S 35 of 216 (x**2 + 2*x + 3)/(x**3 + 4*x**2 + 5*x + 2) -padicFraction( - partialFraction(numerator(%) :: UnivariatePolynomial(x, Fraction Integer), - factor(denominator(%) :: Polynomial Integer) :: +--R +--R +--R 2 +--R x + 2x + 3 +--R (35) ----------------- +--R 3 2 +--R x + 4x + 5x + 2 +--R Type: Fraction Polynomial Integer +--E 35 + +--S 36 of 216 +padicFraction(_ + partialFraction(numerator(%) :: UnivariatePolynomial(x, Fraction Integer),_ + factor(denominator(%) :: Polynomial Integer) ::_ Factored UnivariatePolynomial(x, Fraction Integer))) +--R +--R +--R 2 2 3 +--R (36) - ----- + -------- + ----- +--R x + 1 2 x + 2 +--R (x + 1) +--R Type: PartialFraction UnivariatePolynomial(x,Fraction Integer) +--E 36 + + -- ---------- Inequalities ---------- -- ---------- Trigonometry ---------- -- Trigonometric manipulations---these are typically difficult for students +--S 37 of 216 r:= cos(3*x)/cos(x) +--R +--R +--R cos(3x) +--R (37) ------- +--R cos(x) +--R Type: Expression Integer +--E 37 + +--S 38 of 216 real(complexNormalize(%)) +--R +--R +--R 2 2 +--R (38) - 2sin(x) + 2cos(x) - 1 +--R Type: Expression Integer +--E 38 + +--S 39 of 216 real(normalize(simplify(complexNormalize(r)))) +--R +--R +--R (39) 2cos(2x) - 1 +--R Type: Expression Integer +--E 39 + -- Use rewrite rules +--S 40 of 216 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) ) +--R +--R +--R (40) +--R {cos(n x) == - sin(x)sin((n - 1)x) + cos(x)cos((n - 1)x), +--R sin(n x) == cos(x)sin((n - 1)x) + cos((n - 1)x)sin(x)} +--R Type: Ruleset(Integer,Integer,Expression Integer) +--E 40 + +--S 41 of 216 sincosAngles r +--R +--R +--R 2 2 +--R (41) - 3sin(x) + cos(x) +--R Type: Expression Integer +--E 41 + -- ---------- Determining Zero Equivalence ---------- -- The following expressions are all equal to zero +--S 42 of 216 sqrt(997) - (997**3)**(1/6) +--R +--R +--R (42) 0 +--R Type: AlgebraicNumber +--E 42 + +--S 43 of 216 sqrt(999983) - (999983**3)**(1/6) +--R +--R +--R (43) 0 +--R Type: AlgebraicNumber +--E 43 + +--S 44 of 216 s1:=(2**(1/3) + 4**(1/3))**3 - 6*(2**(1/3) + 4**(1/3)) - 6 +--R +--R +--R 3+-+3+-+2 3+-+2 3+-+ 3+-+ +--R (44) 3\|2 \|4 + (3\|2 - 6)\|4 - 6\|2 +--R Type: AlgebraicNumber +--E 44 + +--S 45 of 216 simplify(%) +--R +--R +--R 3+-+3+-+2 3+-+2 3+-+ 3+-+ +--R (45) 3\|2 \|4 + (3\|2 - 6)\|4 - 6\|2 +--R Type: Expression Integer +--E 45 + +--S 46 of 216 p:POLY FRAC INT:= (ratPoly(s1::Expression Integer)::SUP FRAC INT).'z +--R +--R +--R 7 5 3 2 +--R (46) z - 648z + 419904z + 7558272z + 45349632z +--R Type: Polynomial Fraction Integer +--E 46 + +--S 47 of 216 solp:=radicalSolve p +--R +--R +--R (47) [z= 0] +--R Type: List Equation Expression Integer +--E 47 + +--S 48 of 216 rhs select (z+-> real abs (complexNumeric rhs z - complexNumeric s1) < 1.E-19,solp).1 --- This expression is zero for x, y > 0 and n not equal to zero +--R +--R +--R (48) 0 +--R Type: Expression Integer +--E 48 + +-- Thi49s expression is zero for x, y > 0 and n not equal to zero +--S 49 of 216 x**(1/n)*y**(1/n) - (x*y)**(1/n) +--R +--R +--R 1 1 1 +--R - - - +--R n n n +--R (49) - (x y) + x y +--R Type: Expression Integer +--E 49 + +--S 50 of 216 normalize(%) +--R +--R +--R (50) 0 +--R Type: Expression Integer +--E 50 + -- See Joel Moses, ``Algebraic Simplification: A Guide for the Perplexed'', -- CACM, Volume 14, Number 8, August 1971 +--S 51 of 216 expr:= log(tan(1/2*x + %pi/4)) - asinh(tan(x)) +--R +--R +--R 2x + %pi +--R (51) log(tan(--------)) - asinh(tan(x)) +--R 4 +--R Type: Expression Integer +--E 51 + +--S 52 of 216 complexNormalize(%) +--R +--R +--R (52) +--R - +--R log +--R +---+ 4 +--R (2x + %pi)\|- 1 +--R ---------------- +--R 4 +--R ((%e ) - 1) +--R * +--R +----------------------------------------------------+ +--R | +---+ 4 +--R | (2x + %pi)\|- 1 +--R | ---------------- +--R | 4 +--R | 4(%e ) +--R |- -------------------------------------------------- +--R | +---+ 8 +---+ 4 +--R | (2x + %pi)\|- 1 (2x + %pi)\|- 1 +--R | ---------------- ---------------- +--R | 4 4 +--R \| (%e ) - 2(%e ) + 1 +--R + +--R +---+ 4 +--R (2x + %pi)\|- 1 +--R ---------------- +--R +---+ 4 +---+ +--R - \|- 1 (%e ) - \|- 1 +--R / +--R +---+ 4 +--R (2x + %pi)\|- 1 +--R ---------------- +--R 4 +--R (%e ) - 1 +--R + +--R +---+ 2 +--R (2x + %pi)\|- 1 +--R ---------------- +--R +---+ 4 +---+ +--R - \|- 1 (%e ) + \|- 1 +--R log(--------------------------------------) +--R +---+ 2 +--R (2x + %pi)\|- 1 +--R ---------------- +--R 4 +--R (%e ) + 1 +--R Type: Expression Integer +--E 52 + -- Use a roundabout method---show that expr is a constant equal to zero +--S 53 of 216 D(expr, x) +--R +--R +--R (53) +--R +-----------+ +--R 2x + %pi 2 | 2 2x + %pi 2 2x + %pi +--R (tan(--------) + 1)\|tan(x) + 1 - 2tan(--------)tan(x) - 2tan(--------) +--R 4 4 4 +--R --------------------------------------------------------------------------- +--R +-----------+ +--R 2x + %pi | 2 +--R 2tan(--------)\|tan(x) + 1 +--R 4 +--R Type: Expression Integer +--E 53 + +--S 54 of 216 normalize(rootSimp(expand(simplify(%)))) +--R +--R +--R (54) 0 +--R Type: Expression Integer +--E 54 + +--S 55 of 216 normalize(eval(expr, x = 0)) +--R +--R +--R (55) 0 +--R Type: Expression Integer +--E 55 + +--S 56 of 216 expr:=log((2*sqrt(r) + 1)/sqrt(4*r + 4*sqrt(r) + 1)) +--R +--R +--R +-------+ +--R |cos(3x) +--R 2 |------- + 1 +--R \| cos(x) +--R (56) log(----------------------------------------) +--R +-------------------------------------+ +--R | +-------+ +--R | |cos(3x) +--R |4cos(x) |------- + 4cos(3x) + cos(x) +--R | \| cos(x) +--R |------------------------------------- +--R \| cos(x) +--R Type: Expression Integer +--E 56 + +--S 57 of 216 D(expr, x) +--R +--R +--R (57) 0 +--R Type: Expression Integer +--E 57 + +--S 58 of 216 eval(expr, x = 0) +--R +--R +--R (58) 0 +--R Type: Expression Integer +--E 58 + +--S 59 of 216 (4*r + 4*sqrt(r) + 1)**(sqrt(r)/(2*sqrt(r) + 1)) _ * (2*sqrt(r) + 1)**(1/(2*sqrt(r) + 1)) - 2*sqrt(r) - 1 +--R +--R +--R (59) +--R 1 +--R --------------- +--R +-------+ +--R |cos(3x) +--R 2 |------- + 1 +--R +-------+ \| cos(x) +--R |cos(3x) +--R (2 |------- + 1) +--R \| cos(x) +--R * +--R +-------+ +--R |cos(3x) +--R |------- +--R \| cos(x) +--R --------------- +--R +-------+ +--R |cos(3x) +--R 2 |------- + 1 +--R +-------+ \| cos(x) +--R |cos(3x) +--R 4cos(x) |------- + 4cos(3x) + cos(x) +--R \| cos(x) +--R (-------------------------------------) +--R cos(x) +--R + +--R +-------+ +--R |cos(3x) +--R - 2 |------- - 1 +--R \| cos(x) +--R Type: Expression Integer +--E 59 + +--S 60 of 216 normalize(%) +--R +--R +--R (60) 0 +--R Type: Expression Integer +--E 60 + -- ---------- The Complex Domain ---------- -- Complex functions---separate into their real and imaginary parts +--S 61 of 216 rectform(z) == real(z) + %i*imag(z) +--R +--R Type: Void +--E 61 + +--S 62 of 216 rectform(log(3 + 4*%i)) +--R +--R Compiling function rectform with type Expression Complex Integer -> +--R Expression Complex Integer +--R +--R 4 +--R log(25) + 2%i atan(-) +--R 3 +--R (62) --------------------- +--R 2 +--R Type: Expression Complex Integer +--E 62 + +--S 63 of 216 simplify(rectform(tan(x + %i*y))) +--R +--R +--R - 2y 2 - 2y +--R - 2%i cos(x)%e sin(x) + (- 2cos(x) + 1)%e + 1 +--R (63) ----------------------------------------------------- +--R - 2y 2 - 2y +--R 2cos(x)%e sin(x) + (- 2%i cos(x) + %i)%e - %i +--R Type: Expression Complex Integer +--E 63 + -- Check for branch abuse. See David R. Stoutemyer, ``Crimes and Misdemeanors -- in the Computer Algebra Trade'', Notices of the AMS, Volume 38, Number 7, -- September 1991. This first expression can simplify to sqrt(x y)/sqrt(x), -- but no further in general (consider what happens when x, y = -1). +--S 64 of 216 sqrt(x*y*abs(z)**2) / (sqrt(x)*abs(z)) +--R +--R +--R +-----------+ +--R | 2 +--R \|x y abs(z) +--R (64) -------------- +--R +-+ +--R abs(z)\|x +--R Type: Expression Integer +--E 64 + +--S 65 of 216 rootSimp % +--R +--R +--R +---+ +--R \|x y +--R (65) ------ +--R +-+ +--R \|x +--R Type: Expression Integer +--E 65 + -- If z = -1, sqrt(1/z) is not equal to 1/sqrt(z) +--S 66 of 216 sqrt(1/z) - 1/sqrt(z) +--R +--R +--R +-+ +--R |1 +-+ +--R |- \|z - 1 +--R \|z +--R (66) ------------ +--R +-+ +--R \|z +--R Type: Expression Integer +--E 66 + -- If z = 3 pi i, log(exp(z)) is not equal to z +--S 67 of 216 log(%e**z) +--R +--R +--R (67) z +--R Type: Expression Integer +--E 67 + +--S 68 of 216 normalize(%) +--R +--R +--R (68) z +--R Type: Expression Integer +--E 68 + -- The principal value of this expression is (10 - 4 pi) i +--S 69 of 216 log(%e**(10*%i)) +--R +--R +--R 10%i +--R (69) log(%e ) +--R Type: Expression Complex Integer +--E 69 + +--S 70 of 216 normalize(%) +--R +--R +--R 10%i +--R (70) log(%e ) +--R Type: Expression Complex Integer +--E 70 + -- If z = pi, arctan(tan(z)) is not equal to z +--S 71 of 216 atan(tan(z)) +--R +--R +--R (71) z +--R Type: Expression Integer +--E 71 + -- If z = 2 pi i, sqrt(exp(z)) is not equal to exp(z/2) +--S 72 of 216 sqrt(%e**z) - %e**(z/2) +--R +--R +--R z +--R +---+ - +--R | z 2 +--R (72) \|%e - %e +--R Type: Expression Integer +--E 72 + -- ---------- Equations ---------- -- Manipulate an equation using a natural syntax +--S 73 of 216 (x = 0)/2 + 1 +--R +--R +--R x + 2 +--R (73) -----= 1 +--R 2 +--R Type: Equation Fraction Polynomial Integer +--E 73 + -- Solve various nonlinear equations---this cubic polynomial has all real roots +--S 74 of 216 radicalSolve(3*x**3 - 18*x**2 + 33*x - 19 = 0, x) +--R +--R +--R (74) +--R +-------------+2 +-------------+ +--R | +-+ +---+ | +-+ +---+ +--R +---+ |\|3 + \|- 1 +---+ |\|3 + \|- 1 +--R (- 3\|- 3 + 3) |------------- + (6\|- 3 + 6) |------------- - 2 +--R 3| +-+ 3| +-+ +--R \| 6\|3 \| 6\|3 +--R [x= --------------------------------------------------------------------, +--R +-------------+ +--R | +-+ +---+ +--R +---+ |\|3 + \|- 1 +--R (3\|- 3 + 3) |------------- +--R 3| +-+ +--R \| 6\|3 +--R +-------------+2 +-------------+ +--R | +-+ +---+ | +-+ +---+ +--R +---+ |\|3 + \|- 1 +---+ |\|3 + \|- 1 +--R (- 3\|- 3 - 3) |------------- + (6\|- 3 - 6) |------------- + 2 +--R 3| +-+ 3| +-+ +--R \| 6\|3 \| 6\|3 +--R x= --------------------------------------------------------------------, +--R +-------------+ +--R | +-+ +---+ +--R +---+ |\|3 + \|- 1 +--R (3\|- 3 - 3) |------------- +--R 3| +-+ +--R \| 6\|3 +--R +-------------+2 +-------------+ +--R | +-+ +---+ | +-+ +---+ +--R |\|3 + \|- 1 |\|3 + \|- 1 +--R 3 |------------- + 6 |------------- + 1 +--R 3| +-+ 3| +-+ +--R \| 6\|3 \| 6\|3 +--R x= ------------------------------------------] +--R +-------------+ +--R | +-+ +---+ +--R |\|3 + \|- 1 +--R 3 |------------- +--R 3| +-+ +--R \| 6\|3 +--R Type: List Equation Expression Integer +--E 74 + +--S 75 of 216 map(e +-> lhs(e) = rectform(rhs(e)), %) +--R +--R Compiling function rectform with type Expression Integer -> +--R Expression Complex Integer +--R +--R (75) +--R [ +--R x = +--R +-+ %pi 2 +-+ %pi +-+ %pi +--R (\|3 - %i)sin(---) + ((- 2%i\|3 - 2)cos(---) + 4\|3 )sin(---) +--R 18 18 18 +--R + +--R +-+ %pi 2 +-+ %pi +-+ +--R (- \|3 + %i)cos(---) - 4%i\|3 cos(---) + \|3 + %i +--R 18 18 +--R / +--R +-+ %pi +-+ %pi +--R 2\|3 sin(---) - 2%i\|3 cos(---) +--R 18 18 +--R , +--R +--R x = +--R +-+ %pi 2 +-+ %pi +-+ %pi +--R (- \|3 - %i)sin(---) + ((2%i\|3 - 2)cos(---) + 4\|3 )sin(---) +--R 18 18 18 +--R + +--R +-+ %pi 2 +-+ %pi +-+ +--R (\|3 + %i)cos(---) - 4%i\|3 cos(---) - \|3 + %i +--R 18 18 +--R / +--R +-+ %pi +-+ %pi +--R 2\|3 sin(---) - 2%i\|3 cos(---) +--R 18 18 +--R , +--R +--R x = +--R %pi 2 %pi +-+ %pi %pi 2 +--R %i sin(---) + (2cos(---) + 2\|3 )sin(---) - %i cos(---) +--R 18 18 18 18 +--R + +--R +-+ %pi +--R - 2%i\|3 cos(---) - %i +--R 18 +--R / +--R +-+ %pi +-+ %pi +--R \|3 sin(---) - %i\|3 cos(---) +--R 18 18 +--R ] +--R Type: List Equation Expression Complex Integer +--E 75 + -- Some simple seeming problems can have messy answers +--S 76 of 216 eqn:= x**4 + x**3 + x**2 + x + 1 = 0 +--R +--R +--R 4 3 2 +--R (76) x + x + x + x + 1= 0 +--R Type: Equation Polynomial Integer +--E 76 + +--S 77 of 216 radicalSolve(eqn, x) +--R +--R +--R (77) +--R [ +--R x = +--R - +--R 2 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 30 |------------------- - 40 +--R 3| +-+ +--R \| 54\|3 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 15 |------------------- + 40 +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 45 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 15 |------------------- + 40 +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R 2 |--------------------------------------------------------- - 1 +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R / +--R 4 +--R , +--R +--R x = +--R 2 +--R * +--R ROOT +--R +-------------------+2 +-------------------+ +--R | +-+ +---+ | +-+ +---+ +--R |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R - 36 |------------------- - 30 |------------------- +--R 3| +-+ 3| +-+ +--R \| 54\|3 \| 54\|3 +--R + +--R - 40 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 45 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R 2 |--------------------------------------------------------- - 1 +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R / +--R 4 +--R , +--R +--R x = +--R - +--R 2 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 30 |------------------- - 40 +--R 3| +-+ +--R \| 54\|3 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 15 |------------------- + 40 +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 45 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R ROOT +--R +-------------------+2 +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 15 |------------------- + 40 +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R - 2 |--------------------------------------------------------- - 1 +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R / +--R 4 +--R , +--R +--R x = +--R 2 +--R * +--R ROOT +--R +-------------------+2 +-------------------+ +--R | +-+ +---+ | +-+ +---+ +--R |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R - 36 |------------------- - 30 |------------------- +--R 3| +-+ 3| +-+ +--R \| 54\|3 \| 54\|3 +--R + +--R - 40 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 45 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R - 2 |--------------------------------------------------------- - 1 +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R / +--R 4 +--R ] +--R Type: List Equation Expression Integer +--E 77 + -- Check one of the answers +--S 78 of 216 eval(eqn, %.1) +--R +--R +--R (78) +--R +-------------------+ +--R | +-+ +---+ +--R +---+ +-+2 +---+ |- 25\|3 + 45\|- 5 +--R (90\|- 5 \|3 - 270\|- 5 ) |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R ROOT +--R +-------------------+2 +-------------------+ +--R | +-+ +---+ | +-+ +---+ +--R |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R (- 36 |------------------- - 30 |------------------- - 40) +--R 3| +-+ 3| +-+ +--R \| 54\|3 \| 54\|3 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R - 45 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+ +--R | +-+ +---+ +--R |- 25\|3 + 45\|- 5 +--R 36 |------------------- +--R 3| +-+ +--R \| 54\|3 +--R * +--R +---------------------------------------------------------+ +--R | +-------------------+2 +-------------------+ +--R | | +-+ +---+ | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 |- 25\|3 + 45\|- 5 +--R |36 |------------------- - 15 |------------------- + 40 +--R | 3| +-+ 3| +-+ +--R | \| 54\|3 \| 54\|3 +--R |--------------------------------------------------------- +--R | +-------------------+ +--R | | +-+ +---+ +--R | |- 25\|3 + 45\|- 5 +--R | 36 |------------------- +--R | 3| +-+ +--R \| \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R +---+ +-+2 +---+ |- 25\|3 + 45\|- 5 +--R (- 135\|- 5 \|3 + 405\|- 5 ) |------------------- +--R 3| +-+ +--R \| 54\|3 +--R / +--R +-------------------+2 +--R | +-+ +---+ +--R +---+ +-+2 +-+ |- 25\|3 + 45\|- 5 +--R (432\|- 5 \|3 + 1584\|3 ) |------------------- +--R 3| +-+ +--R \| 54\|3 +--R + +--R +-------------------+ +--R | +-+ +---+ +--R +---+ +-+2 +-+ |- 25\|3 + 45\|- 5 +-+ +---+ +--R (- 180\|- 5 \|3 - 660\|3 ) |------------------- + 1760\|3 + 1440\|- 5 +--R 3| +-+ +--R \| 54\|3 +--R = +--R 0 +--R Type: Equation Expression Integer +--E 78 + +--S 79 of 216 %e**(2*x) + 2*%e**x + 1 = z +--R +--R +--R 2x x +--R (79) %e + 2%e + 1= z +--R Type: Equation Expression Integer +--E 79 + +--S 80 of 216 solve(%, x) +--R +--R +--R +-+ +-+ +--R (80) [x= log(\|z - 1),x= log(- \|z - 1)] +--R Type: List Equation Expression Integer +--E 80 + -- This equation is already factored and so *should* be easy to solve +--S 81 of 216 (x + 1) * (sin(x)**2 + 1)**2 * cos(3*x)**3 = 0 +--R +--R +--R 3 4 3 2 3 +--R (81) (x + 1)cos(3x) sin(x) + (2x + 2)cos(3x) sin(x) + (x + 1)cos(3x) = 0 +--R Type: Equation Expression Integer +--E 81 + +--S 82 of 216 solve(%, x) +--R +--R +--R +---+ +---+ %pi +--R (82) [x= asin(\|- 1 ),x= - asin(\|- 1 ),x= ---,x= - 1] +--R 6 +--R Type: List Equation Expression Integer +--E 82 + -- The following equations have an infinite number of solutions (let n be an -- arbitrary integer): z = 0 [+ n 2 pi i] +--S 83 of 216 solve(%e**z = 1, z) +--R +--R +--R (83) [z= 0] +--R Type: List Equation Expression Integer +--E 83 + -- x = pi/4 [+ n pi] +--S 84 of 216 solve(sin(x) = cos(x), x) +--R +--R +--R %pi +--R (84) [x= ---] +--R 4 +--R Type: List Equation Expression Integer +--E 84 + +--S 85 of 216 solve(tan(x) = 1, x) +--R +--R +--R %pi +--R (85) [x= ---] +--R 4 +--R Type: List Equation Expression Integer +--E 85 + -- x = 0, 0 [+ n pi, + n 2 pi] +--S 86 of 216 solve(sin(x) = tan(x), x) +--R +--R +--R (86) [x= 0] +--R Type: List Equation Expression Integer +--E 86 + -- This equation has no solutions +--S 87 of 216 solve(sqrt(x**2 + 1) = x - 2, x) +--R +--R +--R (87) [] +--R Type: List Equation Expression Integer +--E 87 + -- Solve a system of linear equations +--S 88 of 216 eq1:= x + y + z = 6 +--R +--R +--R (88) z + y + x= 6 +--R Type: Equation Polynomial Integer +--E 88 + +--S 89 of 216 eq2:= 2*x + y + 2*z = 10 +--R +--R +--R (89) 2z + y + 2x= 10 +--R Type: Equation Polynomial Integer +--E 89 + +--S 90 of 216 eq3:= x + 3*y + z = 10 +--R +--R +--R (90) z + 3y + x= 10 +--R Type: Equation Polynomial Integer +--E 90 + -- Note that the solution is parametric +--S 91 of 216 solve([eq1, eq2, eq3], [x, y, z]) +--R +--R +--R (91) [[x= - %CA + 4,y= 2,z= %CA]] +--R Type: List List Equation Fraction Polynomial Integer +--E 91 + -- Solve a system of nonlinear equations +--S 92 of 216 eq1:= x**2*y + 3*y*z - 4 = 0 +--R +--R +--R 2 +--R (92) 3y z + x y - 4= 0 +--R Type: Equation Polynomial Integer +--E 92 + +--S 93 of 216 eq2:= -3*x**2*z + 2*y**2 + 1 = 0 +--R +--R +--R 2 2 +--R (93) - 3x z + 2y + 1= 0 +--R Type: Equation Polynomial Integer +--E 93 + +--S 94 of 216 eq3:= 2*y*z**2 - z**2 - 1 = 0 +--R +--R +--R 2 +--R (94) (2y - 1)z - 1= 0 +--R Type: Equation Polynomial Integer +--E 94 + -- Solving this by hand would be a nightmare +--S 95 of 216 solve([eq1, eq2, eq3], [x, y, z]) +--R +--R +--R (95) +--R [[x= 1,y= 1,z= 1], [x= - 1,y= 1,z= 1], +--R 2 2 +--R [- 3z + x + 2= 0,y= - 3z + 1,3z - 2z + 1= 0], +--R +--R 4 3 2 +--R 4 3 2 2 - 18z + 24z + 21z + 12z + 3 +--R [12z - 12z - 30z + 7z + 3x = 0, y= ------------------------------, +--R 2 +--R 5 4 3 2 +--R 6z - 6z - 9z - 7z - 3z - 1= 0] +--R ] +--R Type: List List Equation Fraction Polynomial Integer +--E 95 + -- ---------- Matrix Algebra ---------- +--S 96 of 216 m:= matrix([[a, b], [1, a*b]]) +--R +--R +--R +a b + +--R (96) | | +--R +1 a b+ +--R Type: Matrix Polynomial Integer +--E 96 + -- Invert the matrix +--S 97 of 216 minv:= inverse(m) +--R +--R +--R + a 1 + +--R | ------ - ------ | +--R | 2 2 | +--R | a - 1 a - 1 | +--R (97) | | +--R | 1 a | +--R |- --------- ---------| +--R | 2 2 | +--R + (a - 1)b (a - 1)b+ +--R Type: Union(Matrix Fraction Polynomial Integer,...) +--E 97 + +--S 98 of 216 m * minv +--R +--R +--R +1 0+ +--R (98) | | +--R +0 1+ +--R Type: Matrix Fraction Polynomial Integer +--E 98 + -- Define a Vandermonde matrix (useful for doing polynomial interpolations) +--S 99 of 216 matrix([[1, 1, 1, 1 ], _ [w, x, y, z ], _ [w**2, x**2, y**2, z**2], _ [w**3, x**3, y**3, z**3]]) +--R +--R +--R +1 1 1 1 + +--R | | +--R |w x y z | +--R | | +--R (99) | 2 2 2 2| +--R |w x y z | +--R | | +--R | 3 3 3 3| +--R +w x y z + +--R Type: Matrix Polynomial Integer +--E 99 + +--S 100 of 216 determinant(%) +--R +--R +--R (100) +--R 2 2 2 2 2 3 +--R ((x - w)y + (- x + w )y + w x - w x)z +--R + +--R 3 3 3 3 3 2 +--R ((- x + w)y + (x - w )y - w x + w x)z +--R + +--R 2 2 3 3 3 2 2 3 3 2 2 2 3 +--R ((x - w )y + (- x + w )y + w x - w x )z + (- w x + w x)y +--R + +--R 3 3 2 2 3 3 2 +--R (w x - w x)y + (- w x + w x )y +--R Type: Polynomial Integer +--E 100 + -- The following formula implies a general result +--S 101 of 216 factor(%) +--R +--R +--R (101) (x - w)(y - x)(y - w)(z - y)(z - x)(z - w) +--R Type: Factored Polynomial Integer +--E 101 + -- Compute the eigenvalues of a matrix from its characteristic polynomial +--S 102 of 216 m:= matrix([[ 5, -3, -7], _ [-2, 1, 2], _ [ 2, -3, -4]]) +--R +--R +--R + 5 - 3 - 7+ +--R | | +--R (102) |- 2 1 2 | +--R | | +--R + 2 - 3 - 4+ +--R Type: Matrix Integer +--E 102 + +--S 103 of 216 characteristicPolynomial(m, lambda) +--R +--R +--R 3 2 +--R (103) - lambda + 2lambda + 5lambda - 6 +--R Type: Polynomial Integer +--E 103 + +--S 104 of 216 solve(% = 0, lambda) +--R +--R +--R (104) [lambda= 3,lambda= 1,lambda= - 2] +--R Type: List Equation Fraction Polynomial Integer +--E 104 + -- ---------- Tensors ---------- -- ---------- Sums and Products ---------- -- Sums: finite and infinite +--S 105 of 216 summation(k**3, k = 1..n) +--R +--R +--R n +--R --+ 3 +--R (105) > k +--R --+ +--R k= 1 +--R Type: Expression Integer +--E 105 + +--S 106 of 216 sum(k**3, k = 1..n) +--R +--R +--R 4 3 2 +--R n + 2n + n +--R (106) ------------- +--R 4 +--R Type: Fraction Polynomial Integer +--E 106 + +--S 107 of 216 limit(sum(1/k**2 + 1/k**3, k = 1..n), n = %plusInfinity) +--R +--R +--R (107) "failed" +--R Type: Union("failed",...) +--E 107 + -- Products +--S 108 of 216 product(k, k = 1..n) +--R +--R +--R n +--R ++-++ +--R (108) | | k +--R | | +--R k= 1 +--R Type: Expression Integer +--E 108 + -- ---------- Calculus ---------- -- Limits---start with a famous example +--S 109 of 216 limit((1 + 1/n)**n, n = %plusInfinity) +--R +--R +--R (109) %e +--R Type: Union(OrderedCompletion Expression Integer,...) +--E 109 + +--S 110 of 216 limit((1 - cos(x))/x**2, x = 0) +--R +--R +--R 1 +--R (110) - +--R 2 +--R Type: Union(OrderedCompletion Expression Integer,...) +--E 110 + -- Apply the chain rule---this is important for PDEs and many other -- applications +--S 111 of 216 y:= operator('y); +--R +--R +--R Type: BasicOperator +--E 111 + +--S 112 of 216 x:= operator('x); +--R +--R +--R Type: BasicOperator +--E 112 + +--S 113 of 216 D(y(x(t)), t, 2) +--R +--R +--R , 2 ,, , ,, +--R (113) x (t) y (x(t)) + y (x(t))x (t) +--R +--R Type: Expression Integer +--E 113 + )clear properties x y + -- ---------- Indefinite Integrals ---------- +--S 114 of 216 1/(x**3 + 2) +--R +--R +--R 1 +--R (114) ------ +--R 3 +--R x + 2 +--R Type: Fraction Polynomial Integer +--E 114 + -- This would be very difficult to do by hand +--S 115 of 216 integrate(%, x) +--R +--R +--R (115) +--R +-+ 2 3+-+2 3+-+ +-+ 3+-+ +--R - \|3 log(x \|4 - 2x\|4 + 4) + 2\|3 log(x\|4 + 2) +--R + +--R +-+3+-+ +-+ +--R x\|3 \|4 - \|3 +--R 6atan(----------------) +--R 3 +--R / +--R +-+3+-+ +--R 6\|3 \|4 +--R Type: Union(Expression Integer,...) +--E 115 + +--S 116 of 216 D(%, x) +--R +--R +--R 1 +--R (116) ------ +--R 3 +--R x + 2 +--R Type: Expression Integer +--E 116 + -- This example involves several symbolic parameters +--S 117 of 216 integrate(1/(a + b*cos(x)), x) +--R +--R +--R (117) +--R +-------+ +--R | 2 2 2 2 +--R (- a cos(x) - b)\|b - a + (- b + a )sin(x) +--R log(----------------------------------------------) +--R b cos(x) + a +--R [---------------------------------------------------, +--R +-------+ +--R | 2 2 +--R \|b - a +--R +---------+ +--R | 2 2 +--R sin(x)\|- b + a +--R 2atan(---------------------) +--R (b + a)cos(x) + b + a +--R ----------------------------] +--R +---------+ +--R | 2 2 +--R \|- b + a +--R Type: Union(List Expression Integer,...) +--E 117 + +--S 118 of 216 map(simplify, map(f +-> D(f, x), %)) +--R +--R +--R 1 1 +--R (118) [------------,------------] +--R b cos(x) + a b cos(x) + a +--R Type: List Expression Integer +--E 118 + -- Calculus on a non-smooth (but well defined) function +--S 119 of 216 D(abs(x), x) +--R +--R +--R abs(x) +--R (119) ------ +--R x +--R Type: Expression Integer +--E 119 + +--S 120 of 216 integrate(abs(x), x) +--R +--R +--R x +--R ++ +--R (120) | abs(%M)d%M +--R ++ +--R Type: Union(Expression Integer,...) +--E 120 + -- Calculus on a piecewise defined function +--S 121 of 216 a(x) == if x < 0 then -x else x +--R +--R Type: Void +--E 121 + +--S 122 of 216 D(a(x), x) +--R +--R Compiling function a with type Variable x -> Polynomial Integer +--R +--R (122) 1 +--R Type: Polynomial Integer +--E 122 + +--S 123 of 216 integrate(a(x), x) +--R +--R +--R 1 2 +--R (123) - x +--R 2 +--R Type: Polynomial Fraction Integer +--E 123 + )clear properties a + + Compiled code for a has been cleared. -- The following two integrals should be equivalent. The correct solution is -- [(1 + x)^(3/2) + (1 - x)^(3/2)] / 3 +--S 124 of 216 integrate(x/(sqrt(1 + x) + sqrt(1 - x)), x) +--R +--R +--R +-----+ +-------+ +--R (x + 1)\|x + 1 + (- x + 1)\|- x + 1 +--R (124) ------------------------------------- +--R 3 +--R Type: Union(Expression Integer,...) +--E 124 + +--S 125 of 216 integrate((sqrt(1 + x) - sqrt(1 - x))/2, x) +--R +--R +--R +-----+ +-------+ +--R (x + 1)\|x + 1 + (- x + 1)\|- x + 1 +--R (125) ------------------------------------- +--R 3 +--R Type: Union(Expression Integer,...) +--E 125 + -- ---------- Definite Integrals ---------- -- The following two functions have a pole at zero +--S 126 of 216 integrate(1/x, x = -1..1) +--R +--R +--R >> Error detected within library code: +--R integrate: pole in path of integration +--R +--R Continuing to read the file... +--R +--E 126 + +--S 127 of 216 integrate(1/x**2, x = -1..1) +--R +--R +--R >> Error detected within library code: +--R integrate: pole in path of integration +--R +--R Continuing to read the file... +--R +--E 127 + -- Different branches of the square root need to be chosen in the intervals -- [0, 1] and [1, 2]. The correct results are 4/3, [4 - sqrt(8)]/3, -- [8 - sqrt(8)]/3, respectively. +--S 128 of 216 integrate(sqrt(x + 1/x - 2), x = 0..1) +--R +--R +--R (126) potentialPole +--R Type: Union(pole: potentialPole,...) +--E 128 + +--S 129 of 216 integrate(sqrt(x + 1/x - 2), x = 0..1, "noPole") +--R +--R +--R 4 +--R (127) - - +--R 3 +--R Type: Union(f1: OrderedCompletion Expression Integer,...) +--E 129 + +--S 130 of 216 integrate(sqrt(x + 1/x - 2), x = 1..2) +--R +--R +--R (128) potentialPole +--R Type: Union(pole: potentialPole,...) +--E 130 + +--S 131 of 216 integrate(sqrt(x + 1/x - 2), x = 1..2, "noPole") +--R +--R +--R +-+ +--R - 2\|2 + 4 +--R (129) ----------- +--R 3 +--R Type: Union(f1: OrderedCompletion Expression Integer,...) +--E 131 + +--S 132 of 216 integrate(sqrt(x + 1/x - 2), x = 0..2) +--R +--R +--R (130) potentialPole +--R Type: Union(pole: potentialPole,...) +--E 132 + +--S 133 of 216 integrate(sqrt(x + 1/x - 2), x = 0..2, "noPole") +--R +--R +--R +-+ +--R 2\|2 +--R (131) - ----- +--R 3 +--R Type: Union(f1: OrderedCompletion Expression Integer,...) +--E 133 + +)clear properties a + -- Contour integrals +--S 134 of 216 integrate(cos(x)/(x**2 + a**2), x = %minusInfinity..%plusInfinity) +--R +--R +--R (132) potentialPole +--R Type: Union(pole: potentialPole,...) +--E 134 + +--S 135 of 216 integrate(cos(x)/(x**2 + a**2), x = %minusInfinity..%plusInfinity, "noPole") +--R +--R +--R (133) "failed" +--R Type: Union(fail: failed,...) +--E 135 + -- Integrand with a branch point +--S 136 of 216 integrate(t**(a - 1)/(1 + t), t = 0..%plusInfinity) +--R +--R +--R (134) potentialPole +--R Type: Union(pole: potentialPole,...) +--E 136 + +--S 137 of 216 integrate(t**(a - 1)/(1 + t), t = 0..%plusInfinity, "noPole") +--R +--R +--R (135) "failed" +--R Type: Union(fail: failed,...) +--E 137 + -- Multiple integrals: volume of a tetrahedron +--S 138 of 216 integrate(integrate(integrate(1, z = 0..c*(1 - x/a - y/b)), _ y = 0..b*(1 - x/a)), _ x = 0..a) +--R +--R +--R a b c +--R (136) ----- +--R 6 +--R Type: Union(f1: OrderedCompletion Expression Integer,...) +--E 138 + -- ---------- Series ---------- -- Taylor series---this first example comes from special relativity +--S 139 of 216 1/sqrt(1 - (v/c)**2) +--R +--R +--R 1 +--R (137) ------------ +--R +---------+ +--R | 2 2 +--R |- v + c +--R |--------- +--R | 2 +--R \| c +--R Type: Expression Integer +--E 139 + +--S 140 of 216 series(%, v = 0) +--R +--R +--R 1 2 3 4 5 6 8 +--R (138) 1 + --- v + --- v + ---- v + O(v ) +--R 2 4 6 +--R 2c 8c 16c +--R Type: UnivariatePuiseuxSeries(Expression Integer,v,0) +--E 140 + +--S 141 of 216 1/%**2 +--R +--R +--R 1 2 8 +--R (139) 1 - -- v + O(v ) +--R 2 +--R c +--R Type: UnivariatePuiseuxSeries(Expression Integer,v,0) +--E 141 + +--S 142 of 216 tsin:= series(sin(x), x = 0) +--R +--R +--R 1 3 1 5 1 7 9 +--R (140) x - - x + --- x - ---- x + O(x ) +--R 6 120 5040 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 142 + +--S 143 of 216 tcos:= series(cos(x), x = 0) +--R +--R +--R 1 2 1 4 1 6 8 +--R (141) 1 - - x + -- x - --- x + O(x ) +--R 2 24 720 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 143 + -- Note that additional terms will be computed as needed +--S 144 of 216 tsin/tcos +--R +--R +--R 1 3 2 5 17 7 9 +--R (142) x + - x + -- x + --- x + O(x ) +--R 3 15 315 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 144 + +--S 145 of 216 series(tan(x), x = 0) +--R +--R +--R 1 3 2 5 17 7 9 +--R (143) x + - x + -- x + --- x + O(x ) +--R 3 15 315 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 145 + -- Look at the Taylor series around x = 1 )set streams calculate 1 + +--S 146 of 216 log(x)**a*exp(-b*x) +--R +--R +--R - b x a +--R (144) %e log(x) +--R Type: Expression Integer +--E 146 + +--S 147 of 216 series(%, x = 1) +--R +--R +--R >> Error detected within library code: +--R No series expansion +--R +--R Continuing to read the file... +--R +--E 147 + )set streams calculate 7 + -- Compare the Taylor series of two different formulations of a function +--S 148 of 216 taylor(log(sinh(z)) + log(cosh(z + w)), z = 0) +--R +--R +--R >> Error detected within library code: +--R No Taylor expansion: logarithmic singularity +--R +--R Continuing to read the file... +--R +--E 148 + +--S 149 of 216 % - taylor(log(sinh(z) * cosh(z + w)), z = 0) +--R +--R +--R >> Error detected within library code: +--R No Taylor expansion: logarithmic singularity +--R +--R Continuing to read the file... +--R +--E 149 + +--S 150 of 216 series(log(sinh(z)) + log(cosh(z + w)), z = 0) +--R +--R +--R (145) +--R w 2 w 2 w 4 w 2 +--R (%e ) + 1 (%e ) - 1 (%e ) + 14(%e ) + 1 2 +--R log(----------) + log(z) + ---------- z + ---------------------- z +--R w w 2 w 4 w 2 +--R 2%e (%e ) + 1 6(%e ) + 12(%e ) + 6 +--R + +--R w 4 w 2 +--R - 4(%e ) + 4(%e ) 3 +--R ------------------------------- z +--R w 6 w 4 w 2 +--R 3(%e ) + 9(%e ) + 9(%e ) + 3 +--R + +--R w 8 w 6 w 4 w 2 +--R - (%e ) + 116(%e ) - 486(%e ) + 116(%e ) - 1 4 +--R ---------------------------------------------------- z +--R w 8 w 6 w 4 w 2 +--R 180(%e ) + 720(%e ) + 1080(%e ) + 720(%e ) + 180 +--R + +--R w 8 w 6 w 4 w 2 +--R - 4(%e ) + 44(%e ) - 44(%e ) + 4(%e ) 5 +--R ------------------------------------------------------------ z +--R w 10 w 8 w 6 w 4 w 2 +--R 15(%e ) + 75(%e ) + 150(%e ) + 150(%e ) + 75(%e ) + 15 +--R + +--R w 12 w 10 w 8 w 6 w 4 +--R (%e ) + 258(%e ) - 6537(%e ) + 16652(%e ) - 6537(%e ) +--R + +--R w 2 +--R 258(%e ) + 1 +--R / +--R w 12 w 10 w 8 w 6 w 4 +--R 2835(%e ) + 17010(%e ) + 42525(%e ) + 56700(%e ) + 42525(%e ) +--R + +--R w 2 +--R 17010(%e ) + 2835 +--R * +--R 6 +--R z +--R + +--R w 12 w 10 w 8 w 6 w 4 w 2 +--R - 8(%e ) + 456(%e ) - 2416(%e ) + 2416(%e ) - 456(%e ) + 8(%e ) +--R / +--R w 14 w 12 w 10 w 8 w 6 +--R 315(%e ) + 2205(%e ) + 6615(%e ) + 11025(%e ) + 11025(%e ) +--R + +--R w 4 w 2 +--R 6615(%e ) + 2205(%e ) + 315 +--R * +--R 7 +--R z +--R + +--R 8 +--R O(z ) +--R Type: GeneralUnivariatePowerSeries(Expression Integer,z,0) +--E 150 + +--S 151 of 216 % - series(log(sinh(z) * cosh(z + w)), z = 0) +--R +--R +--R 15 +--R (146) O(z ) +--R Type: GeneralUnivariatePowerSeries(Expression Integer,z,0) +--E 151 + -- Power series (compute the general formula) +--S 152 of 216 log(sin(x)/x) +--R +--R +--R sin(x) +--R (147) log(------) +--R x +--R Type: Expression Integer +--E 152 + +--S 153 of 216 series(%, x = 0) +--R +--R +--R 1 2 1 4 1 6 1 8 10 +--R (148) - - x - --- x - ---- x - ----- x + O(x ) +--R 6 180 2835 37800 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 153 + +--S 154 of 216 exp(-x)*sin(x) +--R +--R +--R - x +--R (149) %e sin(x) +--R Type: Expression Integer +--E 154 + +--S 155 of 216 series(%, x = 0) +--R +--R +--R 2 1 3 1 5 1 6 1 7 9 +--R (150) x - x + - x - -- x + -- x - --- x + O(x ) +--R 3 30 90 630 +--R Type: UnivariatePuiseuxSeries(Expression Integer,x,0) +--E 155 + -- Derive an explicit Taylor series solution of y as a function of x from the -- following implicit relation +--S 156 of 216 y:= operator('y); +--R +--R +--R Type: BasicOperator +--E 156 + +--S 157 of 216 x = sin(y(x)) + cos(y(x)) +--R +--R +--R (152) x= sin(y(x)) + cos(y(x)) +--R Type: Equation Expression Integer +--E 157 + +--S 158 of 216 seriesSolve(%, y, x = 1, 0) +--R +--R +--R >> Error detected within library code: +--R Improper initial value +--R +--R Continuing to read the file... +--R +--E 158 + )clear properties y + -- Pade (rational function) approximation +--S 159 of 216 pade(1, 1, taylor(exp(-x), x = 0)) +--R +--R +--R - x + 2 +--R (153) ------- +--R x + 2 +--R Type: Union(Fraction UnivariatePolynomial(x,Expression Integer),...) +--E 159 + -- ---------- Transforms ---------- -- Laplace and inverse Laplace transforms +--S 160 of 216 laplace(cos((w - 1)*t), t, s) +--R +--R +--R s +--R (154) ---------------- +--R 2 2 +--R w - 2w + s + 1 +--R Type: Expression Integer +--E 160 + +--S 161 of 216 inverseLaplace(%, s, t) +--R +--R +--R +-----------+ +--R | 2 +--R (155) cos(t\|w - 2w + 1 ) +--R Type: Union(Expression Integer,...) +--E 161 + -- ---------- Difference and Differential Equations ---------- -- Second order linear recurrence equation +--S 162 of 216 r:= operator('r); +--R +--R +--R Type: BasicOperator +--E 162 + +--S 163 of 216 r(n + 2) - 2 * r(n + 1) + r(n) = 2 +--R +--R +--R (157) r(n + 2) - 2r(n + 1) + r(n)= 2 +--R Type: Equation Expression Integer +--E 163 + +--S 164 of 216 [%, r(0) = 1, r(1) = m] +--R +--R +--R (158) +--R [ +--R [[r(n + 2) - 2r(n + 1) + r(n),0,0], [0,r(n + 2) - 2r(n + 1) + r(n),0], +--R [0,0,r(n + 2) - 2r(n + 1) + r(n)]] +--R = +--R +2 0 0+ +--R | | +--R |0 2 0| +--R | | +--R +0 0 2+ +--R , +--R +r(0) 0 0 + +1 0 0+ +r(1) 0 0 + + 5 - 3 - 7+ +--R | | | | | | | | +--R | 0 r(0) 0 |= |0 1 0|, | 0 r(1) 0 |= |- 2 1 2 |] +--R | | | | | | | | +--R + 0 0 r(0)+ +0 0 1+ + 0 0 r(1)+ + 2 - 3 - 4+ +--R Type: List Equation SquareMatrix(3,Expression Integer) +--E 164 + )clear properties r + -- Second order ODE with initial conditions---solve first using Laplace -- transforms +--S 165 of 216 f:= operator('f); +--R +--R +--R Type: BasicOperator +--E 165 + +--S 166 of 216 ode:= D(f(t), t, 2) + 4*f(t) = sin(2*t) +--R +--R +--R ,, +--R (160) f (t) + 4f(t)= sin(2t) +--R +--R Type: Equation Expression Integer +--E 166 + +--S 167 of 216 map(e +-> laplace(e, t, s), %) +--R +--R +--R 2 , 2 +--R (161) (s + 4)laplace(f(t),t,s) - f (0) - f(0)s= ------ +--R 2 +--R s + 4 +--R Type: Equation Expression Integer +--E 167 + -- Now, solve the ODE directly +--S 168 of 216 solve(ode, f, t = 0, [0, 0]) +--R +--R +--R sin(2t) - 2t cos(2t) +--R (162) -------------------- +--R 8 +--R Type: Union(Expression Integer,...) +--E 168 + -- First order linear ODE +--S 169 of 216 y:= operator('y); +--R +--R +--R Type: BasicOperator +--E 169 + +--S 170 of 216 x**2 * D(y(x), x) + 3*x*y(x) = sin(x)/x +--R +--R +--R 2 , sin(x) +--R (164) x y (x) + 3x y(x)= ------ +--R x +--R Type: Equation Expression Integer +--E 170 + +--S 171 of 216 solve(%, y, x) +--R +--R +--R cos(x) 1 +--R (165) [particular= - ------,basis= [--]] +--R 3 3 +--R x x +--RType: Union(Record(particular: Expression Integer,basis: List Expression Integer),...) +--E 171 + -- Nonlinear ODE +--S 172 of 216 D(y(x), x, 2) + y(x)*D(y(x), x)**3 = 0 +--R +--R +--R ,, , 3 +--R (166) y (x) + y(x)y (x) = 0 +--R +--R Type: Equation Expression Integer +--E 172 + +--S 173 of 216 solve(%, y, x) +--R +--R +--R >> Error detected within library code: +--R getlincoeff: not an appropriate ordinary differential equation +--R +--R Continuing to read the file... +--R +--E 173 + -- A simple parametric ODE +--S 174 of 216 D(y(x, a), x) = a*y(x, a) +--R +--R +--R (167) y (x,a)= a y(x,a) +--R ,1 +--R Type: Equation Expression Integer +--E 174 + +--S 175 of 216 solve(%, y, x) +--R +--R +--R >> Error detected within library code: +--R parseODE: equation has order 0 +--R +--R Continuing to read the file... +--R +--E 175 + +--S 176 of 216 D(y(x), x) = a*y(x) +--R +--R +--R , +--R (168) y (x)= a y(x) +--R +--R Type: Equation Expression Integer +--E 176 + +--S 177 of 216 solve(%, y, x) +--R +--R +--R a x +--R (169) [particular= 0,basis= [%e ]] +--RType: Union(Record(particular: Expression Integer,basis: List Expression Integer),...) +--E 177 + -- ODE with boundary conditions. This problem has nontrivial solutions -- y(x) = A sin([pi/2 + n pi] x) for n an arbitrary integer. +--S 178 of 216 solve(D(y(x), x, 2) + k**2*y(x) = 0, y, x) +--R +--R +--R (170) [particular= 0,basis= [cos(k x),sin(k x)]] +--RType: Union(Record(particular: Expression Integer,basis: List Expression Integer),...) +--E 178 + -- bc(%, x = 0, y = 0, x = 1, D(y(x), x) = 0) -- System of two linear, constant coefficient ODEs +--S 179 of 216 x:= operator('x); +--R +--R +--R Type: BasicOperator +--E 179 + +--S 180 of 216 system:= [D(x(t), t) = x(t) - y(t), D(y(t), t) = x(t) + y(t)] +--R +--R +--R , , +--R (172) [x (t)= - y(t) + x(t),y (t)= y(t) + x(t)] +--R +--R Type: List Equation Expression Integer +--E 180 + +--S 181 of 216 solve(system,[x,y],t) +--R +--R +--R (173) +--R t t t t +--R [particular= [0,0],basis= [[cos(t)%e ,%e sin(t)],[%e sin(t),- cos(t)%e ]]] +--RType: Union(Record(particular: Vector Expression Integer,basis: List Vector Expression Integer),...) +--E 181 + -- Check the answer -- Triangular system of two ODEs +--S 182 of 216 system:= [D(x(t), t) = x(t) * (1 + cos(t)/(2 + sin(t))), _ D(y(t), t) = x(t) - y(t)] +--R +--R +--R , x(t)sin(t) + x(t)cos(t) + 2x(t) , +--R (174) [x (t)= -------------------------------,y (t)= - y(t) + x(t)] +--R sin(t) + 2 +--R Type: List Equation Expression Integer +--E 182 + -- Try solving this system one equation at a time +--S 183 of 216 solve(system.1, x, t) +--R +--R +--R t t +--R (175) [particular= 0,basis= [%e sin(t) + 2%e ]] +--RType: Union(Record(particular: Expression Integer,basis: List Expression Integer),...) +--E 183 + +--S 184 of 216 genericx:=C1*%.basis.1 +--R +--R +--R t t +--R (176) C1 %e sin(t) + 2C1 %e +--R Type: Expression Integer +--E 184 + +--S 185 of 216 eval(lhs rightZero system.2,x,genericx,t) +--R +--R Compiling function %DP with type Expression Integer -> Expression +--R Integer +--R +--R , t t +--R (177) y (t) - C1 %e sin(t) - 2C1 %e + y(t) +--R +--R Type: Expression Integer +--E 185 + +--S 186 of 216 solve(%,y,t) +--R +--R +--R (178) +--R - t t 2 - t t 2 +--R 2C1 %e (%e ) sin(t) + (- C1 cos(t) + 5C1)%e (%e ) +--R [particular= ------------------------------------------------------, +--R 5 +--R - t +--R basis= [%e ]] +--RType: Union(Record(particular: Expression Integer,basis: List Expression Integer),...) +--E 186 + +--S 187 of 216 genericy:=simplify (%.particular)+K1*(%.basis.1) +--R +--R +--R t t - t +--R 2C1 %e sin(t) + (- C1 cos(t) + 5C1)%e + 5K1 %e +--R (179) -------------------------------------------------- +--R 5 +--R Type: Expression Integer +--E 187 + +--S 188 of 216 eval(lhs rightZero system.1,x,genericx,t) +--R +--R Compiling function %DS with type Expression Integer -> Expression +--R Integer +--R +--R (180) 0 +--R Type: Expression Integer +--E 188 + +--S 189 of 216 eval(lhs rightZero system.2,[x,y],[genericx,genericy],t) +--R +--R Compiling function %DT with type Expression Integer -> Expression +--R Integer +--R Compiling function %DU with type Expression Integer -> Expression +--R Integer +--R +--R (181) 0 +--R Type: Expression Integer +--E 189 + )clear properties x y + -- ---------- Operators ---------- -- Linear differential operator +--S 190 of 216 DD:= operator("D") :: Operator(Expression Integer) +--R +--R +--R (182) D +--R Type: Operator Expression Integer +--E 190 + +--S 191 of 216 evaluate(DD, e +-> D(e, x))$Operator(Expression Integer) +--R +--R +--R (183) D +--R Type: Operator Expression Integer +--E 191 + +--S 192 of 216 L:= (DD - 1) * (DD + 2) +--R +--R +--R 2 +--R (184) D 2 + D - D - 2 +--R Type: Operator Expression Integer +--E 192 + +--S 193 of 216 g:= operator('g) +--R +--R +--R (185) g +--R Type: BasicOperator +--E 193 + +--S 194 of 216 L(f(x)) +--R +--R +--R ,, , +--R (186) f (x) + f (x) - 2f(x) +--R +--R Type: Expression Integer +--E 194 + +--S 195 of 216 subst(L(subst(g(y), y = x)), x = y) +--R +--R +--R ,, , +--R (187) g (y) + g (y) - 2g(y) +--R +--R Type: Expression Integer +--E 195 + +--S 196 of 216 subst(L(subst(A * sin(z**2), z = x)), x = z) +--R +--R +--R 2 2 2 +--R (188) (- 4A z - 2A)sin(z ) + (2A z + 2A)cos(z ) +--R Type: Expression Integer +--E 196 + -- Truncated Taylor series operator +--S 197 of 216 T:= (f, xx, a) +-> subst((DD**0)(f(x)), x = a)/factorial(0) * (xx - a)**0 + _ subst((DD**1)(f(x)), x = a)/factorial(1) * (xx - a)**1 + _ subst((DD**2)(f(x)), x = a)/factorial(2) * (xx - a)**2 +--R +--R +--R (189) +--R (f,xx,a) +--R +-> +--R 0 1 +--R subst(DD (f(x)),x= a) 0 subst(DD (f(x)),x= a) 1 +--R --------------------- (xx - a) + --------------------- (xx - a) +--R factorial(0) factorial(1) +--R + +--R 2 +--R subst(DD (f(x)),x= a) 2 +--R --------------------- (xx - a) +--R factorial(2) +--R Type: AnonymousFunction +--E 197 + +--S 198 of 216 T(f, x, a) +--R +--R +--R 2 2 ,, , +--R (x - 2a x + a )f (a) + (2x - 2a)f (a) + 2f(a) +--R +--R (190) ----------------------------------------------- +--R 2 +--R Type: Expression Integer +--E 198 + +--S 199 of 216 T(g, y, b) +--R +--R +--R 2 2 ,, , +--R (y - 2b y + b )g (b) + (2y - 2b)g (b) + 2g(b) +--R +--R (191) ----------------------------------------------- +--R 2 +--R Type: Expression Integer +--E 199 + +--S 200 of 216 Sin:= operator("sin") :: Operator(Expression Integer) +--R +--R +--R (192) sin +--R Type: Operator Expression Integer +--E 200 + +--S 201 of 216 evaluate(Sin, x +-> sin(x))$Operator(Expression Integer) +--R +--R +--R (193) sin +--R Type: Operator Expression Integer +--E 201 + +--S 202 of 216 T(Sin, z, c) +--R +--R +--R 2 2 +--R (- z + 2c z - c + 2)sin(c) + (2z - 2c)cos(c) +--R (194) ---------------------------------------------- +--R 2 +--R Type: Expression Integer +--E 202 + -- ---------- Programming ---------- -- Write a simple program to compute Legendre polynomials )clear properties p + +--S 203 of 216 p(n, x) == 1/(2**n*factorial(n)) * D((x**2 - 1)**n, x, n) +--R +--R Type: Void +--E 203 + +--S 204 of 216 for i in 0..4 repeat { output(""); output(concat(["p(", string(i), ", x) = "])); output(p(i, x))} +--R +--R Compiling function p with type (NonNegativeInteger,Variable x) -> +--R Polynomial Fraction Integer +--R +--R p(0, x) = +--R 1 +--R +--R p(1, x) = +--R x +--R +--R p(2, x) = +--R 3 2 1 +--R - x - - +--R 2 2 +--R +--R p(3, x) = +--R 5 3 3 +--R - x - - x +--R 2 2 +--R +--R p(4, x) = +--R 35 4 15 2 3 +--R -- x - -- x + - +--R 8 4 8 +--R Type: Void +--E 204 + +--S 205 of 216 eval(p(4, x), x = 1) +--R +--R Compiling function p with type (PositiveInteger,Variable x) -> +--R Polynomial Fraction Integer +--R +--R (197) 1 +--R Type: Polynomial Fraction Integer +--E 205 + -- Now, perform the same computation using a recursive definition +--S 206 of 216 pp(0, x) == 1 +--R +--R Type: Void +--E 206 + +--S 207 of 216 pp(1, x) == x +--R +--R Type: Void +--E 207 + +--S 208 of 216 pp(n, x) == ((2*n - 1)*x*pp(n - 1, x) - (n - 1)*pp(n - 2, x))/n +--R +--R Type: Void +--E 208 + +--S 209 of 216 for i in 0..4 repeat { output(""); output(concat(["pp(", string(i), ", x) = "])); output(pp(i, x))} +--R +--R Compiling function pp with type (Integer,Variable x) -> Polynomial +--R Fraction Integer +--R +--R pp(0, x) = +--R 1 +--R +--R pp(1, x) = +--R x +--R +--R pp(2, x) = +--R 3 2 1 +--R - x - - +--R 2 2 +--R +--R pp(3, x) = +--R 5 3 3 +--R - x - - x +--R 2 2 +--R +--R pp(4, x) = +--R 35 4 15 2 3 +--R -- x - -- x + - +--R 8 4 8 +--R Type: Void +--E 209 + )clear properties p pp + + Compiled code for p has been cleared. + Compiled code for pp has been cleared. -- ---------- Translation ---------- -- Horner's rule---this is important for numerical algorithms +--S 210 of 216 a:= operator('a) +--R +--R +--R (202) a +--R Type: BasicOperator +--E 210 + +--S 211 of 216 sum(a(i)*x**i, i = 1..5) +--R +--R +--R 5 4 3 2 +--R (203) a(5)x + a(4)x + a(3)x + a(2)x + a(1)x +--R Type: Expression Integer +--E 211 + +)clear properties p + +--S 212 of 216 p:= factor(%) +--R +--R +--R 5 4 3 2 +--R (204) a(5)x + a(4)x + a(3)x + a(2)x + a(1)x +--R Type: Factored Expression Integer +--E 212 + -- Convert the result into FORTRAN syntax )set fortran ints2floats off + +--S 213 of 216 outputAsFortran('p = p) +--R +--R p=a(5)*x**5+a(4)*x**4+a(3)*x**3+a(2)*x*x+a(1)*x +--R Type: Void +--E 213 + -- ---------- Boolean Logic ---------- -- Simplify logical expressions +--S 214 of 216 true and false +--R +--R +--R (206) false +--R Type: Boolean +--E 214 + +--S 215 of 216 x or (not x) ---x or y or (x and y) +--R +--R +--R Argument number 1 to "or" must be a Boolean. +--E 215 + +--S 216 of 216 +x or y or (x and y) +--R +--R +--R Argument number 1 to "or" must be a Boolean. +--E 216 + + +)spool + + +)lisp (bye) \end{chunk} \eject \begin{thebibliography}{99}