Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ erfcx() [3/6]

template<typename T , require_all_kernel_expressions_and_none_scalar_t< T > * = nullptr>
var_value< matrix_cl< double > > stan::math::erfcx ( const var_value< T > &  A)
inline

Returns the elementwise erfcx() of a var_value<matrix_cl<double>>.

The derivative 2 * x * erfcx(x) - 2 / sqrt(pi) reuses the function value, so no second exp or erfc evaluation is needed. That difference cancels for x >= 4, where both terms approach 2 / sqrt(pi) while the result decays like 1 / (sqrt(pi) * x^2); the device function erfcx_derivative takes the derivative from the tail rational there instead. Without that the error reaches 2.55e+11 ulp at x = 1e6. The CPU implementation branches at the same point.

Parameters
Aargument
Returns
Elementwise erfcx() of the input.

Definition at line 28 of file erfcx.hpp.