Home > manopt > tools > dsqrtm.m

# dsqrtm

## PURPOSE

Fréchet derivative of the matrix square root.

## SYNOPSIS

function [D, fX] = dsqrtm(X, H)

## DESCRIPTION

``` Fréchet derivative of the matrix square root.

function [D, fX] = dsqrtm(X, H)

Computes the directional derivative (the Fréchet derivative) of sqrtm at
X along H (square matrices).

Thus, D = lim_(t -> 0) (sqrtm(X + tH) - sqrtm(X)) / t.

The second output is fX = sqrtm(X), though it may be less accurate.

Note: the adjoint of dsqrtm(X, .) is dsqrtm(X', .), which is a fact often
useful to derive gradients of matrix functions involving sqrtm(X).
(This is wrt the inner product inner = @(A, B) real(trace(A'*B))).

## CROSS-REFERENCE INFORMATION

This function calls:
• dfunm Fréchet derivative of matrix functions.
This function is called by:

## SOURCE CODE

```0001 function [D, fX] = dsqrtm(X, H)
0002 % Fréchet derivative of the matrix square root.
0003 %
0004 % function [D, fX] = dsqrtm(X, H)
0005 %
0006 % Computes the directional derivative (the Fréchet derivative) of sqrtm at
0007 % X along H (square matrices).
0008 %
0009 % Thus, D = lim_(t -> 0) (sqrtm(X + tH) - sqrtm(X)) / t.
0010 %
0011 % The second output is fX = sqrtm(X), though it may be less accurate.
0012 %
0013 % Note: the adjoint of dsqrtm(X, .) is dsqrtm(X', .), which is a fact often
0014 % useful to derive gradients of matrix functions involving sqrtm(X).
0015 % (This is wrt the inner product inner = @(A, B) real(trace(A'*B))).
0016 %
0018
0019 % This file is part of Manopt: www.manopt.org.
0020 % Original author: Nicolas Boumal, July 3, 2015.
0021 % Contributors:
0022 % Change log:
0023 %
0024 %   June 14, 2019 (NB): now also outputs sqrtm(X) as a by-product.
0025
0026     % Note: following Higham, 'Functions of Matrices', 2008, page 58: this
0027     % could also be computed as fX = sqrtm(X), then solving the Sylvester
0028     % equation fX*D + D*fX = H, e.g. via , D = sylvester(fX, fX, H).
0029     % If X has special structure (e.g., if it is symmetric or Hermitian),
0030     % then this may be faster and more accurate. This should be tested
0031     % before considering a replacement.
0032
0033     [D, fX] = dfunm(@sqrtm, X, H);
0034
0035 end```

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005