1C> \ingroup wfn1
2C> @{
3C>
4C> \brief Fit a parabola given two points and a gradient
5C>
6C> Given \f$(0)\f$,
7C> \f$\left.\frac{\partial f(x)}{\partial x}\right|_{x=0}\f$,
8C> and \f$f(x_1)\f$ find the parabola \f$f(x)=ax^2+bx+c\f$ matching this
9C> data, and predict its minimum.
10C>
11      subroutine wfn1_f0df0f1(x1,f0,df0,f1,t,a,b,c,xm,fxm)
12      implicit none
13c
14      double precision, intent(in)  :: x1  !< \f$x_1\f$
15      double precision, intent(in)  :: f0  !< \f$f(0)\f$
16      double precision, intent(in)  :: df0 !< \f$\left.\frac{df(x)}{dx}\right|_{x=0}\f$
17      double precision, intent(in)  :: f1  !< \f$f(x_1)\f$
18      double precision, intent(in)  :: t   !< The trust region ensuring
19                                           !< that \f$-t\le xm \le t\f$
20      double precision, intent(out) :: a   !< The coefficient of \f$x^2\f$
21      double precision, intent(out) :: b   !< The coefficient of \f$x\f$
22      double precision, intent(out) :: c   !< The coefficient of \f$x^0\f$
23      double precision, intent(out) :: xm  !< The value of \f$x\f$ that
24                                           !< minimizes \f$f(x)\f$
25      double precision, intent(out) :: fxm !< The value of \f$f(xm)\f$
26c
27      double precision f
28      f(xm) = a*xm*xm+b*xm+c
29c
30      c = f0
31      b = df0
32      a = (f1-f0-x1*df0)/(x1*x1)
33c
34      if (a.gt.0.0d0) then
35        xm = -b/(2.0d0*a)
36      else
37c
38c       the function has no minimum
39c
40        if (df0.lt.0.0d0) then
41          xm = t
42        else
43          xm = -t
44        endif
45      endif
46      fxm = f(xm)
47c
48      end
49
50C> @}
51
52