Average Error: 0.0 → 0.0
Time: 1.5s
Precision: binary64
\[\left(5 \leq a \land a \leq 10\right) \land \left(0 \leq b \land b \leq 0.001\right)\]
\[[a, b] = \mathsf{sort}([a, b]) \\]
\[\left(a + b\right) \cdot \left(a + b\right) \]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(2, a, b\right), a \cdot a\right)\right)\right) \]
\left(a + b\right) \cdot \left(a + b\right)
\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(2, a, b\right), a \cdot a\right)\right)\right)
(FPCore (a b) :precision binary64 (* (+ a b) (+ a b)))
(FPCore (a b)
 :precision binary64
 (log1p (expm1 (fma b (fma 2.0 a b) (* a a)))))
double code(double a, double b) {
	return (a + b) * (a + b);
}
double code(double a, double b) {
	return log1p(expm1(fma(b, fma(2.0, a, b), (a * a))));
}

Error

Bits error versus a

Bits error versus b

Target

Original0.0
Target0.0
Herbie0.0
\[\left(\left(b \cdot a + b \cdot b\right) + b \cdot a\right) + a \cdot a \]

Derivation

  1. Initial program 0.0

    \[\left(a + b\right) \cdot \left(a + b\right) \]
  2. Taylor expanded in a around 0 0.0

    \[\leadsto \color{blue}{2 \cdot \left(a \cdot b\right) + \left({a}^{2} + {b}^{2}\right)} \]
  3. Applied log1p-expm1-u_binary640.0

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(2 \cdot \left(a \cdot b\right) + \left({a}^{2} + {b}^{2}\right)\right)\right)} \]
  4. Simplified0.0

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(2, a, b\right), a \cdot a\right)\right)}\right) \]
  5. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(2, a, b\right), a \cdot a\right)\right)\right) \]

Reproduce

herbie shell --seed 2022081 
(FPCore (a b)
  :name "Expression 4, p15"
  :precision binary64
  :pre (and (and (<= 5.0 a) (<= a 10.0)) (and (<= 0.0 b) (<= b 0.001)))

  :herbie-target
  (+ (+ (+ (* b a) (* b b)) (* b a)) (* a a))

  (* (+ a b) (+ a b)))