benchmarks.wiki / Public workspace

SciCode / 29.3 / With the previous functions, provide a function that performs Gram-Schmidt…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

step background

Background The Gram-Schmidt orthogonalization is defined as $$ \begin{aligned} & \varepsilon_1=\alpha_1, \\ & \varepsilon_2=\alpha_2-\frac{\left(\alpha_2, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1, \\ & \varepsilon_3=\alpha_3-\frac{\left(\alpha_3, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1-\frac{\left(\alpha_3, \varepsilon_2\right)}{\left(\varepsilon_2, \varepsilon_2\right)} \varepsilon_2, \\ & \ldots \ldots \ldots \ldots \\ & \varepsilon_{\mathrm{i}+1}=\alpha_{\mathrm{i}+1}-\sum_{\mathrm{k}=1}^{\mathrm{i}} \frac{\left(\alpha_{\mathrm{i}+1}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}} \\ & \ldots \ldots \ldots \ldots \ldots \\ & \varepsilon_{\mathrm{n}}=\alpha_{\mathrm{n}}-\sum_{\mathrm{k}=1}^{n-1} \frac{\left(\alpha_{\mathrm{n}}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}} \end{aligned} $$ and this function wants to not only do the orthogonalization but also the normalization for all the vectors.
Plain-text mathematical notation (without MathML)
Background
The Gram-Schmidt orthogonalization is defined as

$$
\begin{aligned}
& \varepsilon_1=\alpha_1, \\
& \varepsilon_2=\alpha_2-\frac{\left(\alpha_2, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1, \\
& \varepsilon_3=\alpha_3-\frac{\left(\alpha_3, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1-\frac{\left(\alpha_3, \varepsilon_2\right)}{\left(\varepsilon_2, \varepsilon_2\right)} \varepsilon_2, \\
& \ldots \ldots \ldots \ldots \\
& \varepsilon_{\mathrm{i}+1}=\alpha_{\mathrm{i}+1}-\sum_{\mathrm{k}=1}^{\mathrm{i}} \frac{\left(\alpha_{\mathrm{i}+1}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}} \\
& \ldots \ldots \ldots \ldots \ldots \\
& \varepsilon_{\mathrm{n}}=\alpha_{\mathrm{n}}-\sum_{\mathrm{k}=1}^{n-1} \frac{\left(\alpha_{\mathrm{n}}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}}
\end{aligned}
$$

and this function wants to not only do the orthogonalization but also the normalization for all the vectors.
Original LaTeX notation
Background
The Gram-Schmidt orthogonalization is defined as

$$
\begin{aligned}
& \varepsilon_1=\alpha_1, \\
& \varepsilon_2=\alpha_2-\frac{\left(\alpha_2, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1, \\
& \varepsilon_3=\alpha_3-\frac{\left(\alpha_3, \varepsilon_1\right)}{\left(\varepsilon_1, \varepsilon_1\right)} \varepsilon_1-\frac{\left(\alpha_3, \varepsilon_2\right)}{\left(\varepsilon_2, \varepsilon_2\right)} \varepsilon_2, \\
& \ldots \ldots \ldots \ldots \\
& \varepsilon_{\mathrm{i}+1}=\alpha_{\mathrm{i}+1}-\sum_{\mathrm{k}=1}^{\mathrm{i}} \frac{\left(\alpha_{\mathrm{i}+1}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}} \\
& \ldots \ldots \ldots \ldots \ldots \\
& \varepsilon_{\mathrm{n}}=\alpha_{\mathrm{n}}-\sum_{\mathrm{k}=1}^{n-1} \frac{\left(\alpha_{\mathrm{n}}, \varepsilon_{\mathrm{k}}\right)}{\left(\varepsilon_{\mathrm{k}}, \varepsilon_{\mathrm{k}}\right)} \varepsilon_{\mathrm{k}}
\end{aligned}
$$

and this function wants to not only do the orthogonalization but also the normalization for all the vectors.

step description prompt

With the previous functions, provide a function that performs Gram-Schmidt orthogonalization on N linearly independent vectors in N-dimension space. The input is an N×NN\times N numpy array, containing N vectors in the shape of N×1N\times1. The output should also be an N×NN\times N numpy array, containing the orthogonal and normalized vectors.
Plain-text mathematical notation (without MathML)
With the previous functions, provide a function that performs Gram-Schmidt orthogonalization on N linearly independent vectors in N-dimension space. The input is an N×N numpy array, containing N vectors in the shape of N×1. The output should also be an N×N numpy array, containing the orthogonal and normalized vectors.
Original LaTeX notation
With the previous functions, provide a function that performs Gram-Schmidt orthogonalization on N linearly independent vectors in N-dimension space. The input is an $N\times N$ numpy array, containing N vectors in the shape of $N\times1$. The output should also be an $N\times N$ numpy array, containing the orthogonal and normalized vectors.

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import