Skip to content
class

AcosBackward

AcosBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for element-wise arccosine y=arccos⁡(x)y = \arccos(x).

Shares the radicand 1−x21 - x^2 with AsinBackward but with a negated sign in the derivative. Defined on [−1,1][-1, 1] with range [0,π][0, \pi]; the gradient is unbounded at x=±1x = \pm 1.

Math

\frac{\partial y}{\partial x} = -\frac{1}{\sqrt{1 - x^2}}, \qquad \frac{\partial \mathcal{L}}{\partial x} = -\frac{1}{\sqrt{1 - x^2}}\,\frac{\partial \mathcal{L}}{\partial y}.$$

Attributes

schema_v1OpSchema
Registered as "arccos" with AmpPolicy::Promote.

Notes

Dispatch: Accelerate vvacosf/vvacos (CPU) / MLX arccos (GPU).

Static methods

1
static

dispatch

int dispatch(backend::IBackend & be, const int & a, const int & s, Dtype dt)

Forward — calls IBackend::acos to compute y=arccos⁡xy = \arccos x.

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Backward — ∂y/∂x=−1/1−x2\partial y/\partial x = -1/\sqrt{1 - x^2}, scaled by grad_out.

fn

grad_formula_impl

int grad_formula_impl(const int & g, const int & x, const int &)

Graph-mode backward: the same derivative built from composable ops, so the gradient itself stays differentiable.