1 | initial version |
The apply_map method is a handy command for entrywise operations. For instance, let
A = matrix([[sin(x), cos(x)],[cos(x), -sin(x)]]); # define a matrix function of x
A
$$ \begin{pmatrix} \sin\left(x\right) & \cos\left(x\right) \\ \cos\left(x\right) & -\sin\left(x\right) \end{pmatrix}. $$
Let's compute the entrywise derivative
A.apply_map(lambda a : a.derivative(x))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} \cos\left(x\right) & -\sin\left(x\right) \\ -\sin\left(x\right) & -\cos\left(x\right) \end{array}\right), $$
and the Jordan canonical form
A.jordan_form()
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{r|r} -\sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} & 0 \\ \hline 0 & \sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} \end{array}\right) $$
Another small example, this time with symbolic functions:
var('x y')
m=2; n=4
# create a mxn matrix of symbolic functions in x and y
A = matrix([[function('f'+str(i)+str(j))(x, y) for j in [1..n]] for i in [1..m]]);
A
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} f_{11}\left(x, y\right) & f_{12}\left(x, y\right) & f_{13}\left(x, y\right) & f_{14}\left(x, y\right) \\ f_{21}\left(x, y\right) & f_{22}\left(x, y\right) & f_{23}\left(x, y\right) & f_{24}\left(x, y\right) \end{array}\right) $$
Now, let's ask for the entrywise integral with respect to $y$ of the 2nd derivative with respect to $x$:
A.apply_map(lambda a : (a.derivative(x, 2)).integrate(y))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} \int \frac{\partial^{2}}{(\partial x)^{2}}f_{11}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{12}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{13}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{14}\left(x, y\right)\,{d y} \\ \int \frac{\partial^{2}}{(\partial x)^{2}}f_{21}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{22}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{23}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{24}\left(x, y\right)\,{d y} \end{array}\right) $$
2 | No.2 Revision |
The apply_map method is a handy command for entrywise operations. For instance, let
A = matrix([[sin(x), cos(x)],[cos(x), -sin(x)]]); # define a matrix function of x
A
$$ \begin{pmatrix} \sin\left(x\right) & \cos\left(x\right) \\ \cos\left(x\right) & -\sin\left(x\right) \end{pmatrix}. $$
Let's compute the entrywise derivativederivative with apply_map
:
A.apply_map(lambda a : a.derivative(x))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} \cos\left(x\right) & -\sin\left(x\right) \\ -\sin\left(x\right) & -\cos\left(x\right) \end{array}\right), $$
and the Jordan canonical form
A.jordan_form()
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{r|r} -\sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} & 0 \\ \hline 0 & \sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} \end{array}\right) $$
Another small example, this time with symbolic functions:
var('x y')
m=2; n=4
# create a mxn matrix of symbolic functions in x and y
A = matrix([[function('f'+str(i)+str(j))(x, y) for j in [1..n]] for i in [1..m]]);
A
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} f_{11}\left(x, y\right) & f_{12}\left(x, y\right) & f_{13}\left(x, y\right) & f_{14}\left(x, y\right) \\ f_{21}\left(x, y\right) & f_{22}\left(x, y\right) & f_{23}\left(x, y\right) & f_{24}\left(x, y\right) \end{array}\right) $$
Now, let's ask for the entrywise integral with respect to $y$ of the 2nd derivative with respect to $x$:
A.apply_map(lambda a : (a.derivative(x, 2)).integrate(y))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} \int \frac{\partial^{2}}{(\partial x)^{2}}f_{11}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{12}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{13}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{14}\left(x, y\right)\,{d y} \\ \int \frac{\partial^{2}}{(\partial x)^{2}}f_{21}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{22}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{23}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{24}\left(x, y\right)\,{d y} \end{array}\right) $$
3 | No.3 Revision |
The apply_map method is a handy command for entrywise operations. For instance, let
A = matrix([[sin(x), cos(x)],[cos(x), -sin(x)]]); # define a matrix function of x
A
$$ \begin{pmatrix} \sin\left(x\right) & \cos\left(x\right) \\ \cos\left(x\right) & -\sin\left(x\right) \end{pmatrix}. $$
Let's compute the entrywise derivative with apply_map
:
A.apply_map(lambda a : a.derivative(x))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} \cos\left(x\right) & -\sin\left(x\right) \\ -\sin\left(x\right) & -\cos\left(x\right) \end{array}\right), $$
and the Jordan canonical form
A.jordan_form()
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{r|r} -\sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} & 0 \\ \hline 0 & \sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} \end{array}\right) $$
Another small example, this time with symbolic functions:
var('x y')
m=2; n=4
# create a mxn matrix of symbolic functions in x and y
A F = matrix([[function('f'+str(i)+str(j))(x, y) for j in [1..n]] for i in [1..m]]);
A
F
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} f_{11}\left(x, y\right) & f_{12}\left(x, y\right) & f_{13}\left(x, y\right) & f_{14}\left(x, y\right) \\ f_{21}\left(x, y\right) & f_{22}\left(x, y\right) & f_{23}\left(x, y\right) & f_{24}\left(x, y\right) \end{array}\right) $$
Now, let's ask for the entrywise integral with respect to $y$ of the 2nd derivative with respect to $x$:
A.apply_map(lambda a F.apply_map(lambda f : (a.derivative(x, (f.derivative(x, 2)).integrate(y))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} \int \frac{\partial^{2}}{(\partial x)^{2}}f_{11}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{12}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{13}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{14}\left(x, y\right)\,{d y} \\ \int \frac{\partial^{2}}{(\partial x)^{2}}f_{21}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{22}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{23}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{24}\left(x, y\right)\,{d y} \end{array}\right) $$
4 | No.4 Revision |
The apply_map method is a handy command for entrywise operations. For instance, let
A = matrix([[sin(x), cos(x)],[cos(x), -sin(x)]]); # define a matrix function of x
A
$$ \begin{pmatrix} \sin\left(x\right) & \cos\left(x\right) \\ \cos\left(x\right) & -\sin\left(x\right) \end{pmatrix}. $$
Let's compute the entrywise derivative with apply_map
:
A.apply_map(lambda a : a.derivative(x))
$$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} \cos\left(x\right) & -\sin\left(x\right) \\ -\sin\left(x\right) & -\cos\left(x\right) \end{array}\right), $$
and the Jordan canonical form
A.jordan_form()
$$
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{r|r}
-\sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}} & 0 \\
\hline
0 & \sqrt{\cos\left(x\right)^{2} + \sin\left(x\right)^{2}}
\end{array}\right)
\end{array}\right).
$$
Another small example, this time with symbolic functions:
var('x y')
m=2; n=4
# create a mxn matrix of symbolic functions in x and y
F = matrix([[function('f'+str(i)+str(j))(x, y) for j in [1..n]] for i in [1..m]]);
F
$$
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
f_{11}\left(x, y\right) & f_{12}\left(x, y\right) & f_{13}\left(x, y\right) & f_{14}\left(x, y\right) \\
f_{21}\left(x, y\right) & f_{22}\left(x, y\right) & f_{23}\left(x, y\right) & f_{24}\left(x, y\right)
\end{array}\right)
\end{array}\right).
$$
Now, let's ask for the entrywise integral with respect to $y$ of the 2nd derivative with respect to $x$:
F.apply_map(lambda f : (f.derivative(x, 2)).integrate(y))
$$
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
\int \frac{\partial^{2}}{(\partial x)^{2}}f_{11}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{12}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{13}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{14}\left(x, y\right)\,{d y} \\
\int \frac{\partial^{2}}{(\partial x)^{2}}f_{21}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{22}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{23}\left(x, y\right)\,{d y} & \int \frac{\partial^{2}}{(\partial x)^{2}}f_{24}\left(x, y\right)\,{d y}
\end{array}\right)
$$