?

Average Error: 5.9 → 0.4
Time: 11.4s
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 -1.3 \cdot 10^{+154} \lor \neg \left(z \leq 5.8 \cdot 10^{+89}\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 -1.3e+154) (not (<= z 5.8e+89)))
   (- (* 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 <= -1.3e+154) || !(z <= 5.8e+89)) {
		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 <= (-1.3d+154)) .or. (.not. (z <= 5.8d+89))) 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 <= -1.3e+154) || !(z <= 5.8e+89)) {
		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 <= -1.3e+154) or not (z <= 5.8e+89):
		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 <= -1.3e+154) || !(z <= 5.8e+89))
		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 <= -1.3e+154) || ~((z <= 5.8e+89)))
		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, -1.3e+154], N[Not[LessEqual[z, 5.8e+89]], $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 -1.3 \cdot 10^{+154} \lor \neg \left(z \leq 5.8 \cdot 10^{+89}\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

Original5.9
Target5.9
Herbie0.4
\[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 < -1.29999999999999994e154 or 5.80000000000000051e89 < z

    1. Initial program 43.3

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

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

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

      [Start]45.5

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

      associate-*r* [=>]45.5

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

      unpow2 [=>]45.5

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

      *-commutative [<=]45.5

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

      *-commutative [=>]45.5

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

      associate-*l* [=>]2.4

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

      *-commutative [=>]2.4

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

    if -1.29999999999999994e154 < z < 5.80000000000000051e89

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+154} \lor \neg \left(z \leq 5.8 \cdot 10^{+89}\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
Error8.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-107}:\\ \;\;\;\;x \cdot x + \left(4 \cdot y\right) \cdot t\\ \mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+288}:\\ \;\;\;\;y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \]
Alternative 2
Error27.2
Cost976
\[\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 -5.8 \cdot 10^{-25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-280}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{-195}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error6.5
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-19} \lor \neg \left(z \leq 1.65 \cdot 10^{-34}\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 t\\ \end{array} \]
Alternative 4
Error15.1
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -16500000000 \lor \neg \left(x \leq 9.8 \cdot 10^{-17}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(4 \cdot y\right) \cdot \left(t - z \cdot z\right)\\ \end{array} \]
Alternative 5
Error15.1
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -7400000000:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Error25.7
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -19000000000 \lor \neg \left(x \leq 6.8 \cdot 10^{-46}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 7
Error41.6
Cost192
\[x \cdot x \]

Error

Reproduce?

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