Repository: ivy-llc/ivy

Issue:
stable_pow



Discussion:

Resolving patch:
diff --git a/ivy/data_classes/array/general.py b/ivy/data_classes/array/general.py
--- a/ivy/data_classes/array/general.py
+++ b/ivy/data_classes/array/general.py
@@ -1091,6 +1091,22 @@ def stable_pow(
         -------
         ret
             The new item following the numerically stable power.
+
+        Examples
+        --------
+        With :class:`ivy.Array` instance method:
+
+        >>> x = ivy.asarray([2, 4])
+        >>> y = x.stable_pow(2)
+        >>> print(y)
+        ivy.array([ 4.00004, 16.00008])
+
+        >>> x = ivy.asarray([[2., 4.], [6., 8.]])
+        >>> y = ivy.asarray([2., 4.])
+        >>> z = x.stable_pow(y)
+        >>> print(z)
+        ivy.array([[4.00004000e+00, 2.56002560e+02],
+                [3.60001200e+01, 4.09602048e+03]])
         """
         return ivy.stable_pow(self, exponent, min_base=min_base)
 
diff --git a/ivy/data_classes/container/general.py b/ivy/data_classes/container/general.py
--- a/ivy/data_classes/container/general.py
+++ b/ivy/data_classes/container/general.py
@@ -1015,7 +1015,6 @@ def assert_supports_inplace(
         ret
             An ivy.Container instance of True bool values if nodes of the Container \
             support in-place operations, raises IvyBackendException otherwise
-
         Examples
         --------
 
@@ -3195,6 +3194,42 @@ def _static_stable_pow(
         ret
             A container of elements containing the new items following the
             numerically stable power.
+
+        Examples
+        --------
+        >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+        >>> y = ivy.Container.stable_pow(x, 2)
+        >>> print(y)
+        {
+            a: ivy.array([4.00004, 16.00008]),
+            b: ivy.array([36.00012, 64.00016])
+        }
+
+        >>> x = ivy.Container(a=4, b=8)
+        >>> y = ivy.Container.stable_pow(x, 2)
+        >>> print(y)
+        {
+            a: ivy.array(16.00008),
+            b: ivy.array(64.00016)
+        }
+
+        >>> x = ivy.Container(a=4, b=8)
+        >>> y = ivy.asarray([1, 2])
+        >>> z = ivy.Container.stable_pow(x, y)
+        >>> print(z)
+        {
+            a: ivy.array([4.00001, 16.00008]),
+            b: ivy.array([8.00001, 64.00016])
+        }
+
+        >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+        >>> y = ivy.Container(a=4, b=8)
+        >>> z = ivy.Container.stable_pow(x, y)
+        >>> print(z)
+        {
+            a: ivy.array([16.00032, 256.00256]),
+            b: ivy.array([1679638.395, 16777383.77])
+        }
         """
         return ContainerBase.cont_multi_map_in_function(
             "stable_pow",
@@ -3248,6 +3283,42 @@ def stable_pow(
         ret
             A container of elements containing the new items following the
             numerically stable power.
+
+        Examples
+        --------
+        >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+        >>> y = x.stable_pow(2)
+        >>> print(y)
+        {
+            a: ivy.array([4.00004, 16.00008]),
+            b: ivy.array([36.00012, 64.00016])
+        }
+
+        >>> x = ivy.Container(a=4, b=8)
+        >>> y = x.stable_pow(2)
+        >>> print(y)
+        {
+            a: ivy.array(16.00008),
+            b: ivy.array(64.00016)
+        }
+
+        >>> x = ivy.Container(a=4, b=8)
+        >>> y = ivy.asarray([1, 2])
+        >>> z = x.stable_pow(y)
+        >>> print(z)
+        {
+            a: ivy.array([4.00001, 16.00008]),
+            b: ivy.array([8.00001, 64.00016])
+        }
+
+        >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+        >>> y = ivy.Container(a=4, b=8)
+        >>> z = x.stable_pow(y)
+        >>> print(z)
+        {
+            a: ivy.array([16.00032, 256.00256]),
+            b: ivy.array([1679638.395, 16777383.77])
+        }
         """
         return self._static_stable_pow(
             self,
diff --git a/ivy/functional/ivy/general.py b/ivy/functional/ivy/general.py
--- a/ivy/functional/ivy/general.py
+++ b/ivy/functional/ivy/general.py
@@ -2303,6 +2303,64 @@ def stable_pow(
     -------
     ret
         The new item following the numerically stable power.
+
+    Examples
+    --------
+    With :code:`int` input:
+
+    >>> x = ivy.stable_pow(2, 2)
+    >>> print(x)
+    ivy.array(4.00004)
+
+    >>> x = ivy.stable_pow(2, 2, min_base=2)
+    >>> print(x)
+    ivy.array(16)
+
+    With float input:
+
+    >>> x = ivy.stable_pow(4.0, .5)
+    >>> print(x)
+    ivy.array(2.00000262)
+
+    With :code:`complex` input:
+
+    >>> x = ivy.stable_pow(3+4j, 2j)
+    >>> print(x)
+    ivy.array(-0.15605032-0.01208451j)
+
+    With :class:`ivy.Array` input:
+
+    >>> x = ivy.asarray([[2, 4],
+    ...                  [6, 8]])
+    >>> y = ivy.stable_pow(x, 2)
+    >>> print(y)
+    ivy.array([[ 4.00004, 16.00008],
+           [36.00012, 64.00016]])
+
+    >>> x = ivy.asarray([2, 4, 6])
+    >>> y = ivy.asarray([2, 3, 4])
+    >>> z = ivy.stable_pow(x, y)
+    >>> print(z)
+    ivy.array([   4.00004,   64.00048, 1296.00864])
+
+    With :class:`ivy.Container` input:
+
+    >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+    >>> y = ivy.stable_pow(x, 2)
+    >>> print(y)
+    {
+        a: ivy.array([4.00004, 16.00008]),
+        b: ivy.array([36.00012, 64.00016])
+    }
+
+    >>> x = ivy.Container(a=ivy.asarray([2, 4]), b=ivy.asarray([6, 8]))
+    >>> y = ivy.Container(a=ivy.asarray([1, 3]), b=ivy.asarray([4, 5]))
+    >>> z = ivy.stable_pow(x, y)
+    >>> print(z)
+    {
+        a: ivy.array([2.00001, 64.00048]),
+        b: ivy.array([1296.00864, 32768.2048])
+    }
     """
     return_dtype = ivy.promote_types(
         ivy.default_dtype(item=base),


Test patch: