<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/math_ops.py#L5732-L5767) |

Computes element-wise square root of the input tensor.

#### View aliases


**Main aliases**

[`tf.sqrt`](https://www.tensorflow.org/api_docs/python/tf/math/sqrt)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.sqrt`](https://www.tensorflow.org/api_docs/python/tf/math/sqrt)

<br />

    tf.math.sqrt(
        x, name=None
    )

### Used in the notebooks

| Used in the guide | Used in the tutorials |
|---|---|
| - [Distributed training with Core APIs and DTensor](https://www.tensorflow.org/guide/core/distribution) - [Multilayer perceptrons for digit recognition with Core APIs](https://www.tensorflow.org/guide/core/mlp_core) - [Optimizers with Core APIs](https://www.tensorflow.org/guide/core/optimizers_core) | - [Uncertainty-aware Deep Learning with SNGP](https://www.tensorflow.org/tutorials/understanding/sngp) - [TFP Release Notes notebook (0.12.1)](https://www.tensorflow.org/probability/examples/TFP_Release_Notebook_0_12_1) - [Copulas Primer](https://www.tensorflow.org/probability/examples/Gaussian_Copula) - [Substantial Undocumented Infection Facilitates the Rapid Dissemination of Novel Coronavirus (SARS-CoV2)](https://www.tensorflow.org/probability/examples/Undocumented_Infection_and_the_Dissemination_of_SARS-CoV2) - [Neural machine translation with a Transformer and Keras](https://www.tensorflow.org/text/tutorials/transformer) |

> [!NOTE]
> **Note:** This operation does not support integer types.

    x = tf.constant([[4.0], [16.0]])
    tf.sqrt(x)
    <tf.Tensor: shape=(2, 1), dtype=float32, numpy=
      array([[2.],
             [4.]], dtype=float32)>
    y = tf.constant([[-4.0], [16.0]])
    tf.sqrt(y)
    <tf.Tensor: shape=(2, 1), dtype=float32, numpy=
      array([[nan],
             [ 4.]], dtype=float32)>
    z = tf.constant([[-1.0], [16.0]], dtype=tf.complex128)
    tf.sqrt(z)
    <tf.Tensor: shape=(2, 1), dtype=complex128, numpy=
      array([[0.0+1.j],
             [4.0+0.j]])>

> [!NOTE]
> **Note:** In order to support complex type, please provide an input tensor of `complex64` or `complex128`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of type `bfloat16`, `half`, `float32`, `float64`, `complex64`, `complex128` |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of same size, type and sparsity as `x`. <br /> If `x` is a `SparseTensor`, returns `SparseTensor(x.indices, tf.math.sqrt(x.values, ...), x.dense_shape)` ||

<br />