Average Error: 0.1 → 0.2
Time: 29.5s
Precision: binary64
Cost: 14153
\[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i \]
\[\begin{array}{l} \mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\ \;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\ \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
(FPCore (x y z t a b c i)
 :precision binary64
 (if (or (<= x -21.0) (not (<= x 2.8e-24)))
   (+ (* y i) (+ (+ a (+ t (+ z (* x (log y))))) (* b (log c))))
   (fma y i (+ a (+ (* (log c) (+ b -0.5)) (+ z t))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((x <= -21.0) || !(x <= 2.8e-24)) {
		tmp = (y * i) + ((a + (t + (z + (x * log(y))))) + (b * log(c)));
	} else {
		tmp = fma(y, i, (a + ((log(c) * (b + -0.5)) + (z + t))));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i))
end
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if ((x <= -21.0) || !(x <= 2.8e-24))
		tmp = Float64(Float64(y * i) + Float64(Float64(a + Float64(t + Float64(z + Float64(x * log(y))))) + Float64(b * log(c))));
	else
		tmp = fma(y, i, Float64(a + Float64(Float64(log(c) * Float64(b + -0.5)) + Float64(z + t))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -21.0], N[Not[LessEqual[x, 2.8e-24]], $MachinePrecision]], N[(N[(y * i), $MachinePrecision] + N[(N[(a + N[(t + N[(z + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * i + N[(a + N[(N[(N[Log[c], $MachinePrecision] * N[(b + -0.5), $MachinePrecision]), $MachinePrecision] + N[(z + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\begin{array}{l}
\mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -21 or 2.8000000000000002e-24 < x

    1. Initial program 0.1

      \[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i \]
    2. Taylor expanded in b around inf 0.2

      \[\leadsto \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \color{blue}{\log c \cdot b}\right) + y \cdot i \]

    if -21 < x < 2.8000000000000002e-24

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(x, \log y, z\right) + \left(t + a\right)\right)\right)} \]
      Proof
      (fma.f64 y i (fma.f64 (+.f64 b -1/2) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (fma.f64 (+.f64 b (Rewrite<= metadata-eval (neg.f64 1/2))) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (fma.f64 (Rewrite<= sub-neg_binary64 (-.f64 b 1/2)) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (fma.f64 (-.f64 b 1/2) (log.f64 c) (+.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (log.f64 y)) z)) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (fma.f64 (-.f64 b 1/2) (log.f64 c) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 b 1/2) (log.f64 c)) (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 y i (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y i) (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))) (*.f64 y i))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around 0 0.1

      \[\leadsto \mathsf{fma}\left(y, i, \color{blue}{a + \left(\log c \cdot \left(b - 0.5\right) + \left(t + z\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\ \;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.1
Cost32832
\[\mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(x, \log y, z\right) + \left(t + a\right)\right)\right) \]
Alternative 2
Error0.1
Cost14016
\[\left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + \log c \cdot \left(b + -0.5\right)\right) + y \cdot i \]
Alternative 3
Error3.1
Cost13896
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{+22}:\\ \;\;\;\;a + \left(t_1 + \left(t + \left(z + b \cdot \log c\right)\right)\right)\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+147}:\\ \;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(t_1 + \left(a + \left(z + t\right)\right)\right)\\ \end{array} \]
Alternative 4
Error3.2
Cost13764
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{+22}:\\ \;\;\;\;a + \left(t_1 + \left(t + \left(z + b \cdot \log c\right)\right)\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+148}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(t + \left(z + a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(t_1 + \left(a + \left(z + t\right)\right)\right)\\ \end{array} \]
Alternative 5
Error19.3
Cost8033
\[\begin{array}{l} t_1 := y \cdot i + \left(z + a\right)\\ t_2 := x \cdot \log y + \left(a + \left(z + t\right)\right)\\ t_3 := y \cdot i + \left(a + b \cdot \log c\right)\\ \mathbf{if}\;b \leq -5.5 \cdot 10^{+195}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -1.95 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -6.5 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2 \cdot 10^{-173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+131}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 2.25 \cdot 10^{+192} \lor \neg \left(b \leq 1.6 \cdot 10^{+228}\right):\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;z + \log c \cdot \left(b + -0.5\right)\\ \end{array} \]
Alternative 6
Error19.5
Cost7768
\[\begin{array}{l} t_1 := y \cdot i + \left(z + a\right)\\ t_2 := x \cdot \log y + \left(a + \left(z + t\right)\right)\\ t_3 := z + \log c \cdot \left(b + -0.5\right)\\ \mathbf{if}\;b \leq -2.8 \cdot 10^{+187}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -2.25 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{-167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 8.2 \cdot 10^{+197}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error6.4
Cost7753
\[\begin{array}{l} t_1 := a + \left(z + t\right)\\ \mathbf{if}\;b + -0.5 \leq -4 \cdot 10^{+137} \lor \neg \left(b + -0.5 \leq 10^{+93}\right):\\ \;\;\;\;\log c \cdot \left(b + -0.5\right) + t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + t_1\right)\\ \end{array} \]
Alternative 8
Error14.2
Cost7632
\[\begin{array}{l} t_1 := a + \left(z + t\right)\\ t_2 := \log c \cdot \left(b + -0.5\right) + t_1\\ t_3 := x \cdot \log y + t_1\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{+22}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-271}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-208}:\\ \;\;\;\;y \cdot i + \left(z + a\right)\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+148}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 9
Error4.0
Cost7625
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+19} \lor \neg \left(x \leq 4.4 \cdot 10^{+147}\right):\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(t + \left(z + a\right)\right)\right)\\ \end{array} \]
Alternative 10
Error14.1
Cost7500
\[\begin{array}{l} t_1 := a + \left(z + t\right)\\ t_2 := x \cdot \log y + t_1\\ t_3 := \log c \cdot \left(b + -0.5\right)\\ \mathbf{if}\;x \leq -620000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-153}:\\ \;\;\;\;y \cdot i + \left(z + t_3\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+148}:\\ \;\;\;\;t_3 + t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error19.0
Cost7369
\[\begin{array}{l} \mathbf{if}\;b + -0.5 \leq -1 \cdot 10^{+163} \lor \neg \left(b + -0.5 \leq 5 \cdot 10^{+102}\right):\\ \;\;\;\;z + \log c \cdot \left(b + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;a + \left(t + \mathsf{fma}\left(y, i, z\right)\right)\\ \end{array} \]
Alternative 12
Error19.1
Cost7113
\[\begin{array}{l} \mathbf{if}\;b \leq -2.3 \cdot 10^{+194} \lor \neg \left(b \leq 3.1 \cdot 10^{+210}\right):\\ \;\;\;\;b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;a + \left(t + \mathsf{fma}\left(y, i, z\right)\right)\\ \end{array} \]
Alternative 13
Error19.2
Cost7112
\[\begin{array}{l} t_1 := b \cdot \log c\\ \mathbf{if}\;b \leq -3.2 \cdot 10^{+195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{+158}:\\ \;\;\;\;a + \left(t + \mathsf{fma}\left(y, i, z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_1\\ \end{array} \]
Alternative 14
Error19.1
Cost6857
\[\begin{array}{l} \mathbf{if}\;b \leq -1.06 \cdot 10^{+194} \lor \neg \left(b \leq 8.2 \cdot 10^{+210}\right):\\ \;\;\;\;b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(z + \left(t + a\right)\right)\\ \end{array} \]
Alternative 15
Error47.4
Cost588
\[\begin{array}{l} \mathbf{if}\;a \leq 1.75 \cdot 10^{-244}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \leq 3.45 \cdot 10^{-105}:\\ \;\;\;\;y \cdot i\\ \mathbf{elif}\;a \leq 1.55 \cdot 10^{+76}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;t + a\\ \end{array} \]
Alternative 16
Error31.2
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+139}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(t + a\right)\\ \end{array} \]
Alternative 17
Error23.3
Cost576
\[y \cdot i + \left(z + \left(t + a\right)\right) \]
Alternative 18
Error49.1
Cost460
\[\begin{array}{l} \mathbf{if}\;a \leq 1.75 \cdot 10^{-244}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \leq 2.25 \cdot 10^{-104}:\\ \;\;\;\;y \cdot i\\ \mathbf{elif}\;a \leq 2.05 \cdot 10^{+77}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 19
Error41.7
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+139}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 20
Error41.1
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+139}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 21
Error34.2
Cost448
\[y \cdot i + \left(z + a\right) \]
Alternative 22
Error48.6
Cost196
\[\begin{array}{l} \mathbf{if}\;z \leq -4.15 \cdot 10^{+139}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 23
Error52.4
Cost64
\[a \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y z t a b c i)
  :name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
  :precision binary64
  (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))