diff --git a/books/bookvol10.4.pamphlet b/books/bookvol10.4.pamphlet index 62d73be..a89816d 100644 --- a/books/bookvol10.4.pamphlet +++ b/books/bookvol10.4.pamphlet @@ -152427,6 +152427,211 @@ TranscendentalManipulations(R, F): Exports == Implementation where smplog p == map(logexpand, (r1:R):F +-> r1::F, p) smp2htrigs p == map((k1:K):F +-> htrigs(k1::F), (r1:R):F +-> r1::F, p) +\end{chunk} +\subsection{The htrigs function} +The htrigs function can be used to replace and reduce hyperbolic +trigonometric identities. + +The identity for $sinh(x)$ is $(exp(x) - exp(-x))/2$ + +If we difference these we should get zero +\begin{verbatim} + f := sinh(x) - (exp(x) - exp(-x))/2 +\end{verbatim} +instead, by default, we get +\begin{verbatim} + x -x + 2sinh(x) - %e + %e + --------------------- + 2 +\end{verbatim} +The function htrigs(f) gives 0 + +This works as follows: +\begin{verbatim} + m:=mainKernel f => sinh(x) + Type: Union(Kernel(Expression(Integer)),...) +\end{verbatim} +which is coerced to the first part of the union: +\begin{verbatim} + k:=m::Kernel(Expression(Integer)) +\end{verbatim} +and the operator is extracted: +\begin{verbatim} + op:=operator(k) => sinh + Type: BasicOperator +\end{verbatim} +The argument function extracts the variable used as arguments: +\begin{verbatim} + argument k ==> [x] + Type Kernel(Expression(Integer)) +\end{verbatim} +At this point we have picked apart the main Kernel into its +operator and its arguments. We now process the list of arguments. + +The function htrigs is called on every element of the argument list, +which in this case, returns a list: +\begin{verbatim} + arg:=[htrigs x for x in argument k]$List(Expression(Integer)) + => [x] + Type: List(Expression(Integer)) +\end{verbatim} +We form a polynomial by replacing the kernel in the numerator with ? +\begin{verbatim} + num := univariate(numer f, k) + + x -x + 2? - %e + %e + Type: SparseUnivariatePolynomial( + SparseMultivariatePolynomial( + Integer, Kernel(Expression(Integer)))) +\end{verbatim} +and a polynomial of the denominator, replacing the kernel +\begin{verbatim} + den := univariate(denom f, k) + + 2 + Type: SparseUnivariatePolynomial( + SparseMultivariatePolynomial( + Integer, Kernel(Expression(Integer)))) +\end{verbatim} +In this case the op is not the exponential so we are doing straight +trig substitution. We reconstruct the function call using the op +and arg values, that is: +\begin{verbatim} + g1 := op arg ==> sinh(x) + Type: Expression(Integer) +\end{verbatim} +So sup2htrigs, which is a local function, is used to simplify the +parts of the fraction. In this case, +\begin{verbatim} + sup2htrigs(num, g1:= op arg) ==> 0 + Type: Expression(Integer) + + sup2htrigs(den, g1) ==> 2 + Type: Expression(Integer) +\end{verbatim} +Thus, the result is 0 + +The identity for $cosh(x)$ is $(exp(x) + exp(-x))/2$ + +If we difference these we should get zero +\begin{verbatim} + f := cosh(x) - (%e^x + %e^-x)/2 +\end{verbatim} +instead, by default, we get +\begin{verbatim} + x - x + - %e + %e + 2cosh(x) + ------------------------- + 2 +\end{verbatim} +and the function call $htrigs(f)$ gives 0 + +This works as follows: +\begin{verbatim} + x + m:=mainKernel f => %e + Type: Union(Kernel(Expression(Integer)),...) +\end{verbatim} +which is coerced to the first part of the union: +\begin{verbatim} + x + k:=m::Kernel(Expression(Integer)) => %e + Type: Kernel(Expression(Integer)) +\end{verbatim} +and the operator is extracted: +\begin{verbatim} + op:=operator(k) => exp + Type: BasicOperator +\end{verbatim} +The argument function extracts the variable used as arguments: +\begin{verbatim} + argument k ==> [x] + Type Kernel(Expression(Integer)) +\end{verbatim} +At this point we have picked apart the main Kernel into its +operator and its arguments. We now process the list of arguments. + +The htrigs function +is called on every element of the argument list, which in this +case, returns a list: +\begin{verbatim} + arg:=[htrigs x for x in argument k]$List(Expression(Integer)) + => [x] + Type: List(Expression(Integer)) +\end{verbatim} +We form polynomial by replacing the kernel in the numerator with ? +\begin{verbatim} + num := univariate(numer f, k) + + - x + - ? - %e + 2cosh(x) + Type: SparseUnivariatePolynomial( + SparseMultivariatePolynomial( + Integer, Kernel(Expression(Integer)))) +\end{verbatim} +and a polynomial of the denominator, replacing the kernel +\begin{verbatim} + den := univariate(denom f, k) + + 2 + Type: SparseUnivariatePolynomial( + SparseMultivariatePolynomial( + Integer, Kernel(Expression(Integer)))) +\end{verbatim} +In this case, the expression +\begin{verbatim} + is?(op, "exp"::Symbol) => true +\end{verbatim} +so we form +\begin{verbatim} + a := first arg => x + Type: Expression(Integer) +\end{verbatim} +since we know that +\begin{verbatim} + x + cosh(x)+sinh(x) => %e +\end{verbatim} +we can form this use this expression in substitutions +\begin{verbatim} + g1 := cosh(a)+sinh(a) => sinh(x)+cosh(x) + Type: Expression(Integer) +\end{verbatim} +since we know that +\begin{verbatim} + - x + cosh(x)-sinh(x) => - %e +\end{verbatim} +we can form this use this expression in substitutions +\begin{verbatim} + g2 := cosh(a)-sinh(a) => -sinh(x)+cosh(x) + Type: Expression(Integer) + + b := (degree num)::Integer quo 2 => 0 + Type: NonNegativeInteger +\end{verbatim} +The supexp function is using the g1 and g2 identities to replace exp(x) +\begin{verbatim} + supexp(num,g1,g2,b) => sinh(x)-cosh(x)-sinh(x)+2cosh(x)-cosh(x) + Type: Expression(Integer) + + supexp(den,g1,g2,b) => 2 + Type: Expression(Integer) +\end{verbatim} +which is effectively +\begin{verbatim} + t1/t2 => (sinh(x)-cosh(x)-sinh(x)+2cosh(x)-cosh(x))/2 + Type: Expression(Integer) +\end{verbatim} +the last form of which can be rearranged as: +\begin{verbatim} + (sinh(x)-sinh(x) + 2cosh(x)-cosh(x)-cosh(x) )/2 => 0 +\end{verbatim} +so the result is 0 + +\begin{chunk}{package TRMANIP TranscendentalManipulations} htrigs f == (m := mainKernel f) case "failed" => f op := operator(k := m::K) diff --git a/changelog b/changelog index cb8dd8d..9b0d43c 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ +20130124 tpd src/axiom-website/patches.html 20130124.01.tpd.patch +20120124 tpd books/bookvol10.4 document htrigs function in TRMANIP 20130123 tpd src/axiom-website/patches.html 20130123.03.tpd.patch 20130123 tpd src/Makefile clean up src/algebra properly 20130123 tpd src/axiom-website/patches.html 20130123.02.tpd.patch diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 152948e..b6faeb7 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3955,5 +3955,7 @@ src/input/tree.regress added src/doc/endpaper fixed format 20130123.03.tpd.patch src/Makefile clean up src/algebra properly +20130124.01.tpd.patch +books/bookvol10.4 document htrigs function in TRMANIP