Average Error: 5.7 → 0.2
Time: 14.3s
Precision: binary64
Cost: 1225
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+129} \lor \neg \left(z \leq 10^{+152}\right):\\ \;\;\;\;x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + 4 \cdot \left(y \cdot t - y \cdot \left(z \cdot z\right)\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -3.2e+129) (not (<= z 1e+152)))
   (+ (* x x) (* z (* z (* y -4.0))))
   (+ (* x x) (* 4.0 (- (* y t) (* y (* z z)))))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -3.2e+129) || !(z <= 1e+152)) {
		tmp = (x * x) + (z * (z * (y * -4.0)));
	} else {
		tmp = (x * x) + (4.0 * ((y * t) - (y * (z * z))));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * x) - ((y * 4.0d0) * ((z * z) - t))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z <= (-3.2d+129)) .or. (.not. (z <= 1d+152))) then
        tmp = (x * x) + (z * (z * (y * (-4.0d0))))
    else
        tmp = (x * x) + (4.0d0 * ((y * t) - (y * (z * z))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -3.2e+129) || !(z <= 1e+152)) {
		tmp = (x * x) + (z * (z * (y * -4.0)));
	} else {
		tmp = (x * x) + (4.0 * ((y * t) - (y * (z * z))));
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
def code(x, y, z, t):
	tmp = 0
	if (z <= -3.2e+129) or not (z <= 1e+152):
		tmp = (x * x) + (z * (z * (y * -4.0)))
	else:
		tmp = (x * x) + (4.0 * ((y * t) - (y * (z * z))))
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)))
end
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -3.2e+129) || !(z <= 1e+152))
		tmp = Float64(Float64(x * x) + Float64(z * Float64(z * Float64(y * -4.0))));
	else
		tmp = Float64(Float64(x * x) + Float64(4.0 * Float64(Float64(y * t) - Float64(y * Float64(z * z)))));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -3.2e+129) || ~((z <= 1e+152)))
		tmp = (x * x) + (z * (z * (y * -4.0)));
	else
		tmp = (x * x) + (4.0 * ((y * t) - (y * (z * z))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.2e+129], N[Not[LessEqual[z, 1e+152]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] + N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(4.0 * N[(N[(y * t), $MachinePrecision] - N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+129} \lor \neg \left(z \leq 10^{+152}\right):\\
\;\;\;\;x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x + 4 \cdot \left(y \cdot t - y \cdot \left(z \cdot z\right)\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.7
Target5.7
Herbie0.2
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation

  1. Split input into 2 regimes
  2. if z < -3.2000000000000002e129 or 1e152 < z

    1. Initial program 53.6

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Simplified53.8

      \[\leadsto \color{blue}{x \cdot x - y \cdot \left(4 \cdot \left(z \cdot z - t\right)\right)} \]
      Proof

      [Start]53.6

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

      associate-*l* [=>]53.8

      \[ x \cdot x - \color{blue}{y \cdot \left(4 \cdot \left(z \cdot z - t\right)\right)} \]
    3. Taylor expanded in z around inf 54.2

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(y \cdot {z}^{2}\right)} \]
    4. Simplified0.9

      \[\leadsto x \cdot x - \color{blue}{z \cdot \left(z \cdot \left(4 \cdot y\right)\right)} \]
      Proof

      [Start]54.2

      \[ x \cdot x - 4 \cdot \left(y \cdot {z}^{2}\right) \]

      *-commutative [=>]54.2

      \[ x \cdot x - \color{blue}{\left(y \cdot {z}^{2}\right) \cdot 4} \]

      *-commutative [=>]54.2

      \[ x \cdot x - \color{blue}{\left({z}^{2} \cdot y\right)} \cdot 4 \]

      unpow2 [=>]54.2

      \[ x \cdot x - \left(\color{blue}{\left(z \cdot z\right)} \cdot y\right) \cdot 4 \]

      associate-*r* [<=]54.2

      \[ x \cdot x - \color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot 4\right)} \]

      associate-*l* [=>]0.9

      \[ x \cdot x - \color{blue}{z \cdot \left(z \cdot \left(y \cdot 4\right)\right)} \]

      *-commutative [=>]0.9

      \[ x \cdot x - z \cdot \left(z \cdot \color{blue}{\left(4 \cdot y\right)}\right) \]

    if -3.2000000000000002e129 < z < 1e152

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Simplified0.1

      \[\leadsto \color{blue}{x \cdot x - y \cdot \left(4 \cdot \left(z \cdot z - t\right)\right)} \]
      Proof

      [Start]0.1

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

      associate-*l* [=>]0.1

      \[ x \cdot x - \color{blue}{y \cdot \left(4 \cdot \left(z \cdot z - t\right)\right)} \]
    3. Applied egg-rr0.1

      \[\leadsto x \cdot x - \color{blue}{\left(\left(z \cdot z\right) \cdot \left(y \cdot 4\right) + \left(-t\right) \cdot \left(y \cdot 4\right)\right)} \]
    4. Applied egg-rr0.1

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(z \cdot \left(z \cdot y\right) - y \cdot t\right)} \]
    5. Simplified0.1

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(y \cdot \left(z \cdot z\right) - y \cdot t\right)} \]
      Proof

      [Start]0.1

      \[ x \cdot x - 4 \cdot \left(z \cdot \left(z \cdot y\right) - y \cdot t\right) \]

      associate-*r* [=>]0.1

      \[ x \cdot x - 4 \cdot \left(\color{blue}{\left(z \cdot z\right) \cdot y} - y \cdot t\right) \]

      *-commutative [<=]0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+129} \lor \neg \left(z \leq 10^{+152}\right):\\ \;\;\;\;x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + 4 \cdot \left(y \cdot t - y \cdot \left(z \cdot z\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.5
Cost13952
\[x \cdot x + \left(y \cdot \left(4 \cdot t\right) - {\left(\sqrt[3]{z \cdot \left(z \cdot \left(y \cdot 4\right)\right)}\right)}^{3}\right) \]
Alternative 2
Error27.7
Cost1373
\[\begin{array}{l} t_1 := 4 \cdot \left(y \cdot t\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -2.2 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-115}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 10^{-220}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-192}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+27} \lor \neg \left(z \leq 5 \cdot 10^{+67}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 3
Error27.7
Cost1372
\[\begin{array}{l} t_1 := 4 \cdot \left(y \cdot t\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -1.16 \cdot 10^{-14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-115}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-221}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-192}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 1.06 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+27}:\\ \;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+68}:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error8.2
Cost1104
\[\begin{array}{l} t_1 := \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-48}:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error0.2
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+129} \lor \neg \left(z \leq 2 \cdot 10^{+152}\right):\\ \;\;\;\;x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \end{array} \]
Alternative 6
Error6.3
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-16} \lor \neg \left(z \leq 1.1 \cdot 10^{-43}\right):\\ \;\;\;\;x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \end{array} \]
Alternative 7
Error14.9
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -8500000000:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{+28}:\\ \;\;\;\;\left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 8
Error25.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-67}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-27}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 9
Error41.3
Cost192
\[x \cdot x \]

Error

Reproduce

herbie shell --seed 2023017 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))