
(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 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}
Initial program 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 (<= x -3.8e+51)
t_0
(if (<= x -4.4e-127)
t_1
(if (<= x -2.55e-148)
-2.0
(if (<= x -4.8e-180)
t_1
(if (<= x 9.5e-265)
-2.0
(if (<= x 1.35e-167)
t_1
(if (<= x 2.05e-121) -2.0 (if (<= x 1.12e-23) t_1 t_0))))))))))
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 (x <= -3.8e+51) {
tmp = t_0;
} else if (x <= -4.4e-127) {
tmp = t_1;
} else if (x <= -2.55e-148) {
tmp = -2.0;
} else if (x <= -4.8e-180) {
tmp = t_1;
} else if (x <= 9.5e-265) {
tmp = -2.0;
} else if (x <= 1.35e-167) {
tmp = t_1;
} else if (x <= 2.05e-121) {
tmp = -2.0;
} else if (x <= 1.12e-23) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x * (4.0d0 / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-3.8d+51)) then
tmp = t_0
else if (x <= (-4.4d-127)) then
tmp = t_1
else if (x <= (-2.55d-148)) then
tmp = -2.0d0
else if (x <= (-4.8d-180)) then
tmp = t_1
else if (x <= 9.5d-265) then
tmp = -2.0d0
else if (x <= 1.35d-167) then
tmp = t_1
else if (x <= 2.05d-121) then
tmp = -2.0d0
else if (x <= 1.12d-23) then
tmp = t_1
else
tmp = t_0
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 (x <= -3.8e+51) {
tmp = t_0;
} else if (x <= -4.4e-127) {
tmp = t_1;
} else if (x <= -2.55e-148) {
tmp = -2.0;
} else if (x <= -4.8e-180) {
tmp = t_1;
} else if (x <= 9.5e-265) {
tmp = -2.0;
} else if (x <= 1.35e-167) {
tmp = t_1;
} else if (x <= 2.05e-121) {
tmp = -2.0;
} else if (x <= 1.12e-23) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -3.8e+51: tmp = t_0 elif x <= -4.4e-127: tmp = t_1 elif x <= -2.55e-148: tmp = -2.0 elif x <= -4.8e-180: tmp = t_1 elif x <= 9.5e-265: tmp = -2.0 elif x <= 1.35e-167: tmp = t_1 elif x <= 2.05e-121: tmp = -2.0 elif x <= 1.12e-23: tmp = t_1 else: tmp = t_0 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 (x <= -3.8e+51) tmp = t_0; elseif (x <= -4.4e-127) tmp = t_1; elseif (x <= -2.55e-148) tmp = -2.0; elseif (x <= -4.8e-180) tmp = t_1; elseif (x <= 9.5e-265) tmp = -2.0; elseif (x <= 1.35e-167) tmp = t_1; elseif (x <= 2.05e-121) tmp = -2.0; elseif (x <= 1.12e-23) tmp = t_1; else tmp = t_0; 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 (x <= -3.8e+51) tmp = t_0; elseif (x <= -4.4e-127) tmp = t_1; elseif (x <= -2.55e-148) tmp = -2.0; elseif (x <= -4.8e-180) tmp = t_1; elseif (x <= 9.5e-265) tmp = -2.0; elseif (x <= 1.35e-167) tmp = t_1; elseif (x <= 2.05e-121) tmp = -2.0; elseif (x <= 1.12e-23) tmp = t_1; else tmp = t_0; 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[x, -3.8e+51], t$95$0, If[LessEqual[x, -4.4e-127], t$95$1, If[LessEqual[x, -2.55e-148], -2.0, If[LessEqual[x, -4.8e-180], t$95$1, If[LessEqual[x, 9.5e-265], -2.0, If[LessEqual[x, 1.35e-167], t$95$1, If[LessEqual[x, 2.05e-121], -2.0, If[LessEqual[x, 1.12e-23], t$95$1, t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{-127}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.55 \cdot 10^{-148}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-180}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-265}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-167}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-121}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-23}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.7999999999999997e51 or 1.1200000000000001e-23 < x Initial program 100.0%
Taylor expanded in x around inf 67.1%
*-commutative67.1%
associate-*l/67.1%
associate-*r/67.0%
Simplified67.0%
if -3.7999999999999997e51 < x < -4.4000000000000003e-127 or -2.55e-148 < x < -4.79999999999999959e-180 or 9.50000000000000034e-265 < x < 1.35e-167 or 2.04999999999999991e-121 < x < 1.1200000000000001e-23Initial program 100.0%
Taylor expanded in y around inf 61.2%
if -4.4000000000000003e-127 < x < -2.55e-148 or -4.79999999999999959e-180 < x < 9.50000000000000034e-265 or 1.35e-167 < x < 2.04999999999999991e-121Initial program 100.0%
Taylor expanded in z around inf 76.8%
Final simplification66.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* 4.0 x) z)) (t_1 (* -4.0 (/ y z))))
(if (<= x -1.5e+55)
t_0
(if (<= x -3.9e-125)
t_1
(if (<= x -4.8e-149)
-2.0
(if (<= x -1.2e-179)
t_1
(if (<= x 3.6e-265)
-2.0
(if (<= x 6.4e-167)
t_1
(if (<= x 3.9e-119) -2.0 (if (<= x 1.12e-23) t_1 t_0))))))))))
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 (x <= -1.5e+55) {
tmp = t_0;
} else if (x <= -3.9e-125) {
tmp = t_1;
} else if (x <= -4.8e-149) {
tmp = -2.0;
} else if (x <= -1.2e-179) {
tmp = t_1;
} else if (x <= 3.6e-265) {
tmp = -2.0;
} else if (x <= 6.4e-167) {
tmp = t_1;
} else if (x <= 3.9e-119) {
tmp = -2.0;
} else if (x <= 1.12e-23) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (4.0d0 * x) / z
t_1 = (-4.0d0) * (y / z)
if (x <= (-1.5d+55)) then
tmp = t_0
else if (x <= (-3.9d-125)) then
tmp = t_1
else if (x <= (-4.8d-149)) then
tmp = -2.0d0
else if (x <= (-1.2d-179)) then
tmp = t_1
else if (x <= 3.6d-265) then
tmp = -2.0d0
else if (x <= 6.4d-167) then
tmp = t_1
else if (x <= 3.9d-119) then
tmp = -2.0d0
else if (x <= 1.12d-23) then
tmp = t_1
else
tmp = t_0
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 (x <= -1.5e+55) {
tmp = t_0;
} else if (x <= -3.9e-125) {
tmp = t_1;
} else if (x <= -4.8e-149) {
tmp = -2.0;
} else if (x <= -1.2e-179) {
tmp = t_1;
} else if (x <= 3.6e-265) {
tmp = -2.0;
} else if (x <= 6.4e-167) {
tmp = t_1;
} else if (x <= 3.9e-119) {
tmp = -2.0;
} else if (x <= 1.12e-23) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / z t_1 = -4.0 * (y / z) tmp = 0 if x <= -1.5e+55: tmp = t_0 elif x <= -3.9e-125: tmp = t_1 elif x <= -4.8e-149: tmp = -2.0 elif x <= -1.2e-179: tmp = t_1 elif x <= 3.6e-265: tmp = -2.0 elif x <= 6.4e-167: tmp = t_1 elif x <= 3.9e-119: tmp = -2.0 elif x <= 1.12e-23: tmp = t_1 else: tmp = t_0 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 (x <= -1.5e+55) tmp = t_0; elseif (x <= -3.9e-125) tmp = t_1; elseif (x <= -4.8e-149) tmp = -2.0; elseif (x <= -1.2e-179) tmp = t_1; elseif (x <= 3.6e-265) tmp = -2.0; elseif (x <= 6.4e-167) tmp = t_1; elseif (x <= 3.9e-119) tmp = -2.0; elseif (x <= 1.12e-23) tmp = t_1; else tmp = t_0; 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 (x <= -1.5e+55) tmp = t_0; elseif (x <= -3.9e-125) tmp = t_1; elseif (x <= -4.8e-149) tmp = -2.0; elseif (x <= -1.2e-179) tmp = t_1; elseif (x <= 3.6e-265) tmp = -2.0; elseif (x <= 6.4e-167) tmp = t_1; elseif (x <= 3.9e-119) tmp = -2.0; elseif (x <= 1.12e-23) tmp = t_1; else tmp = t_0; 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[x, -1.5e+55], t$95$0, If[LessEqual[x, -3.9e-125], t$95$1, If[LessEqual[x, -4.8e-149], -2.0, If[LessEqual[x, -1.2e-179], t$95$1, If[LessEqual[x, 3.6e-265], -2.0, If[LessEqual[x, 6.4e-167], t$95$1, If[LessEqual[x, 3.9e-119], -2.0, If[LessEqual[x, 1.12e-23], t$95$1, t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{+55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.9 \cdot 10^{-125}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-149}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-179}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-265}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-167}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-119}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-23}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.50000000000000008e55 or 1.1200000000000001e-23 < x Initial program 100.0%
Taylor expanded in x around inf 67.1%
associate-*r/67.1%
Simplified67.1%
if -1.50000000000000008e55 < x < -3.89999999999999982e-125 or -4.8000000000000002e-149 < x < -1.2e-179 or 3.6000000000000002e-265 < x < 6.4000000000000003e-167 or 3.8999999999999999e-119 < x < 1.1200000000000001e-23Initial program 100.0%
Taylor expanded in y around inf 61.2%
if -3.89999999999999982e-125 < x < -4.8000000000000002e-149 or -1.2e-179 < x < 3.6000000000000002e-265 or 6.4000000000000003e-167 < x < 3.8999999999999999e-119Initial program 100.0%
Taylor expanded in z around inf 76.8%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2e+52) (not (<= x 270000000.0))) (* 4.0 (/ (- x y) z)) (- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2e+52) || !(x <= 270000000.0)) {
tmp = 4.0 * ((x - y) / 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 <= (-2d+52)) .or. (.not. (x <= 270000000.0d0))) then
tmp = 4.0d0 * ((x - y) / 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 <= -2e+52) || !(x <= 270000000.0)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2e+52) or not (x <= 270000000.0): tmp = 4.0 * ((x - y) / z) else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2e+52) || !(x <= 270000000.0)) tmp = Float64(4.0 * Float64(Float64(x - y) / 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 <= -2e+52) || ~((x <= 270000000.0))) tmp = 4.0 * ((x - y) / z); else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2e+52], N[Not[LessEqual[x, 270000000.0]], $MachinePrecision]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / 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 -2 \cdot 10^{+52} \lor \neg \left(x \leq 270000000\right):\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -2e52 or 2.7e8 < x Initial program 100.0%
Taylor expanded in z around 0 83.5%
if -2e52 < x < 2.7e8Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 89.7%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (<= z -3.1e+158) -2.0 (if (<= z 6.4e+125) (* 4.0 (/ (- x y) z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e+158) {
tmp = -2.0;
} else if (z <= 6.4e+125) {
tmp = 4.0 * ((x - 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 (z <= (-3.1d+158)) then
tmp = -2.0d0
else if (z <= 6.4d+125) then
tmp = 4.0d0 * ((x - 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 (z <= -3.1e+158) {
tmp = -2.0;
} else if (z <= 6.4e+125) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.1e+158: tmp = -2.0 elif z <= 6.4e+125: tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.1e+158) tmp = -2.0; elseif (z <= 6.4e+125) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.1e+158) tmp = -2.0; elseif (z <= 6.4e+125) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.1e+158], -2.0, If[LessEqual[z, 6.4e+125], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+158}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{+125}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -3.1000000000000002e158 or 6.39999999999999967e125 < z Initial program 100.0%
Taylor expanded in z around inf 79.9%
if -3.1000000000000002e158 < z < 6.39999999999999967e125Initial program 100.0%
Taylor expanded in z around 0 85.0%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (<= y -2.2e-56) (* 4.0 (/ (- x y) z)) (if (<= y 1.45e+15) (- (* 4.0 (/ x z)) 2.0) (- (* -4.0 (/ y z)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e-56) {
tmp = 4.0 * ((x - y) / z);
} else if (y <= 1.45e+15) {
tmp = (4.0 * (x / z)) - 2.0;
} 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 (y <= (-2.2d-56)) then
tmp = 4.0d0 * ((x - y) / z)
else if (y <= 1.45d+15) then
tmp = (4.0d0 * (x / z)) - 2.0d0
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 (y <= -2.2e-56) {
tmp = 4.0 * ((x - y) / z);
} else if (y <= 1.45e+15) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.2e-56: tmp = 4.0 * ((x - y) / z) elif y <= 1.45e+15: tmp = (4.0 * (x / z)) - 2.0 else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.2e-56) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (y <= 1.45e+15) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); 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 (y <= -2.2e-56) tmp = 4.0 * ((x - y) / z); elseif (y <= 1.45e+15) tmp = (4.0 * (x / z)) - 2.0; else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.2e-56], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.45e+15], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-56}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+15}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if y < -2.20000000000000004e-56Initial program 100.0%
Taylor expanded in z around 0 85.0%
if -2.20000000000000004e-56 < y < 1.45e15Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.5%
if 1.45e15 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.9%
div-sub99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 89.9%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e-56) (not (<= y 5.5e+58))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e-56) || !(y <= 5.5e+58)) {
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 <= (-4d-56)) .or. (.not. (y <= 5.5d+58))) 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 <= -4e-56) || !(y <= 5.5e+58)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e-56) or not (y <= 5.5e+58): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e-56) || !(y <= 5.5e+58)) 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 <= -4e-56) || ~((y <= 5.5e+58))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e-56], N[Not[LessEqual[y, 5.5e+58]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-56} \lor \neg \left(y \leq 5.5 \cdot 10^{+58}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -4.0000000000000002e-56 or 5.4999999999999999e58 < y Initial program 100.0%
Taylor expanded in y around inf 63.4%
if -4.0000000000000002e-56 < y < 5.4999999999999999e58Initial program 100.0%
Taylor expanded in z around inf 50.2%
Final simplification56.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%
Taylor expanded in z around inf 34.3%
Final simplification34.3%
(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 2024010
(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))