?

Average Accuracy: 46.0% → 48.7%
Time: 13.3s
Precision: binary64
Cost: 1348

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+172}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(\left(t + \left(t - z \cdot z\right)\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\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 (<= (* z z) 1e+172)
   (+ (* x x) (* (* y 4.0) (- (+ t (- t (* z z))) t)))
   (* -4.0 (* z (* z y)))))
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 * z) <= 1e+172) {
		tmp = (x * x) + ((y * 4.0) * ((t + (t - (z * z))) - t));
	} else {
		tmp = -4.0 * (z * (z * y));
	}
	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 * z) <= 1d+172) then
        tmp = (x * x) + ((y * 4.0d0) * ((t + (t - (z * z))) - t))
    else
        tmp = (-4.0d0) * (z * (z * y))
    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 * z) <= 1e+172) {
		tmp = (x * x) + ((y * 4.0) * ((t + (t - (z * z))) - t));
	} else {
		tmp = -4.0 * (z * (z * y));
	}
	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 * z) <= 1e+172:
		tmp = (x * x) + ((y * 4.0) * ((t + (t - (z * z))) - t))
	else:
		tmp = -4.0 * (z * (z * y))
	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 (Float64(z * z) <= 1e+172)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(Float64(t + Float64(t - Float64(z * z))) - t)));
	else
		tmp = Float64(-4.0 * Float64(z * Float64(z * y)));
	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 * z) <= 1e+172)
		tmp = (x * x) + ((y * 4.0) * ((t + (t - (z * z))) - t));
	else
		tmp = -4.0 * (z * (z * y));
	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[LessEqual[N[(z * z), $MachinePrecision], 1e+172], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(N[(t + N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+172}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(\left(t + \left(t - z \cdot z\right)\right) - t\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original46.0%
Target46.0%
Herbie48.7%
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.0000000000000001e172

    1. Initial program 70.2%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Applied egg-rr70.2%

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(\left(z \cdot z - t\right) + \mathsf{fma}\left(-t, 1, t\right)\right)} \]
      Step-by-step derivation

      [Start]70.2

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

      add-sqr-sqrt [=>]70.2

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

      *-un-lft-identity [=>]70.2

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

      prod-diff [=>]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{z \cdot z}, \sqrt{z \cdot z}, -t \cdot 1\right) + \mathsf{fma}\left(-t, 1, t \cdot 1\right)\right)} \]

      *-commutative [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\mathsf{fma}\left(\sqrt{z \cdot z}, \sqrt{z \cdot z}, -\color{blue}{1 \cdot t}\right) + \mathsf{fma}\left(-t, 1, t \cdot 1\right)\right) \]

      *-un-lft-identity [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\mathsf{fma}\left(\sqrt{z \cdot z}, \sqrt{z \cdot z}, -\color{blue}{t}\right) + \mathsf{fma}\left(-t, 1, t \cdot 1\right)\right) \]

      fma-neg [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\color{blue}{\left(\sqrt{z \cdot z} \cdot \sqrt{z \cdot z} - t\right)} + \mathsf{fma}\left(-t, 1, t \cdot 1\right)\right) \]

      add-sqr-sqrt [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\left(\color{blue}{z \cdot z} - t\right) + \mathsf{fma}\left(-t, 1, t \cdot 1\right)\right) \]

      *-commutative [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\left(z \cdot z - t\right) + \mathsf{fma}\left(-t, 1, \color{blue}{1 \cdot t}\right)\right) \]

      *-un-lft-identity [<=]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\left(z \cdot z - t\right) + \mathsf{fma}\left(-t, 1, \color{blue}{t}\right)\right) \]
    3. Simplified70.2%

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(t + \left(\left(z \cdot z - t\right) - t\right)\right)} \]
      Step-by-step derivation

      [Start]70.2

      \[ x \cdot x - \left(y \cdot 4\right) \cdot \left(\left(z \cdot z - t\right) + \mathsf{fma}\left(-t, 1, t\right)\right) \]

      fma-udef [=>]70.2

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

      *-rgt-identity [=>]70.2

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

      associate-+r+ [=>]70.2

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

      +-commutative [=>]70.2

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

      unsub-neg [=>]70.2

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

    if 1.0000000000000001e172 < (*.f64 z z)

    1. Initial program 10.2%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Taylor expanded in z around inf 10.3%

      \[\leadsto \color{blue}{-4 \cdot \left(y \cdot {z}^{2}\right)} \]
    3. Simplified18.3%

      \[\leadsto \color{blue}{-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)} \]
      Step-by-step derivation

      [Start]10.3

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

      unpow2 [=>]10.3

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

      *-commutative [=>]10.3

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

      associate-*l* [=>]18.3

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

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

Alternatives

Alternative 1
Accuracy35.9%
Cost1740
\[\begin{array}{l} t_1 := z \cdot z - t\\ t_2 := -4 \cdot \left(y \cdot t_1\right)\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{-132}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
Alternative 2
Accuracy45.2%
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-142}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+128}:\\ \;\;\;\;-4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array} \]
Alternative 3
Accuracy44.1%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-142}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+304}:\\ \;\;\;\;-4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
Alternative 4
Accuracy48.7%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+172}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
Alternative 5
Accuracy29.6%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{+16}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-211}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-298}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-96}:\\ \;\;\;\;\left(y \cdot 4\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Accuracy26.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;t \leq -3 \cdot 10^{-57} \lor \neg \left(t \leq 520000000000\right):\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 7
Accuracy18.1%
Cost192
\[x \cdot x \]

Error

Reproduce?

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