1 #ifndef STAN_MATH_FWD_SCAL_FUN_INV_PHI_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_INV_PHI_HPP
3 
4 #include <stan/math/fwd/core.hpp>
5 
6 #include <stan/math/prim/scal/fun/inv_Phi.hpp>
7 #include <stan/math/prim/scal/fun/constants.hpp>
8 #include <stan/math/prim/scal/fun/square.hpp>
9 
10 namespace stan {
11 namespace math {
12 
13 template <typename T>
inv_Phi(const fvar<T> & p)14 inline fvar<T> inv_Phi(const fvar<T>& p) {
15   using std::exp;
16   T xv = inv_Phi(p.val_);
17   return fvar<T>(xv, p.d_ / exp(-0.5 * square(xv)) * SQRT_2_TIMES_SQRT_PI);
18 }
19 }  // namespace math
20 }  // namespace stan
21 #endif
22