?

Average Error: 2.0 → 0.2
Time: 13.8s
Precision: binary64
Cost: 1096

?

\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
\[\begin{array}{l} t_1 := \left(x + t \cdot a\right) + z \cdot \left(a \cdot b + y\right)\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.01:\\ \;\;\;\;\left(x + y \cdot z\right) + a \cdot \left(z \cdot b + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (* t a)) (* z (+ (* a b) y)))))
   (if (<= z -1.15e+58)
     t_1
     (if (<= z 0.01) (+ (+ x (* y z)) (* a (+ (* z b) t))) t_1))))
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 + (t * a)) + (z * ((a * b) + y));
	double tmp;
	if (z <= -1.15e+58) {
		tmp = t_1;
	} else if (z <= 0.01) {
		tmp = (x + (y * z)) + (a * ((z * b) + t));
	} else {
		tmp = t_1;
	}
	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 + (t * a)) + (z * ((a * b) + y))
    if (z <= (-1.15d+58)) then
        tmp = t_1
    else if (z <= 0.01d0) then
        tmp = (x + (y * z)) + (a * ((z * b) + t))
    else
        tmp = t_1
    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 + (t * a)) + (z * ((a * b) + y));
	double tmp;
	if (z <= -1.15e+58) {
		tmp = t_1;
	} else if (z <= 0.01) {
		tmp = (x + (y * z)) + (a * ((z * b) + t));
	} else {
		tmp = t_1;
	}
	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 + (t * a)) + (z * ((a * b) + y))
	tmp = 0
	if z <= -1.15e+58:
		tmp = t_1
	elif z <= 0.01:
		tmp = (x + (y * z)) + (a * ((z * b) + t))
	else:
		tmp = t_1
	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(Float64(x + Float64(t * a)) + Float64(z * Float64(Float64(a * b) + y)))
	tmp = 0.0
	if (z <= -1.15e+58)
		tmp = t_1;
	elseif (z <= 0.01)
		tmp = Float64(Float64(x + Float64(y * z)) + Float64(a * Float64(Float64(z * b) + t)));
	else
		tmp = t_1;
	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 + (t * a)) + (z * ((a * b) + y));
	tmp = 0.0;
	if (z <= -1.15e+58)
		tmp = t_1;
	elseif (z <= 0.01)
		tmp = (x + (y * z)) + (a * ((z * b) + t));
	else
		tmp = t_1;
	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[(N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(z * N[(N[(a * b), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e+58], t$95$1, If[LessEqual[z, 0.01], N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(z * b), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
t_1 := \left(x + t \cdot a\right) + z \cdot \left(a \cdot b + y\right)\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{+58}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 0.01:\\
\;\;\;\;\left(x + y \cdot z\right) + a \cdot \left(z \cdot b + t\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.0
Target0.5
Herbie0.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 2 regimes
  2. if z < -1.15000000000000001e58 or 0.0100000000000000002 < z

    1. Initial program 5.3

      \[\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 + t \cdot a\right) + z \cdot \left(a \cdot b + y\right)} \]
      Proof

      [Start]5.3

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

      rational_best-simplify-1 [=>]5.3

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

      rational_best-simplify-1 [=>]5.3

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

      rational_best-simplify-43 [=>]5.3

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

      rational_best-simplify-43 [=>]5.3

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

      rational_best-simplify-2 [=>]5.3

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

      rational_best-simplify-2 [=>]5.3

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

      rational_best-simplify-2 [=>]5.3

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

      rational_best-simplify-44 [=>]0.1

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

      rational_best-simplify-47 [=>]0.1

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

      rational_best-simplify-2 [=>]0.1

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

    if -1.15000000000000001e58 < z < 0.0100000000000000002

    1. Initial program 0.4

      \[\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]0.4

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

      rational_best-simplify-1 [=>]0.4

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

      rational_best-simplify-1 [=>]0.4

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

      rational_best-simplify-43 [=>]0.4

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

      rational_best-simplify-2 [=>]0.4

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

      rational_best-simplify-2 [=>]0.4

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

      rational_best-simplify-44 [=>]0.3

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

      rational_best-simplify-47 [=>]0.3

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

      rational_best-simplify-2 [=>]0.3

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

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

Alternatives

Alternative 1
Error23.6
Cost1504
\[\begin{array}{l} t_1 := z \cdot \left(a \cdot b + y\right)\\ t_2 := \left(t + b \cdot z\right) \cdot a\\ t_3 := z \cdot y + x\\ \mathbf{if}\;x \leq -7.8 \cdot 10^{-28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -6.4 \cdot 10^{-100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.12 \cdot 10^{-156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.18 \cdot 10^{-82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+14}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot a + x\\ \end{array} \]
Alternative 2
Error0.9
Cost1224
\[\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 -1 \cdot 10^{+104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 10^{-246}:\\ \;\;\;\;t_1 + a \cdot \left(z \cdot b + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error21.1
Cost1108
\[\begin{array}{l} t_1 := z \cdot y + x\\ t_2 := t \cdot a + x\\ \mathbf{if}\;t \leq -6.8 \cdot 10^{-35}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.8 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+157}:\\ \;\;\;\;b \cdot \left(z \cdot a\right) + x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error20.7
Cost1108
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;t \leq -9.5 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{-100}:\\ \;\;\;\;z \cdot y + x\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+14}:\\ \;\;\;\;z \cdot \left(a \cdot b\right) + x\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{+103}:\\ \;\;\;\;b \cdot \left(z \cdot a\right) + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error12.9
Cost1104
\[\begin{array}{l} t_1 := z \cdot \left(a \cdot b + y\right) + x\\ t_2 := \left(t + b \cdot z\right) \cdot a + x\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{-34}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 580000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+157}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error8.4
Cost1104
\[\begin{array}{l} t_1 := \left(x + y \cdot z\right) + t \cdot a\\ t_2 := z \cdot \left(a \cdot b + y\right) + x\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{-12}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-110}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error7.1
Cost968
\[\begin{array}{l} t_1 := \left(x + y \cdot z\right) + t \cdot a\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-47}:\\ \;\;\;\;\left(x + t \cdot a\right) + b \cdot \left(z \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error2.6
Cost964
\[\begin{array}{l} \mathbf{if}\;a \leq 1.15 \cdot 10^{+229}:\\ \;\;\;\;\left(x + t \cdot a\right) + z \cdot \left(a \cdot b + y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t + b \cdot z\right) \cdot a + x\\ \end{array} \]
Alternative 9
Error14.4
Cost840
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.3 \cdot 10^{+160}:\\ \;\;\;\;z \cdot \left(a \cdot b + y\right) + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error33.3
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-160}:\\ \;\;\;\;a \cdot t\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+67}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error24.8
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+195}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+247}:\\ \;\;\;\;t \cdot a + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 12
Error20.0
Cost584
\[\begin{array}{l} t_1 := t \cdot a + x\\ \mathbf{if}\;t \leq -1.3 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-51}:\\ \;\;\;\;z \cdot y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error33.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{+73}:\\ \;\;\;\;a \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error40.0
Cost64
\[x \]

Error

Reproduce?

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