?

Average Accuracy: 90.5% → 99.7%
Time: 13.1s
Precision: binary64
Cost: 1097

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+122} \lor \neg \left(z \leq 3.1 \cdot 10^{+133}\right):\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(4 \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + \left(4 \cdot y\right) \cdot \left(t - z \cdot z\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 -6.5e+122) (not (<= z 3.1e+133)))
   (- (* x x) (* z (* z (* 4.0 y))))
   (+ (* x x) (* (* 4.0 y) (- t (* 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 <= -6.5e+122) || !(z <= 3.1e+133)) {
		tmp = (x * x) - (z * (z * (4.0 * y)));
	} else {
		tmp = (x * x) + ((4.0 * y) * (t - (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 <= (-6.5d+122)) .or. (.not. (z <= 3.1d+133))) then
        tmp = (x * x) - (z * (z * (4.0d0 * y)))
    else
        tmp = (x * x) + ((4.0d0 * y) * (t - (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 <= -6.5e+122) || !(z <= 3.1e+133)) {
		tmp = (x * x) - (z * (z * (4.0 * y)));
	} else {
		tmp = (x * x) + ((4.0 * y) * (t - (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 <= -6.5e+122) or not (z <= 3.1e+133):
		tmp = (x * x) - (z * (z * (4.0 * y)))
	else:
		tmp = (x * x) + ((4.0 * y) * (t - (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 <= -6.5e+122) || !(z <= 3.1e+133))
		tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(4.0 * y))));
	else
		tmp = Float64(Float64(x * x) + Float64(Float64(4.0 * y) * Float64(t - 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 <= -6.5e+122) || ~((z <= 3.1e+133)))
		tmp = (x * x) - (z * (z * (4.0 * y)));
	else
		tmp = (x * x) + ((4.0 * y) * (t - (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, -6.5e+122], N[Not[LessEqual[z, 3.1e+133]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(N[(4.0 * y), $MachinePrecision] * N[(t - N[(z * z), $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 -6.5 \cdot 10^{+122} \lor \neg \left(z \leq 3.1 \cdot 10^{+133}\right):\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(4 \cdot y\right)\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original90.5%
Target90.5%
Herbie99.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 z < -6.49999999999999963e122 or 3.1e133 < z

    1. Initial program 26.7%

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

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

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

      [Start]25.4

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

      *-commutative [=>]25.4

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

      unpow2 [=>]25.4

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

      *-commutative [=>]25.4

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

      associate-*r* [<=]25.4

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

      associate-*l* [=>]98.3

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

      *-commutative [=>]98.3

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

    if -6.49999999999999963e122 < z < 3.1e133

    1. Initial program 99.9%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

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

Alternatives

Alternative 1
Accuracy57.8%
Cost1112
\[\begin{array}{l} t_1 := -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ t_2 := 4 \cdot \left(y \cdot t\right)\\ \mathbf{if}\;x \leq -20.5:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 2
Accuracy57.3%
Cost1112
\[\begin{array}{l} t_1 := 4 \cdot \left(y \cdot t\right)\\ \mathbf{if}\;x \leq -10600:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-249}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-203}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-166}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 3
Accuracy75.9%
Cost1106
\[\begin{array}{l} \mathbf{if}\;x \leq -4.25 \cdot 10^{+68} \lor \neg \left(x \leq -4.2 \cdot 10^{+41} \lor \neg \left(x \leq -360000\right) \land x \leq 7.5 \cdot 10^{-10}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z - t\right) \cdot -4\right)\\ \end{array} \]
Alternative 4
Accuracy88.2%
Cost1100
\[\begin{array}{l} t_1 := x \cdot x - z \cdot \left(z \cdot \left(4 \cdot y\right)\right)\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-26}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+133}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z - t\right) \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy85.1%
Cost972
\[\begin{array}{l} t_1 := -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-26}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+133}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z - t\right) \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy59.4%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -990 \lor \neg \left(x \leq 1.08 \cdot 10^{-11}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 7
Accuracy34.4%
Cost192
\[x \cdot x \]

Error

Reproduce?

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