Average Error: 6.1 → 3.2
Time: 6.3s
Precision: binary64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.3241705954333267 \cdot 10^{+303}:\\ \;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\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) 1.3241705954333267e+303)
   (- (* x x) (* (* y 4.0) (- (* z z) t)))
   (- (* x x) (* (* (* y 4.0) (+ z (sqrt t))) (- z (sqrt t))))))
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) <= 1.3241705954333267e+303) {
		tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
	} else {
		tmp = (x * x) - (((y * 4.0) * (z + sqrt(t))) * (z - sqrt(t)));
	}
	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) <= 1.3241705954333267d+303) then
        tmp = (x * x) - ((y * 4.0d0) * ((z * z) - t))
    else
        tmp = (x * x) - (((y * 4.0d0) * (z + sqrt(t))) * (z - sqrt(t)))
    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) <= 1.3241705954333267e+303) {
		tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
	} else {
		tmp = (x * x) - (((y * 4.0) * (z + Math.sqrt(t))) * (z - Math.sqrt(t)));
	}
	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) <= 1.3241705954333267e+303:
		tmp = (x * x) - ((y * 4.0) * ((z * z) - t))
	else:
		tmp = (x * x) - (((y * 4.0) * (z + math.sqrt(t))) * (z - math.sqrt(t)))
	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) <= 1.3241705954333267e+303)
		tmp = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)));
	else
		tmp = Float64(Float64(x * x) - Float64(Float64(Float64(y * 4.0) * Float64(z + sqrt(t))) * Float64(z - sqrt(t))));
	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) <= 1.3241705954333267e+303)
		tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
	else
		tmp = (x * x) - (((y * 4.0) * (z + sqrt(t))) * (z - sqrt(t)));
	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], 1.3241705954333267e+303], N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(y * 4.0), $MachinePrecision] * N[(z + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z - N[Sqrt[t], $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 \cdot z \leq 1.3241705954333267 \cdot 10^{+303}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target6.1
Herbie3.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 (*.f64 z z) < 1.32417059543332672e303

    1. Initial program 0.1

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

    if 1.32417059543332672e303 < (*.f64 z z)

    1. Initial program 62.3

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Applied add-sqr-sqrt_binary6463.0

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - \color{blue}{\sqrt{t} \cdot \sqrt{t}}\right) \]
    3. Applied difference-of-squares_binary6463.0

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(\left(z + \sqrt{t}\right) \cdot \left(z - \sqrt{t}\right)\right)} \]
    4. Applied associate-*r*_binary6432.1

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

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

Reproduce

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