?

Average Error: 0.1 → 0.5
Time: 1.7min
Precision: binary64
Cost: 14152

?

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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Derivation?

  1. Split input into 2 regimes
  2. if x < -1.30000000000000006e66 or 1e-84 < 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.4

      \[\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 -1.30000000000000006e66 < x < 1e-84

    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(i, y, \mathsf{fma}\left(\log c, b + -0.5, \mathsf{fma}\left(\log y, x, z + t\right) + a\right)\right)} \]
      Proof
    3. Taylor expanded in x around 0 0.5

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

Alternatives

Alternative 1
Error0.1
Cost32832
\[\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b + -0.5, \mathsf{fma}\left(\log y, x, z + t\right) + a\right)\right) \]
Alternative 2
Error0.1
Cost14016
\[\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 \]
Alternative 3
Error11.0
Cost13632
\[\mathsf{fma}\left(i, y, \left(b - 0.5\right) \cdot \log c + \left(a + \left(t + z\right)\right)\right) \]
Alternative 4
Error37.4
Cost7772
\[\begin{array}{l} t_1 := \log c \cdot b + i \cdot y\\ t_2 := a + y \cdot i\\ t_3 := z + y \cdot i\\ \mathbf{if}\;a \leq -2.6 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.5 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.1 \cdot 10^{-233}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -5.8 \cdot 10^{-292}:\\ \;\;\;\;t + y \cdot i\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.38 \cdot 10^{-16}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.65 \cdot 10^{+88}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error11.0
Cost7360
\[\left(\left(b - 0.5\right) \cdot \log c + \left(a + \left(t + z\right)\right)\right) + y \cdot i \]
Alternative 6
Error37.9
Cost848
\[\begin{array}{l} t_1 := a + y \cdot i\\ t_2 := z + y \cdot i\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-139}:\\ \;\;\;\;t + y \cdot i\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+139}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error46.8
Cost720
\[\begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+163}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \leq 2 \cdot 10^{-219}:\\ \;\;\;\;y \cdot i\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{-18}:\\ \;\;\;\;t\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+90}:\\ \;\;\;\;y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 8
Error38.7
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -8.8 \cdot 10^{+224}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 3.9 \cdot 10^{+179}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error37.3
Cost584
\[\begin{array}{l} t_1 := a + y \cdot i\\ \mathbf{if}\;a \leq -1.15 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.2 \cdot 10^{+79}:\\ \;\;\;\;t + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error44.7
Cost328
\[\begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+114}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{+73}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 11
Error52.1
Cost64
\[a \]

Error

Reproduce?

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