Average Error: 0.3 → 0.3
Time: 11.0s
Precision: 64
\[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t\]
\[\mathsf{fma}\left(\log t, a - 0.5, \log \left(x + y\right)\right) + \left(\log z - t\right)\]
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\mathsf{fma}\left(\log t, a - 0.5, \log \left(x + y\right)\right) + \left(\log z - t\right)
double f(double x, double y, double z, double t, double a) {
        double r301495 = x;
        double r301496 = y;
        double r301497 = r301495 + r301496;
        double r301498 = log(r301497);
        double r301499 = z;
        double r301500 = log(r301499);
        double r301501 = r301498 + r301500;
        double r301502 = t;
        double r301503 = r301501 - r301502;
        double r301504 = a;
        double r301505 = 0.5;
        double r301506 = r301504 - r301505;
        double r301507 = log(r301502);
        double r301508 = r301506 * r301507;
        double r301509 = r301503 + r301508;
        return r301509;
}

double f(double x, double y, double z, double t, double a) {
        double r301510 = t;
        double r301511 = log(r301510);
        double r301512 = a;
        double r301513 = 0.5;
        double r301514 = r301512 - r301513;
        double r301515 = x;
        double r301516 = y;
        double r301517 = r301515 + r301516;
        double r301518 = log(r301517);
        double r301519 = fma(r301511, r301514, r301518);
        double r301520 = z;
        double r301521 = log(r301520);
        double r301522 = r301521 - r301510;
        double r301523 = r301519 + r301522;
        return r301523;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original0.3
Target0.3
Herbie0.3
\[\log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right)\]

Derivation

  1. Initial program 0.3

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t\]
  2. Simplified0.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, a - 0.5, \left(\log \left(x + y\right) + \log z\right) - t\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.3

    \[\leadsto \color{blue}{\log t \cdot \left(a - 0.5\right) + \left(\left(\log \left(x + y\right) + \log z\right) - t\right)}\]
  5. Using strategy rm
  6. Applied associate--l+0.3

    \[\leadsto \log t \cdot \left(a - 0.5\right) + \color{blue}{\left(\log \left(x + y\right) + \left(\log z - t\right)\right)}\]
  7. Applied associate-+r+0.3

    \[\leadsto \color{blue}{\left(\log t \cdot \left(a - 0.5\right) + \log \left(x + y\right)\right) + \left(\log z - t\right)}\]
  8. Simplified0.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, a - 0.5, \log \left(x + y\right)\right)} + \left(\log z - t\right)\]
  9. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(\log t, a - 0.5, \log \left(x + y\right)\right) + \left(\log z - t\right)\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z t a)
  :name "Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (+ (log (+ x y)) (+ (- (log z) t) (* (- a 0.5) (log t))))

  (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))