?

Average Error: 0.17% → 0.81%
Time: 20.1s
Precision: binary64
Cost: 14152

?

\[ \begin{array}{c}[z, t, a] = \mathsf{sort}([z, t, a])\\ \end{array} \]
\[\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} t_1 := z + x \cdot \log y\\ t_2 := b \cdot \log c\\ \mathbf{if}\;x \leq -1 \cdot 10^{+79}:\\ \;\;\;\;y \cdot i + \left(\left(a + t_1\right) + t_2\right)\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-28}:\\ \;\;\;\;y \cdot i + \left(\left(z + t\right) + \mathsf{fma}\left(\log c, b + -0.5, a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\left(\left(t + t_1\right) + a\right) + t_2\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
 (let* ((t_1 (+ z (* x (log y)))) (t_2 (* b (log c))))
   (if (<= x -1e+79)
     (+ (* y i) (+ (+ a t_1) t_2))
     (if (<= x 3.2e-28)
       (+ (* y i) (+ (+ z t) (fma (log c) (+ b -0.5) a)))
       (+ (* y i) (+ (+ (+ t t_1) a) t_2))))))
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 t_1 = z + (x * log(y));
	double t_2 = b * log(c);
	double tmp;
	if (x <= -1e+79) {
		tmp = (y * i) + ((a + t_1) + t_2);
	} else if (x <= 3.2e-28) {
		tmp = (y * i) + ((z + t) + fma(log(c), (b + -0.5), a));
	} else {
		tmp = (y * i) + (((t + t_1) + a) + t_2);
	}
	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)
	t_1 = Float64(z + Float64(x * log(y)))
	t_2 = Float64(b * log(c))
	tmp = 0.0
	if (x <= -1e+79)
		tmp = Float64(Float64(y * i) + Float64(Float64(a + t_1) + t_2));
	elseif (x <= 3.2e-28)
		tmp = Float64(Float64(y * i) + Float64(Float64(z + t) + fma(log(c), Float64(b + -0.5), a)));
	else
		tmp = Float64(Float64(y * i) + Float64(Float64(Float64(t + t_1) + a) + t_2));
	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_] := Block[{t$95$1 = N[(z + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[Log[c], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e+79], N[(N[(y * i), $MachinePrecision] + N[(N[(a + t$95$1), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e-28], N[(N[(y * i), $MachinePrecision] + N[(N[(z + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b + -0.5), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * i), $MachinePrecision] + N[(N[(N[(t + t$95$1), $MachinePrecision] + a), $MachinePrecision] + t$95$2), $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}
t_1 := z + x \cdot \log y\\
t_2 := b \cdot \log c\\
\mathbf{if}\;x \leq -1 \cdot 10^{+79}:\\
\;\;\;\;y \cdot i + \left(\left(a + t_1\right) + t_2\right)\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-28}:\\
\;\;\;\;y \cdot i + \left(\left(z + t\right) + \mathsf{fma}\left(\log c, b + -0.5, a\right)\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot i + \left(\left(\left(t + t_1\right) + a\right) + t_2\right)\\


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if x < -9.99999999999999967e78

    1. Initial program 0.26

      \[\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.26

      \[\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 \]
    3. Taylor expanded in t around 0 0.6

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

    if -9.99999999999999967e78 < x < 3.19999999999999982e-28

    1. Initial program 0.11

      \[\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 x around 0 0.93

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

      \[\leadsto \color{blue}{\left(\left(t + z\right) + \mathsf{fma}\left(\log c, -0.5 + b, a\right)\right)} + y \cdot i \]
      Proof

      [Start]0.93

      \[ \left(\left(b - 0.5\right) \cdot \log c + \left(a + \left(t + z\right)\right)\right) + y \cdot i \]

      +-commutative [<=]0.93

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

      sub-neg [=>]0.93

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

      metadata-eval [=>]0.93

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

      associate-+r+ [=>]0.93

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

      +-commutative [=>]0.93

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

      +-commutative [=>]0.93

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

      *-commutative [=>]0.93

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

      metadata-eval [<=]0.93

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

      sub-neg [<=]0.93

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

      fma-def [=>]0.93

      \[ \left(\left(t + z\right) + \color{blue}{\mathsf{fma}\left(\log c, b - 0.5, a\right)}\right) + y \cdot i \]

      sub-neg [=>]0.93

      \[ \left(\left(t + z\right) + \mathsf{fma}\left(\log c, \color{blue}{b + \left(-0.5\right)}, a\right)\right) + y \cdot i \]

      metadata-eval [=>]0.93

      \[ \left(\left(t + z\right) + \mathsf{fma}\left(\log c, b + \color{blue}{-0.5}, a\right)\right) + y \cdot i \]

      +-commutative [=>]0.93

      \[ \left(\left(t + z\right) + \mathsf{fma}\left(\log c, \color{blue}{-0.5 + b}, a\right)\right) + y \cdot i \]

    if 3.19999999999999982e-28 < x

    1. Initial program 0.21

      \[\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.71

      \[\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 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.81

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+79}:\\ \;\;\;\;y \cdot i + \left(\left(a + \left(z + x \cdot \log y\right)\right) + b \cdot \log c\right)\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-28}:\\ \;\;\;\;y \cdot i + \left(\left(z + t\right) + \mathsf{fma}\left(\log c, b + -0.5, a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\left(\left(t + \left(z + x \cdot \log y\right)\right) + a\right) + b \cdot \log c\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.92%
Cost14025
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+79} \lor \neg \left(x \leq 3.2 \cdot 10^{-28}\right):\\ \;\;\;\;y \cdot i + \left(\left(a + \left(z + x \cdot \log y\right)\right) + b \cdot \log c\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\left(z + t\right) + \mathsf{fma}\left(\log c, b + -0.5, a\right)\right)\\ \end{array} \]
Alternative 2
Error0.17%
Cost14016
\[\left(\left(\left(t + \left(z + x \cdot \log y\right)\right) + a\right) + \left(b + -0.5\right) \cdot \log c\right) + y \cdot i \]
Alternative 3
Error6.31%
Cost13897
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+190} \lor \neg \left(x \leq 1.08 \cdot 10^{+82}\right):\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + \left(z + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \mathsf{fma}\left(\log c, b + -0.5, z + t\right)\right)\\ \end{array} \]
Alternative 4
Error6.28%
Cost7625
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+190} \lor \neg \left(x \leq 4.2 \cdot 10^{+85}\right):\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + \left(z + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\left(b + -0.5\right) \cdot \log c + \left(a + \left(z + t\right)\right)\right)\\ \end{array} \]
Alternative 5
Error28.68%
Cost7504
\[\begin{array}{l} t_1 := b \cdot \log c\\ t_2 := y \cdot i + \left(a + t_1\right)\\ t_3 := y \cdot i + \left(z + x \cdot \log y\right)\\ \mathbf{if}\;z \leq -8 \cdot 10^{+132}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+38}:\\ \;\;\;\;y \cdot i + \left(z + t_1\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error8.03%
Cost7497
\[\begin{array}{l} \mathbf{if}\;x \leq -1.16 \cdot 10^{+191} \lor \neg \left(x \leq 7.8 \cdot 10^{+88}\right):\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + \left(z + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(b \cdot \log c + \left(a + \left(z + t\right)\right)\right)\\ \end{array} \]
Alternative 7
Error11.42%
Cost7369
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+212} \lor \neg \left(x \leq 5.6 \cdot 10^{+195}\right):\\ \;\;\;\;y \cdot i + \left(z + x \cdot \log y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + b \cdot \log c\right)\right)\\ \end{array} \]
Alternative 8
Error8.54%
Cost7369
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+190} \lor \neg \left(x \leq 6.3 \cdot 10^{+86}\right):\\ \;\;\;\;y \cdot i + \left(x \cdot \log y + \left(z + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + b \cdot \log c\right)\right)\\ \end{array} \]
Alternative 9
Error27.07%
Cost7241
\[\begin{array}{l} \mathbf{if}\;b \leq -4.3 \cdot 10^{+144} \lor \neg \left(b \leq 1.6 \cdot 10^{+146}\right):\\ \;\;\;\;y \cdot i + \left(a + b \cdot \log c\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + t\right)\right)\\ \end{array} \]
Alternative 10
Error26.77%
Cost7240
\[\begin{array}{l} t_1 := b \cdot \log c\\ \mathbf{if}\;b \leq -9.5 \cdot 10^{+179}:\\ \;\;\;\;y \cdot i + \left(z + t_1\right)\\ \mathbf{elif}\;b \leq 1.92 \cdot 10^{+145}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + t_1\right)\\ \end{array} \]
Alternative 11
Error29.66%
Cost7113
\[\begin{array}{l} \mathbf{if}\;b \leq -2.9 \cdot 10^{+180} \lor \neg \left(b \leq 1.02 \cdot 10^{+187}\right):\\ \;\;\;\;y \cdot i + b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + t\right)\right)\\ \end{array} \]
Alternative 12
Error30.48%
Cost6857
\[\begin{array}{l} \mathbf{if}\;b \leq -2.3 \cdot 10^{+181} \lor \neg \left(b \leq 5.3 \cdot 10^{+186}\right):\\ \;\;\;\;b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \left(z + t\right)\right)\\ \end{array} \]
Alternative 13
Error46.23%
Cost717
\[\begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{+132} \lor \neg \left(z \leq -1.6 \cdot 10^{+111}\right) \land z \leq -7.6 \cdot 10^{+33}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 14
Error37.01%
Cost576
\[y \cdot i + \left(a + \left(z + t\right)\right) \]
Alternative 15
Error37.57%
Cost448
\[y \cdot i + \left(z + a\right) \]
Alternative 16
Error63.14%
Cost320
\[a + y \cdot i \]
Alternative 17
Error87.29%
Cost192
\[y \cdot i \]

Error

Reproduce?

herbie shell --seed 2023090 
(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)))