?

Average Accuracy: 90.9% → 85.8%
Time: 11.9s
Precision: binary64
Cost: 1744

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} t_1 := x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ t_2 := 4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{if}\;x \cdot x \leq 5.6 \cdot 10^{-68}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 1.85 \cdot 10^{+37}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 3.8 \cdot 10^{+264}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x x) (* z (* z (* y 4.0)))))
        (t_2 (* 4.0 (* y (- t (* z z))))))
   (if (<= (* x x) 5.6e-68)
     t_2
     (if (<= (* x x) 5e-5)
       t_1
       (if (<= (* x x) 1.85e+37)
         t_2
         (if (<= (* x x) 3.8e+264) t_1 (* x x)))))))
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 t_1 = (x * x) - (z * (z * (y * 4.0)));
	double t_2 = 4.0 * (y * (t - (z * z)));
	double tmp;
	if ((x * x) <= 5.6e-68) {
		tmp = t_2;
	} else if ((x * x) <= 5e-5) {
		tmp = t_1;
	} else if ((x * x) <= 1.85e+37) {
		tmp = t_2;
	} else if ((x * x) <= 3.8e+264) {
		tmp = t_1;
	} else {
		tmp = x * x;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (x * x) - (z * (z * (y * 4.0d0)))
    t_2 = 4.0d0 * (y * (t - (z * z)))
    if ((x * x) <= 5.6d-68) then
        tmp = t_2
    else if ((x * x) <= 5d-5) then
        tmp = t_1
    else if ((x * x) <= 1.85d+37) then
        tmp = t_2
    else if ((x * x) <= 3.8d+264) then
        tmp = t_1
    else
        tmp = x * x
    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 t_1 = (x * x) - (z * (z * (y * 4.0)));
	double t_2 = 4.0 * (y * (t - (z * z)));
	double tmp;
	if ((x * x) <= 5.6e-68) {
		tmp = t_2;
	} else if ((x * x) <= 5e-5) {
		tmp = t_1;
	} else if ((x * x) <= 1.85e+37) {
		tmp = t_2;
	} else if ((x * x) <= 3.8e+264) {
		tmp = t_1;
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
def code(x, y, z, t):
	t_1 = (x * x) - (z * (z * (y * 4.0)))
	t_2 = 4.0 * (y * (t - (z * z)))
	tmp = 0
	if (x * x) <= 5.6e-68:
		tmp = t_2
	elif (x * x) <= 5e-5:
		tmp = t_1
	elif (x * x) <= 1.85e+37:
		tmp = t_2
	elif (x * x) <= 3.8e+264:
		tmp = t_1
	else:
		tmp = x * x
	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)
	t_1 = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0))))
	t_2 = Float64(4.0 * Float64(y * Float64(t - Float64(z * z))))
	tmp = 0.0
	if (Float64(x * x) <= 5.6e-68)
		tmp = t_2;
	elseif (Float64(x * x) <= 5e-5)
		tmp = t_1;
	elseif (Float64(x * x) <= 1.85e+37)
		tmp = t_2;
	elseif (Float64(x * x) <= 3.8e+264)
		tmp = t_1;
	else
		tmp = Float64(x * x);
	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)
	t_1 = (x * x) - (z * (z * (y * 4.0)));
	t_2 = 4.0 * (y * (t - (z * z)));
	tmp = 0.0;
	if ((x * x) <= 5.6e-68)
		tmp = t_2;
	elseif ((x * x) <= 5e-5)
		tmp = t_1;
	elseif ((x * x) <= 1.85e+37)
		tmp = t_2;
	elseif ((x * x) <= 3.8e+264)
		tmp = t_1;
	else
		tmp = x * x;
	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_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(4.0 * N[(y * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5.6e-68], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e-5], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 1.85e+37], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 3.8e+264], t$95$1, N[(x * x), $MachinePrecision]]]]]]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
t_1 := x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
t_2 := 4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\
\mathbf{if}\;x \cdot x \leq 5.6 \cdot 10^{-68}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot x \leq 1.85 \cdot 10^{+37}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \cdot x \leq 3.8 \cdot 10^{+264}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;x \cdot x\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original90.9%
Target91.0%
Herbie85.8%
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if (*.f64 x x) < 5.6000000000000002e-68 or 5.00000000000000024e-5 < (*.f64 x x) < 1.85e37

    1. Initial program 95.5%

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

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

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

      [Start]93.3

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

      associate-*r* [=>]93.3

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

      metadata-eval [<=]93.3

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

      unpow2 [=>]93.3

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

      distribute-lft-neg-in [<=]93.3

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

      distribute-rgt-neg-in [=>]93.3

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

      associate-*l* [=>]93.3

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

      sub-neg [=>]93.3

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

      +-commutative [=>]93.3

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

      distribute-neg-in [=>]93.3

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

      remove-double-neg [=>]93.3

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

      sub-neg [<=]93.3

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

    if 5.6000000000000002e-68 < (*.f64 x x) < 5.00000000000000024e-5 or 1.85e37 < (*.f64 x x) < 3.8000000000000001e264

    1. Initial program 91.1%

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

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

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

      [Start]80.7

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

      unpow2 [=>]80.7

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

      associate-*r* [=>]80.7

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

      *-commutative [<=]80.7

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

      associate-*r* [=>]89.5

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

      *-commutative [=>]89.5

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

    if 3.8000000000000001e264 < (*.f64 x x)

    1. Initial program 82.1%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    3. Simplified91.0%

      \[\leadsto \color{blue}{x \cdot x} \]
      Step-by-step derivation

      [Start]91.0

      \[ {x}^{2} \]

      unpow2 [=>]91.0

      \[ \color{blue}{x \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 5.6 \cdot 10^{-68}:\\ \;\;\;\;4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-5}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 1.85 \cdot 10^{+37}:\\ \;\;\;\;4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 3.8 \cdot 10^{+264}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternatives

Alternative 1
Accuracy39.7%
Cost7368
\[\begin{array}{l} \mathbf{if}\;z \leq 1.65 \cdot 10^{+167}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+148}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(-4 \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array} \]
Alternative 2
Accuracy86.1%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+42}:\\ \;\;\;\;x \cdot x - t \cdot \left(-4 \cdot y\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+265}:\\ \;\;\;\;4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
Alternative 3
Accuracy39.7%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq 1.65 \cdot 10^{+167}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+136}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array} \]
Alternative 4
Accuracy39.5%
Cost976
\[\begin{array}{l} t_1 := -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{if}\;z \leq 1.4 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-141}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{-182}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \leq 4.05 \cdot 10^{+18}:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy41.6%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+132}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+19}:\\ \;\;\;\;4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Accuracy41.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{+43} \lor \neg \left(x \leq 1.45 \cdot 10^{+19}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 7
Accuracy41.6%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq 3.4 \cdot 10^{+43}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+21}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 8
Accuracy41.6%
Cost192
\[x \cdot x \]

Error

Reproduce?

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