Average Error: 5.7 → 0
Time: 2.1s
Precision: 64
\[e^{\log a + \log b}\]
\[b \cdot a\]
e^{\log a + \log b}
b \cdot a
double code(double a, double b) {
	return exp((log(a) + log(b)));
}
double code(double a, double b) {
	return (b * a);
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.7
Target0
Herbie0
\[a \cdot b\]

Derivation

  1. Initial program 5.7

    \[e^{\log a + \log b}\]
  2. Using strategy rm
  3. Applied +-commutative5.7

    \[\leadsto e^{\color{blue}{\log b + \log a}}\]
  4. Applied exp-sum5.4

    \[\leadsto \color{blue}{e^{\log b} \cdot e^{\log a}}\]
  5. Simplified4.7

    \[\leadsto \color{blue}{b} \cdot e^{\log a}\]
  6. Simplified0

    \[\leadsto b \cdot \color{blue}{a}\]
  7. Final simplification0

    \[\leadsto b \cdot a\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(FPCore (a b)
  :name "Exp of sum of logs"
  :precision binary64

  :herbie-target
  (* a b)

  (exp (+ (log a) (log b))))