?

Average Error: 2.2 → 1.2
Time: 25.0s
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\\ \mathbf{if}\;a \leq -6.8 \cdot 10^{+112}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \mathbf{elif}\;a \leq 10^{-60}:\\ \;\;\;\;\left(t_1 + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1 + a \cdot \left(z \cdot b + t\right)\\ \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))))
   (if (<= a -6.8e+112)
     (+ (* (+ t (* b z)) a) x)
     (if (<= a 1e-60)
       (+ (+ t_1 (* t a)) (* (* a z) b))
       (+ t_1 (* a (+ (* z b) t)))))))
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 tmp;
	if (a <= -6.8e+112) {
		tmp = ((t + (b * z)) * a) + x;
	} else if (a <= 1e-60) {
		tmp = (t_1 + (t * a)) + ((a * z) * b);
	} else {
		tmp = t_1 + (a * ((z * b) + t));
	}
	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) :: tmp
    t_1 = x + (y * z)
    if (a <= (-6.8d+112)) then
        tmp = ((t + (b * z)) * a) + x
    else if (a <= 1d-60) then
        tmp = (t_1 + (t * a)) + ((a * z) * b)
    else
        tmp = t_1 + (a * ((z * b) + t))
    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 tmp;
	if (a <= -6.8e+112) {
		tmp = ((t + (b * z)) * a) + x;
	} else if (a <= 1e-60) {
		tmp = (t_1 + (t * a)) + ((a * z) * b);
	} else {
		tmp = t_1 + (a * ((z * b) + t));
	}
	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)
	tmp = 0
	if a <= -6.8e+112:
		tmp = ((t + (b * z)) * a) + x
	elif a <= 1e-60:
		tmp = (t_1 + (t * a)) + ((a * z) * b)
	else:
		tmp = t_1 + (a * ((z * b) + t))
	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))
	tmp = 0.0
	if (a <= -6.8e+112)
		tmp = Float64(Float64(Float64(t + Float64(b * z)) * a) + x);
	elseif (a <= 1e-60)
		tmp = Float64(Float64(t_1 + Float64(t * a)) + Float64(Float64(a * z) * b));
	else
		tmp = Float64(t_1 + Float64(a * Float64(Float64(z * b) + t)));
	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);
	tmp = 0.0;
	if (a <= -6.8e+112)
		tmp = ((t + (b * z)) * a) + x;
	elseif (a <= 1e-60)
		tmp = (t_1 + (t * a)) + ((a * z) * b);
	else
		tmp = t_1 + (a * ((z * b) + t));
	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]}, If[LessEqual[a, -6.8e+112], N[(N[(N[(t + N[(b * z), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 1e-60], N[(N[(t$95$1 + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(a * N[(N[(z * b), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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\\
\mathbf{if}\;a \leq -6.8 \cdot 10^{+112}:\\
\;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\

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

\mathbf{else}:\\
\;\;\;\;t_1 + a \cdot \left(z \cdot b + t\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.2
Target0.3
Herbie1.2
\[\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 3 regimes
  2. if a < -6.79999999999999987e112

    1. Initial program 9.8

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

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

      [Start]9.8

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

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

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

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

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

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

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

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

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

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

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

      rational.json-simplify-51 [=>]0.1

      \[ \left(x + y \cdot z\right) + \color{blue}{a \cdot \left(z \cdot b + t\right)} \]
    3. Taylor expanded in y around 0 5.9

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

    if -6.79999999999999987e112 < a < 9.9999999999999997e-61

    1. Initial program 0.7

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

    if 9.9999999999999997e-61 < a

    1. Initial program 3.5

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

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

      [Start]3.5

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

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

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

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

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

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

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

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

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

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

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

      rational.json-simplify-51 [=>]0.7

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

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

Alternatives

Alternative 1
Error23.2
Cost2296
\[\begin{array}{l} t_1 := z \cdot y + t \cdot a\\ t_2 := z \cdot y + x\\ t_3 := t \cdot a + x\\ t_4 := x + a \cdot \left(z \cdot b\right)\\ \mathbf{if}\;t \leq -8.8 \cdot 10^{+74}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{+26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.85 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.8 \cdot 10^{-246}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -1.82 \cdot 10^{-274}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-297}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 1.85 \cdot 10^{-44}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 125000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.05 \cdot 10^{+18}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.12 \cdot 10^{+54}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 10^{+98}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error34.0
Cost1380
\[\begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+70}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-14}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq -5.7 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-115}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-300}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-306}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-213}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-123}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-35}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error17.1
Cost1368
\[\begin{array}{l} t_1 := \left(t + b \cdot z\right) \cdot a + x\\ t_2 := z \cdot y + t \cdot a\\ \mathbf{if}\;x \leq -1.25 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-6}:\\ \;\;\;\;z \cdot \left(a \cdot b + y\right)\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-287}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-225}:\\ \;\;\;\;y \cdot z + z \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-68}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error9.9
Cost1100
\[\begin{array}{l} t_1 := x + y \cdot z\\ \mathbf{if}\;b \leq -2.5 \cdot 10^{+245}:\\ \;\;\;\;x + \left(z \cdot a\right) \cdot b\\ \mathbf{elif}\;b \leq -6.8 \cdot 10^{+78}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{+199}:\\ \;\;\;\;t_1 + t \cdot a\\ \mathbf{else}:\\ \;\;\;\;t_1 + a \cdot \left(z \cdot b\right)\\ \end{array} \]
Alternative 5
Error26.2
Cost980
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;z \leq -6000:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-44}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+201}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.8
Cost972
\[\begin{array}{l} t_1 := x + \left(z \cdot a\right) \cdot b\\ \mathbf{if}\;b \leq -1.8 \cdot 10^{+246}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{+77}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{+201}:\\ \;\;\;\;\left(x + y \cdot z\right) + t \cdot a\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error3.0
Cost964
\[\begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+250}:\\ \;\;\;\;x + \left(z \cdot a\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x + y \cdot z\right) + a \cdot \left(z \cdot b + t\right)\\ \end{array} \]
Alternative 8
Error20.2
Cost584
\[\begin{array}{l} t_1 := z \cdot y + x\\ \mathbf{if}\;z \leq -2.05 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-62}:\\ \;\;\;\;t \cdot a + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error20.4
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-64}:\\ \;\;\;\;z \cdot \left(a \cdot b + y\right)\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{-62}:\\ \;\;\;\;t \cdot a + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y + x\\ \end{array} \]
Alternative 10
Error33.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-45}:\\ \;\;\;\;t \cdot a\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error40.5
Cost64
\[x \]

Error

Reproduce?

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