
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (* -4.0 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* -4.0 y) z)) (t_1 (/ (* x 4.0) z)))
(if (<= x -1.16e+91)
t_1
(if (<= x -7e-47)
-2.0
(if (<= x -1.7e-158)
t_0
(if (<= x 8.5e-287) -2.0 (if (<= x 1.08e+124) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (-4.0 * y) / z;
double t_1 = (x * 4.0) / z;
double tmp;
if (x <= -1.16e+91) {
tmp = t_1;
} else if (x <= -7e-47) {
tmp = -2.0;
} else if (x <= -1.7e-158) {
tmp = t_0;
} else if (x <= 8.5e-287) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((-4.0d0) * y) / z
t_1 = (x * 4.0d0) / z
if (x <= (-1.16d+91)) then
tmp = t_1
else if (x <= (-7d-47)) then
tmp = -2.0d0
else if (x <= (-1.7d-158)) then
tmp = t_0
else if (x <= 8.5d-287) then
tmp = -2.0d0
else if (x <= 1.08d+124) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-4.0 * y) / z;
double t_1 = (x * 4.0) / z;
double tmp;
if (x <= -1.16e+91) {
tmp = t_1;
} else if (x <= -7e-47) {
tmp = -2.0;
} else if (x <= -1.7e-158) {
tmp = t_0;
} else if (x <= 8.5e-287) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (-4.0 * y) / z t_1 = (x * 4.0) / z tmp = 0 if x <= -1.16e+91: tmp = t_1 elif x <= -7e-47: tmp = -2.0 elif x <= -1.7e-158: tmp = t_0 elif x <= 8.5e-287: tmp = -2.0 elif x <= 1.08e+124: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(-4.0 * y) / z) t_1 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (x <= -1.16e+91) tmp = t_1; elseif (x <= -7e-47) tmp = -2.0; elseif (x <= -1.7e-158) tmp = t_0; elseif (x <= 8.5e-287) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-4.0 * y) / z; t_1 = (x * 4.0) / z; tmp = 0.0; if (x <= -1.16e+91) tmp = t_1; elseif (x <= -7e-47) tmp = -2.0; elseif (x <= -1.7e-158) tmp = t_0; elseif (x <= 8.5e-287) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -1.16e+91], t$95$1, If[LessEqual[x, -7e-47], -2.0, If[LessEqual[x, -1.7e-158], t$95$0, If[LessEqual[x, 8.5e-287], -2.0, If[LessEqual[x, 1.08e+124], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-4 \cdot y}{z}\\
t_1 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;x \leq -1.16 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-47}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-287}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.08 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.1600000000000001e91 or 1.08000000000000005e124 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 79.1%
associate-*r/79.1%
*-commutative79.1%
Simplified79.1%
if -1.1600000000000001e91 < x < -6.9999999999999996e-47 or -1.7e-158 < x < 8.5000000000000003e-287Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 57.5%
if -6.9999999999999996e-47 < x < -1.7e-158 or 8.5000000000000003e-287 < x < 1.08000000000000005e124Initial program 100.0%
Taylor expanded in y around inf 57.9%
*-commutative57.9%
Simplified57.9%
Final simplification65.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))) (t_1 (/ (* x 4.0) z)))
(if (<= x -8.5e+90)
t_1
(if (<= x -6.5e-44)
-2.0
(if (<= x -1.5e-155)
t_0
(if (<= x 2.1e-287) -2.0 (if (<= x 1.08e+124) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = (x * 4.0) / z;
double tmp;
if (x <= -8.5e+90) {
tmp = t_1;
} else if (x <= -6.5e-44) {
tmp = -2.0;
} else if (x <= -1.5e-155) {
tmp = t_0;
} else if (x <= 2.1e-287) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * ((-4.0d0) / z)
t_1 = (x * 4.0d0) / z
if (x <= (-8.5d+90)) then
tmp = t_1
else if (x <= (-6.5d-44)) then
tmp = -2.0d0
else if (x <= (-1.5d-155)) then
tmp = t_0
else if (x <= 2.1d-287) then
tmp = -2.0d0
else if (x <= 1.08d+124) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = (x * 4.0) / z;
double tmp;
if (x <= -8.5e+90) {
tmp = t_1;
} else if (x <= -6.5e-44) {
tmp = -2.0;
} else if (x <= -1.5e-155) {
tmp = t_0;
} else if (x <= 2.1e-287) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) t_1 = (x * 4.0) / z tmp = 0 if x <= -8.5e+90: tmp = t_1 elif x <= -6.5e-44: tmp = -2.0 elif x <= -1.5e-155: tmp = t_0 elif x <= 2.1e-287: tmp = -2.0 elif x <= 1.08e+124: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-4.0 / z)) t_1 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (x <= -8.5e+90) tmp = t_1; elseif (x <= -6.5e-44) tmp = -2.0; elseif (x <= -1.5e-155) tmp = t_0; elseif (x <= 2.1e-287) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (-4.0 / z); t_1 = (x * 4.0) / z; tmp = 0.0; if (x <= -8.5e+90) tmp = t_1; elseif (x <= -6.5e-44) tmp = -2.0; elseif (x <= -1.5e-155) tmp = t_0; elseif (x <= 2.1e-287) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -8.5e+90], t$95$1, If[LessEqual[x, -6.5e-44], -2.0, If[LessEqual[x, -1.5e-155], t$95$0, If[LessEqual[x, 2.1e-287], -2.0, If[LessEqual[x, 1.08e+124], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
t_1 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-44}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-155}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-287}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.08 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -8.5000000000000002e90 or 1.08000000000000005e124 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 79.1%
associate-*r/79.1%
*-commutative79.1%
Simplified79.1%
if -8.5000000000000002e90 < x < -6.5e-44 or -1.49999999999999992e-155 < x < 2.0999999999999999e-287Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 57.5%
if -6.5e-44 < x < -1.49999999999999992e-155 or 2.0999999999999999e-287 < x < 1.08000000000000005e124Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 57.9%
associate-*r/57.9%
*-commutative57.9%
associate-/l*57.7%
Simplified57.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))) (t_1 (/ 4.0 (/ z x))))
(if (<= x -1e+91)
t_1
(if (<= x -1.6e-46)
-2.0
(if (<= x -5.8e-158)
t_0
(if (<= x 1.75e-286) -2.0 (if (<= x 1.08e+124) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = 4.0 / (z / x);
double tmp;
if (x <= -1e+91) {
tmp = t_1;
} else if (x <= -1.6e-46) {
tmp = -2.0;
} else if (x <= -5.8e-158) {
tmp = t_0;
} else if (x <= 1.75e-286) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * ((-4.0d0) / z)
t_1 = 4.0d0 / (z / x)
if (x <= (-1d+91)) then
tmp = t_1
else if (x <= (-1.6d-46)) then
tmp = -2.0d0
else if (x <= (-5.8d-158)) then
tmp = t_0
else if (x <= 1.75d-286) then
tmp = -2.0d0
else if (x <= 1.08d+124) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = 4.0 / (z / x);
double tmp;
if (x <= -1e+91) {
tmp = t_1;
} else if (x <= -1.6e-46) {
tmp = -2.0;
} else if (x <= -5.8e-158) {
tmp = t_0;
} else if (x <= 1.75e-286) {
tmp = -2.0;
} else if (x <= 1.08e+124) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) t_1 = 4.0 / (z / x) tmp = 0 if x <= -1e+91: tmp = t_1 elif x <= -1.6e-46: tmp = -2.0 elif x <= -5.8e-158: tmp = t_0 elif x <= 1.75e-286: tmp = -2.0 elif x <= 1.08e+124: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-4.0 / z)) t_1 = Float64(4.0 / Float64(z / x)) tmp = 0.0 if (x <= -1e+91) tmp = t_1; elseif (x <= -1.6e-46) tmp = -2.0; elseif (x <= -5.8e-158) tmp = t_0; elseif (x <= 1.75e-286) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (-4.0 / z); t_1 = 4.0 / (z / x); tmp = 0.0; if (x <= -1e+91) tmp = t_1; elseif (x <= -1.6e-46) tmp = -2.0; elseif (x <= -5.8e-158) tmp = t_0; elseif (x <= 1.75e-286) tmp = -2.0; elseif (x <= 1.08e+124) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e+91], t$95$1, If[LessEqual[x, -1.6e-46], -2.0, If[LessEqual[x, -5.8e-158], t$95$0, If[LessEqual[x, 1.75e-286], -2.0, If[LessEqual[x, 1.08e+124], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
t_1 := \frac{4}{\frac{z}{x}}\\
\mathbf{if}\;x \leq -1 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-46}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-286}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.08 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.00000000000000008e91 or 1.08000000000000005e124 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 79.1%
associate-*r/79.1%
*-commutative79.1%
Simplified79.1%
clear-num79.0%
inv-pow79.0%
*-un-lft-identity79.0%
*-commutative79.0%
times-frac79.0%
metadata-eval79.0%
Applied egg-rr79.0%
unpow-179.0%
associate-/r*79.0%
metadata-eval79.0%
Simplified79.0%
if -1.00000000000000008e91 < x < -1.6e-46 or -5.79999999999999961e-158 < x < 1.74999999999999994e-286Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 57.5%
if -1.6e-46 < x < -5.79999999999999961e-158 or 1.74999999999999994e-286 < x < 1.08000000000000005e124Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 57.9%
associate-*r/57.9%
*-commutative57.9%
associate-/l*57.7%
Simplified57.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e+76) (not (<= y 1.3e-6))) (+ -2.0 (* -4.0 (/ y z))) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+76) || !(y <= 1.3e-6)) {
tmp = -2.0 + (-4.0 * (y / z));
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.2d+76)) .or. (.not. (y <= 1.3d-6))) then
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+76) || !(y <= 1.3e-6)) {
tmp = -2.0 + (-4.0 * (y / z));
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e+76) or not (y <= 1.3e-6): tmp = -2.0 + (-4.0 * (y / z)) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e+76) || !(y <= 1.3e-6)) tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e+76) || ~((y <= 1.3e-6))) tmp = -2.0 + (-4.0 * (y / z)); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e+76], N[Not[LessEqual[y, 1.3e-6]], $MachinePrecision]], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+76} \lor \neg \left(y \leq 1.3 \cdot 10^{-6}\right):\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.2e76 or 1.30000000000000005e-6 < y Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 82.6%
distribute-rgt-in82.6%
metadata-eval82.6%
Simplified82.6%
if -1.2e76 < y < 1.30000000000000005e-6Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 88.8%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e+105) (not (<= y 6.2e+66))) (/ (* -4.0 y) z) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+105) || !(y <= 6.2e+66)) {
tmp = (-4.0 * y) / z;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3.4d+105)) .or. (.not. (y <= 6.2d+66))) then
tmp = ((-4.0d0) * y) / z
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+105) || !(y <= 6.2e+66)) {
tmp = (-4.0 * y) / z;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+105) or not (y <= 6.2e+66): tmp = (-4.0 * y) / z else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+105) || !(y <= 6.2e+66)) tmp = Float64(Float64(-4.0 * y) / z); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e+105) || ~((y <= 6.2e+66))) tmp = (-4.0 * y) / z; else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+105], N[Not[LessEqual[y, 6.2e+66]], $MachinePrecision]], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+105} \lor \neg \left(y \leq 6.2 \cdot 10^{+66}\right):\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.3999999999999999e105 or 6.20000000000000037e66 < y Initial program 100.0%
Taylor expanded in y around inf 69.9%
*-commutative69.9%
Simplified69.9%
if -3.3999999999999999e105 < y < 6.20000000000000037e66Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 83.7%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (if (<= y -6e-82) (/ (* 4.0 (- x y)) z) (if (<= y 0.135) (* -4.0 (- 0.5 (/ x z))) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e-82) {
tmp = (4.0 * (x - y)) / z;
} else if (y <= 0.135) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-6d-82)) then
tmp = (4.0d0 * (x - y)) / z
else if (y <= 0.135d0) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6e-82) {
tmp = (4.0 * (x - y)) / z;
} else if (y <= 0.135) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e-82: tmp = (4.0 * (x - y)) / z elif y <= 0.135: tmp = -4.0 * (0.5 - (x / z)) else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e-82) tmp = Float64(Float64(4.0 * Float64(x - y)) / z); elseif (y <= 0.135) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e-82) tmp = (4.0 * (x - y)) / z; elseif (y <= 0.135) tmp = -4.0 * (0.5 - (x / z)); else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e-82], N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 0.135], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-82}:\\
\;\;\;\;\frac{4 \cdot \left(x - y\right)}{z}\\
\mathbf{elif}\;y \leq 0.135:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -5.9999999999999998e-82Initial program 100.0%
Taylor expanded in z around 0 81.4%
if -5.9999999999999998e-82 < y < 0.13500000000000001Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 95.4%
if 0.13500000000000001 < y Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 86.3%
distribute-rgt-in86.3%
metadata-eval86.3%
Simplified86.3%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= z -2.8e+110) -2.0 (if (<= z 1.45e+72) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.8e+110) {
tmp = -2.0;
} else if (z <= 1.45e+72) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-2.8d+110)) then
tmp = -2.0d0
else if (z <= 1.45d+72) then
tmp = y * ((-4.0d0) / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.8e+110) {
tmp = -2.0;
} else if (z <= 1.45e+72) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.8e+110: tmp = -2.0 elif z <= 1.45e+72: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.8e+110) tmp = -2.0; elseif (z <= 1.45e+72) tmp = Float64(y * Float64(-4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.8e+110) tmp = -2.0; elseif (z <= 1.45e+72) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.8e+110], -2.0, If[LessEqual[z, 1.45e+72], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+110}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+72}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.79999999999999987e110 or 1.45000000000000009e72 < z Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 63.8%
if -2.79999999999999987e110 < z < 1.45000000000000009e72Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 45.6%
associate-*r/45.6%
*-commutative45.6%
associate-/l*45.5%
Simplified45.5%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 28.5%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * (x / z)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2024110
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))