({{, ROTG[a,b,c,s] 
computes a Givens rotation {c,s} for given scalars a and b.}})

OpenersNotesSection(Spacer1)Details

To use ROTG, you first need to load the BLAS Package using (RefLink[Needs, paclet:ref/Needs])["LinearAlgebra`BLAS`"].

The following arguments must be given:

ROTG[a,b,c,s] computes {c,s} such that {{c,s},{-(RefLink[Conjugate, paclet:ref/Conjugate])[s],c}.{a,b}=={r,0}, where the signed radius r is given by r==(RefLink[Sign, paclet:ref/Sign])[b](RefLink[Norm, paclet:ref/Norm])[{a,b}] if a==0 or a,b∈ℝ with (RefLink[Abs, paclet:ref/Abs])[a]≤(RefLink[Abs, paclet:ref/Abs])[b], and by r==(RefLink[Sign, paclet:ref/Sign])[a](RefLink[Norm, paclet:ref/Norm])[{a,b}] otherwise. In the degenerate case a==b==0, by convention c==1 and s==0.

The scalars c and s can be viewed as the cosine and sine, respectively, of the angle of rotation and satisfy the conditions c∈ℝ and (c^2)+(((RefLink[Abs, paclet:ref/Abs])[s])^2)==1.

The scalar a is set to r.  The scalar b is not modified if either a or b is complex.  Otherwise, b is set to the value z given by:

When given, the value z can be used to reconstruct c and s as follows:

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Load the BLAS package:

Needs["LinearAlgebra`BLAS`"]

Compute a Givens rotation for given scalars:

{a,b}={a0,b0}={2/3,4/5};
ROTG[a,b,c,s];
{c,s}

a==Sign[b0]Norm[{a0,b0}]

OpenersExampleSection1(Spacer1)Scope  (3)

Real values:

{a,b}={a0,b0}={2.3,-4.1};
ROTG[a,b,c,s];
{c,s}

a==Sign[b0]Norm[{a0,b0}]

Complex values:

{a,b}={a0,b0}={-2.+3.I,-2 I};
ROTG[a,b,c,s];
{c,s}

a==Sign[a0]Norm[{a0,b0}]

Note that c is real-valued even when the inputs are complex:

Im[c]

Arbitrary-precision values:

{a,b}={a0,b0}={2`20/3,-4`20/5};
ROTG[a,b,c,s];
{c,s}

a==Sign[b0]Norm[{a0,b0}]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

ROTG[a,b,c,s] satisfies the relation {{c,s},{-(RefLink[Conjugate, paclet:ref/Conjugate])[s],c}}.{a,b}={r,0} where r is the number saved in a:

{a,b}={a0,b0}=RandomComplex[{-1-I,1+I},{2}];
ROTG[a,b,c,s];
Chop[{{c,s},{-Conjugate[s],c}}.{a0,b0}]=={a,0}

The scalars c and s form a unit vector with c real:

c^2+Abs[s]^2==1

OpenersExampleSection4(Spacer1)Possible Issues  (2)

All arguments must be symbols:

ROTG[1,2,3,4]

ROTG[a,b,3,4]

The first and the second arguments are modified and must be initialized to scalars:

Clear[a,b];
ROTG[a,b,c,s]

{a,b}={1,3};
ROTG[a,b,c,s];
{a,b,c,s}

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Linear Algebra Subroutines, paclet:LowLevelLinearAlgebra/guide/BLASGuide])}})}})