pow applied to mixed variables
~~AD of pow<fvar<var>>(0, 0) causes NAN adjoint. pow<fvar<var>>(0, 0) and pow<var>(0, 0) both behave as expected.~~
Update
pow<var>(0, 0) should return NAN adjoint since the partials are undefined.
Steps to reproduce
stan::math::nested_rev_autodiff nested{};
stan::math::var t{0.0};
auto foo = stan::math::pow(t,0);
foo.grad();
assert(not std::isfinite(t.adj())); // fails
Current Version:
v4.7.0
I think this is correct, as the second derivative of pow(x, y) w.r.t. x:
$$ \frac{d^2}{dx^2}(x^y) = x^{(-2 + y)} \cdot (-1 + y) \cdot y $$
Is not defined when both x & y are 0
Ah I see, we handle this in the rev header by skipping the partials update. Thanks for catching this!
Yes exacly! It is handled for rev here. You are also right, the partials are undefined.
Actually, I think pow<var> is the issue. Check out my suggestion!
Covered as part of #3031