Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28494 views
License: GPL3
ubuntu2004
Function: mathouseholder
Section: linear_algebra
C-Name: mathouseholder
Prototype: GG
Help: mathouseholder(Q,v): applies a sequence Q of Householder transforms
 to the vector or matrix v.
Doc: \sidx{Householder transform}applies a sequence $Q$ of Householder
 transforms, as returned by \kbd{matqr}$(M,1)$ to the vector or matrix $v$.
 \bprog
 ? m = [2,1; 3,2]; \\ some random matrix
 ? [Q,R] = matqr(m);
 ? Q
 %3 =
 [-0.554... -0.832...]

 [-0.832... 0.554...]

 ? R
 %4 =
 [-3.605... -2.218...]

 [0         0.277...]

 ? v = [1, 2]~; \\ some random vector
 ? Q * v
 %6 = [-2.218..., 0.277...]~

 ? [q,r] = matqr(m, 1);
 ? exponent(r - R) \\ r is the same as R
 %8 = -128
 ? q \\ but q has a different structure
 %9 = [[0.0494..., [5.605..., 3]]]]
 ? mathouseholder(q, v) \\ applied to v
 %10 = [-2.218..., 0.277...]~
 @eprog\noindent The point of the Householder structure is that it efficiently
 represents the linear operator $v \mapsto Q \* v$ in a more stable way
 than expanding the matrix $Q$:
 \bprog
 ? m = mathilbert(20); v = vectorv(20,i,i^2+1);
 ? [Q,R] = matqr(m);
 ? [q,r] = matqr(m, 1);
 ? \p100
 ? [q2,r2] = matqr(m, 1); \\ recompute at higher accuracy
 ? exponent(R - r)
 %5 = -127
 ? exponent(R - r2)
 %6 = -127
 ? exponent(mathouseholder(q,v) - mathouseholder(q2,v))
 %7 = -119
 ? exponent(Q*v - mathouseholder(q2,v))
 %8 = 9
 @eprog\noindent We see that $R$ is OK with or without a flag to \kbd{matqr}
 but that multiplying by $Q$ is considerably less precise than applying the
 sequence of Householder transforms encoded by $q$.