?

Average Error: 2.1 → 0.8
Time: 20.7s
Precision: binary64
Cost: 1224

?

\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
\[\begin{array}{l} t_1 := x + y \cdot z\\ t_2 := \left(t_1 + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{if}\;b \leq -2.6 \cdot 10^{+104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-150}:\\ \;\;\;\;t_1 + a \cdot \left(z \cdot b + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ x (* y z))) (t_2 (+ (+ t_1 (* t a)) (* (* a z) b))))
   (if (<= b -2.6e+104)
     t_2
     (if (<= b 5e-150) (+ t_1 (* a (+ (* z b) t))) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double t_2 = (t_1 + (t * a)) + ((a * z) * b);
	double tmp;
	if (b <= -2.6e+104) {
		tmp = t_2;
	} else if (b <= 5e-150) {
		tmp = t_1 + (a * ((z * b) + t));
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x + (y * z)
    t_2 = (t_1 + (t * a)) + ((a * z) * b)
    if (b <= (-2.6d+104)) then
        tmp = t_2
    else if (b <= 5d-150) then
        tmp = t_1 + (a * ((z * b) + t))
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double t_2 = (t_1 + (t * a)) + ((a * z) * b);
	double tmp;
	if (b <= -2.6e+104) {
		tmp = t_2;
	} else if (b <= 5e-150) {
		tmp = t_1 + (a * ((z * b) + t));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return ((x + (y * z)) + (t * a)) + ((a * z) * b)
def code(x, y, z, t, a, b):
	t_1 = x + (y * z)
	t_2 = (t_1 + (t * a)) + ((a * z) * b)
	tmp = 0
	if b <= -2.6e+104:
		tmp = t_2
	elif b <= 5e-150:
		tmp = t_1 + (a * ((z * b) + t))
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(x + Float64(y * z))
	t_2 = Float64(Float64(t_1 + Float64(t * a)) + Float64(Float64(a * z) * b))
	tmp = 0.0
	if (b <= -2.6e+104)
		tmp = t_2;
	elseif (b <= 5e-150)
		tmp = Float64(t_1 + Float64(a * Float64(Float64(z * b) + t)));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b);
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x + (y * z);
	t_2 = (t_1 + (t * a)) + ((a * z) * b);
	tmp = 0.0;
	if (b <= -2.6e+104)
		tmp = t_2;
	elseif (b <= 5e-150)
		tmp = t_1 + (a * ((z * b) + t));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.6e+104], t$95$2, If[LessEqual[b, 5e-150], N[(t$95$1 + N[(a * N[(N[(z * b), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
t_1 := x + y \cdot z\\
t_2 := \left(t_1 + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;b \leq -2.6 \cdot 10^{+104}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;b \leq 5 \cdot 10^{-150}:\\
\;\;\;\;t_1 + a \cdot \left(z \cdot b + t\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target0.3
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;z < -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z < 4.7589743188364287 \cdot 10^{-122}:\\ \;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if b < -2.6e104 or 4.9999999999999999e-150 < b

    1. Initial program 1.2

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]

    if -2.6e104 < b < 4.9999999999999999e-150

    1. Initial program 2.9

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Simplified0.3

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

      [Start]2.9

      \[ \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]

      rational.json-simplify-1 [=>]2.9

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

      rational.json-simplify-41 [=>]2.9

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

      rational.json-simplify-2 [=>]2.9

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

      rational.json-simplify-2 [=>]2.9

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

      rational.json-simplify-43 [=>]0.3

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

      rational.json-simplify-2 [=>]0.3

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

      rational.json-simplify-47 [=>]0.3

      \[ \left(x + y \cdot z\right) + \color{blue}{a \cdot \left(z \cdot b + t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.6 \cdot 10^{+104}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-150}:\\ \;\;\;\;\left(x + y \cdot z\right) + a \cdot \left(z \cdot b + t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \end{array} \]

Alternatives

Alternative 1
Error22.3
Cost1768
\[\begin{array}{l} t_1 := z \cdot y + x\\ t_2 := z \cdot \left(a \cdot b + y\right)\\ t_3 := t \cdot a + x\\ \mathbf{if}\;t \leq -1.28 \cdot 10^{+103}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{-255}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-237}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{+89}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+123}:\\ \;\;\;\;a \cdot \left(z \cdot b + t\right)\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+212}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.8 \cdot 10^{+278}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;z \cdot y + t \cdot a\\ \end{array} \]
Alternative 2
Error22.3
Cost1636
\[\begin{array}{l} t_1 := z \cdot y + x\\ t_2 := z \cdot \left(a \cdot b + y\right)\\ t_3 := t \cdot a + x\\ \mathbf{if}\;t \leq -5.5 \cdot 10^{+106}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{-255}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-237}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.4 \cdot 10^{+86}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.2 \cdot 10^{+120}:\\ \;\;\;\;a \cdot \left(z \cdot b + t\right)\\ \mathbf{elif}\;t \leq 2 \cdot 10^{+166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+212}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error33.3
Cost1248
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.66 \cdot 10^{-237}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-291}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-284}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-249}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-161}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 1.52 \cdot 10^{-145}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-22}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error9.1
Cost1236
\[\begin{array}{l} t_1 := x + z \cdot \left(y + b \cdot a\right)\\ t_2 := \left(x + y \cdot z\right) + t \cdot a\\ \mathbf{if}\;y \leq -7 \cdot 10^{-57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.75 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-205}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-230}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-80}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error7.2
Cost968
\[\begin{array}{l} t_1 := \left(x + y \cdot z\right) + t \cdot a\\ \mathbf{if}\;y \leq -1.35 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-75}:\\ \;\;\;\;\left(x + t \cdot a\right) + \left(z \cdot a\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error2.3
Cost964
\[\begin{array}{l} \mathbf{if}\;z \leq 2.3 \cdot 10^{+176}:\\ \;\;\;\;\left(x + y \cdot z\right) + a \cdot \left(z \cdot b + t\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y + b \cdot a\right)\\ \end{array} \]
Alternative 7
Error32.9
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.55 \cdot 10^{-239}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-161}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-146}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-21}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error25.3
Cost848
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;y \leq -7.4 \cdot 10^{+251}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-12}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+155}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 9
Error20.6
Cost844
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;a \leq -1.15 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.08 \cdot 10^{-122}:\\ \;\;\;\;z \cdot y + x\\ \mathbf{elif}\;a \leq 2.8 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot b + t\right)\\ \end{array} \]
Alternative 10
Error14.4
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -6.5 \cdot 10^{+105}:\\ \;\;\;\;t \cdot a + x\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{+249}:\\ \;\;\;\;x + z \cdot \left(y + b \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot y + t \cdot a\\ \end{array} \]
Alternative 11
Error10.5
Cost840
\[\begin{array}{l} t_1 := \left(t + b \cdot z\right) \cdot a + x\\ \mathbf{if}\;a \leq -2.65 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.2 \cdot 10^{-118}:\\ \;\;\;\;x + z \cdot \left(y + b \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error21.9
Cost716
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;a \leq -1.7 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.9 \cdot 10^{-123}:\\ \;\;\;\;z \cdot y + x\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+155}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \end{array} \]
Alternative 13
Error32.7
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-29}:\\ \;\;\;\;t \cdot a\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error39.7
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (if (< z -11820553527347888000.0) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

  (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))