
(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 8 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 (/ (- x y) z)) 2.0))
double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 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 = (4.0d0 * ((x - y) / z)) - 2.0d0
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 2.0;
}
def code(x, y, z): return (4.0 * ((x - y) / z)) - 2.0
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) / z)) - 2.0) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) / z)) - 2.0; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x - y}{z} - 2
\end{array}
Initial program 99.2%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))) (t_1 (* -4.0 (/ y z))))
(if (<= y -6.3e+74)
t_1
(if (<= y -6.2e-145)
-2.0
(if (<= y 3.8e-222)
t_0
(if (<= y 1.26e-151) -2.0 (if (<= y 1.4e+16) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -6.3e+74) {
tmp = t_1;
} else if (y <= -6.2e-145) {
tmp = -2.0;
} else if (y <= 3.8e-222) {
tmp = t_0;
} else if (y <= 1.26e-151) {
tmp = -2.0;
} else if (y <= 1.4e+16) {
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 = x * (4.0d0 / z)
t_1 = (-4.0d0) * (y / z)
if (y <= (-6.3d+74)) then
tmp = t_1
else if (y <= (-6.2d-145)) then
tmp = -2.0d0
else if (y <= 3.8d-222) then
tmp = t_0
else if (y <= 1.26d-151) then
tmp = -2.0d0
else if (y <= 1.4d+16) 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 = x * (4.0 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -6.3e+74) {
tmp = t_1;
} else if (y <= -6.2e-145) {
tmp = -2.0;
} else if (y <= 3.8e-222) {
tmp = t_0;
} else if (y <= 1.26e-151) {
tmp = -2.0;
} else if (y <= 1.4e+16) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) t_1 = -4.0 * (y / z) tmp = 0 if y <= -6.3e+74: tmp = t_1 elif y <= -6.2e-145: tmp = -2.0 elif y <= 3.8e-222: tmp = t_0 elif y <= 1.26e-151: tmp = -2.0 elif y <= 1.4e+16: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -6.3e+74) tmp = t_1; elseif (y <= -6.2e-145) tmp = -2.0; elseif (y <= 3.8e-222) tmp = t_0; elseif (y <= 1.26e-151) tmp = -2.0; elseif (y <= 1.4e+16) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (y <= -6.3e+74) tmp = t_1; elseif (y <= -6.2e-145) tmp = -2.0; elseif (y <= 3.8e-222) tmp = t_0; elseif (y <= 1.26e-151) tmp = -2.0; elseif (y <= 1.4e+16) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.3e+74], t$95$1, If[LessEqual[y, -6.2e-145], -2.0, If[LessEqual[y, 3.8e-222], t$95$0, If[LessEqual[y, 1.26e-151], -2.0, If[LessEqual[y, 1.4e+16], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -6.3 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-145}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-222}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{-151}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.30000000000000016e74 or 1.4e16 < y Initial program 99.1%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 71.0%
if -6.30000000000000016e74 < y < -6.20000000000000001e-145 or 3.79999999999999997e-222 < y < 1.2600000000000001e-151Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 59.4%
if -6.20000000000000001e-145 < y < 3.79999999999999997e-222 or 1.2600000000000001e-151 < y < 1.4e16Initial program 98.8%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 64.7%
associate-*r/64.7%
associate-*l/64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in x around inf 60.9%
associate-*r/60.9%
associate-*l/60.8%
*-commutative60.8%
Simplified60.8%
Final simplification65.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* 4.0 x) z)) (t_1 (* -4.0 (/ y z))))
(if (<= y -5.8e+74)
t_1
(if (<= y -1.8e-145)
-2.0
(if (<= y 3e-222)
t_0
(if (<= y 1.35e-153) -2.0 (if (<= y 1.3e+24) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * x) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -5.8e+74) {
tmp = t_1;
} else if (y <= -1.8e-145) {
tmp = -2.0;
} else if (y <= 3e-222) {
tmp = t_0;
} else if (y <= 1.35e-153) {
tmp = -2.0;
} else if (y <= 1.3e+24) {
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 * x) / z
t_1 = (-4.0d0) * (y / z)
if (y <= (-5.8d+74)) then
tmp = t_1
else if (y <= (-1.8d-145)) then
tmp = -2.0d0
else if (y <= 3d-222) then
tmp = t_0
else if (y <= 1.35d-153) then
tmp = -2.0d0
else if (y <= 1.3d+24) 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 * x) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -5.8e+74) {
tmp = t_1;
} else if (y <= -1.8e-145) {
tmp = -2.0;
} else if (y <= 3e-222) {
tmp = t_0;
} else if (y <= 1.35e-153) {
tmp = -2.0;
} else if (y <= 1.3e+24) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / z t_1 = -4.0 * (y / z) tmp = 0 if y <= -5.8e+74: tmp = t_1 elif y <= -1.8e-145: tmp = -2.0 elif y <= 3e-222: tmp = t_0 elif y <= 1.35e-153: tmp = -2.0 elif y <= 1.3e+24: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * x) / z) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -5.8e+74) tmp = t_1; elseif (y <= -1.8e-145) tmp = -2.0; elseif (y <= 3e-222) tmp = t_0; elseif (y <= 1.35e-153) tmp = -2.0; elseif (y <= 1.3e+24) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * x) / z; t_1 = -4.0 * (y / z); tmp = 0.0; if (y <= -5.8e+74) tmp = t_1; elseif (y <= -1.8e-145) tmp = -2.0; elseif (y <= 3e-222) tmp = t_0; elseif (y <= 1.35e-153) tmp = -2.0; elseif (y <= 1.3e+24) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.8e+74], t$95$1, If[LessEqual[y, -1.8e-145], -2.0, If[LessEqual[y, 3e-222], t$95$0, If[LessEqual[y, 1.35e-153], -2.0, If[LessEqual[y, 1.3e+24], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-145}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-222}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-153}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.8000000000000005e74 or 1.2999999999999999e24 < y Initial program 99.1%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 71.0%
if -5.8000000000000005e74 < y < -1.8e-145 or 3.0000000000000003e-222 < y < 1.35000000000000005e-153Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 59.4%
if -1.8e-145 < y < 3.0000000000000003e-222 or 1.35000000000000005e-153 < y < 1.2999999999999999e24Initial program 98.8%
associate--l-98.8%
Simplified98.8%
Taylor expanded in x around inf 60.9%
Final simplification65.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- x y) (/ 4.0 z))))
(if (<= x -3.5e+70)
t_0
(if (<= x 0.0095)
(- (* -4.0 (/ y z)) 2.0)
(if (<= x 9e+143) (- (* 4.0 (/ x z)) 2.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = (x - y) * (4.0 / z);
double tmp;
if (x <= -3.5e+70) {
tmp = t_0;
} else if (x <= 0.0095) {
tmp = (-4.0 * (y / z)) - 2.0;
} else if (x <= 9e+143) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (x - y) * (4.0d0 / z)
if (x <= (-3.5d+70)) then
tmp = t_0
else if (x <= 0.0095d0) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else if (x <= 9d+143) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - y) * (4.0 / z);
double tmp;
if (x <= -3.5e+70) {
tmp = t_0;
} else if (x <= 0.0095) {
tmp = (-4.0 * (y / z)) - 2.0;
} else if (x <= 9e+143) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) * (4.0 / z) tmp = 0 if x <= -3.5e+70: tmp = t_0 elif x <= 0.0095: tmp = (-4.0 * (y / z)) - 2.0 elif x <= 9e+143: tmp = (4.0 * (x / z)) - 2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) * Float64(4.0 / z)) tmp = 0.0 if (x <= -3.5e+70) tmp = t_0; elseif (x <= 0.0095) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); elseif (x <= 9e+143) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) * (4.0 / z); tmp = 0.0; if (x <= -3.5e+70) tmp = t_0; elseif (x <= 0.0095) tmp = (-4.0 * (y / z)) - 2.0; elseif (x <= 9e+143) tmp = (4.0 * (x / z)) - 2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.5e+70], t$95$0, If[LessEqual[x, 0.0095], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], If[LessEqual[x, 9e+143], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.0095:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+143}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.50000000000000002e70 or 8.9999999999999993e143 < x Initial program 98.9%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 94.1%
associate-*r/94.1%
associate-*l/94.0%
*-commutative94.0%
Simplified94.0%
if -3.50000000000000002e70 < x < 0.00949999999999999976Initial program 99.3%
*-commutative99.3%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
associate-/l*99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 91.2%
if 0.00949999999999999976 < x < 8.9999999999999993e143Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/100.0%
fma-neg100.0%
metadata-eval100.0%
/-rgt-identity100.0%
associate-/r/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
associate-/l*100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.7%
Final simplification92.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -7e+70) (not (<= x 1.35e+80))) (* (- x y) (/ 4.0 z)) (- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7e+70) || !(x <= 1.35e+80)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = (-4.0 * (y / z)) - 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 ((x <= (-7d+70)) .or. (.not. (x <= 1.35d+80))) then
tmp = (x - y) * (4.0d0 / z)
else
tmp = ((-4.0d0) * (y / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7e+70) || !(x <= 1.35e+80)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7e+70) or not (x <= 1.35e+80): tmp = (x - y) * (4.0 / z) else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7e+70) || !(x <= 1.35e+80)) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7e+70) || ~((x <= 1.35e+80))) tmp = (x - y) * (4.0 / z); else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7e+70], N[Not[LessEqual[x, 1.35e+80]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+70} \lor \neg \left(x \leq 1.35 \cdot 10^{+80}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -7.00000000000000005e70 or 1.34999999999999991e80 < x Initial program 99.1%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 89.6%
associate-*r/89.6%
associate-*l/89.5%
*-commutative89.5%
Simplified89.5%
if -7.00000000000000005e70 < x < 1.34999999999999991e80Initial program 99.4%
*-commutative99.4%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
associate-/l*99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 89.4%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (<= z -3.9e+99) -2.0 (if (<= z 1.15e+91) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.9e+99) {
tmp = -2.0;
} else if (z <= 1.15e+91) {
tmp = (x - 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 <= (-3.9d+99)) then
tmp = -2.0d0
else if (z <= 1.15d+91) then
tmp = (x - 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 <= -3.9e+99) {
tmp = -2.0;
} else if (z <= 1.15e+91) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.9e+99: tmp = -2.0 elif z <= 1.15e+91: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.9e+99) tmp = -2.0; elseif (z <= 1.15e+91) tmp = Float64(Float64(x - 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 <= -3.9e+99) tmp = -2.0; elseif (z <= 1.15e+91) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.9e+99], -2.0, If[LessEqual[z, 1.15e+91], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+99}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+91}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -3.89999999999999995e99 or 1.14999999999999996e91 < z Initial program 97.6%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 70.8%
if -3.89999999999999995e99 < z < 1.14999999999999996e91Initial program 100.0%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 88.9%
associate-*r/88.9%
associate-*l/88.7%
*-commutative88.7%
Simplified88.7%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.8e+74) (not (<= y 4.1e-26))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e+74) || !(y <= 4.1e-26)) {
tmp = -4.0 * (y / 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 ((y <= (-5.8d+74)) .or. (.not. (y <= 4.1d-26))) then
tmp = (-4.0d0) * (y / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e+74) || !(y <= 4.1e-26)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.8e+74) or not (y <= 4.1e-26): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.8e+74) || !(y <= 4.1e-26)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.8e+74) || ~((y <= 4.1e-26))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.8e+74], N[Not[LessEqual[y, 4.1e-26]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+74} \lor \neg \left(y \leq 4.1 \cdot 10^{-26}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -5.8000000000000005e74 or 4.0999999999999999e-26 < y Initial program 99.2%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 69.0%
if -5.8000000000000005e74 < y < 4.0999999999999999e-26Initial program 99.3%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 48.7%
Final simplification58.1%
(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 99.2%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 31.9%
Final simplification31.9%
(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 2024036
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:herbie-target
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))