
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 4.0 (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
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 + (4.0d0 * ((x - z) / y))
end function
public static double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
def code(x, y, z): return 4.0 + (4.0 * ((x - z) / y))
function code(x, y, z) return Float64(4.0 + Float64(4.0 * Float64(Float64(x - z) / y))) end
function tmp = code(x, y, z) tmp = 4.0 + (4.0 * ((x - z) / y)); end
code[x_, y_, z_] := N[(4.0 + N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))) (t_1 (* 4.0 (/ x y))))
(if (<= x -4.1e+18)
t_1
(if (<= x -5.4e-185)
4.0
(if (<= x 1.55e-251)
t_0
(if (<= x 8.5e+41) 4.0 (if (<= x 3.8e+132) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -4.1e+18) {
tmp = t_1;
} else if (x <= -5.4e-185) {
tmp = 4.0;
} else if (x <= 1.55e-251) {
tmp = t_0;
} else if (x <= 8.5e+41) {
tmp = 4.0;
} else if (x <= 3.8e+132) {
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) * (z / y)
t_1 = 4.0d0 * (x / y)
if (x <= (-4.1d+18)) then
tmp = t_1
else if (x <= (-5.4d-185)) then
tmp = 4.0d0
else if (x <= 1.55d-251) then
tmp = t_0
else if (x <= 8.5d+41) then
tmp = 4.0d0
else if (x <= 3.8d+132) 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 * (z / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -4.1e+18) {
tmp = t_1;
} else if (x <= -5.4e-185) {
tmp = 4.0;
} else if (x <= 1.55e-251) {
tmp = t_0;
} else if (x <= 8.5e+41) {
tmp = 4.0;
} else if (x <= 3.8e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) t_1 = 4.0 * (x / y) tmp = 0 if x <= -4.1e+18: tmp = t_1 elif x <= -5.4e-185: tmp = 4.0 elif x <= 1.55e-251: tmp = t_0 elif x <= 8.5e+41: tmp = 4.0 elif x <= 3.8e+132: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -4.1e+18) tmp = t_1; elseif (x <= -5.4e-185) tmp = 4.0; elseif (x <= 1.55e-251) tmp = t_0; elseif (x <= 8.5e+41) tmp = 4.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); t_1 = 4.0 * (x / y); tmp = 0.0; if (x <= -4.1e+18) tmp = t_1; elseif (x <= -5.4e-185) tmp = 4.0; elseif (x <= 1.55e-251) tmp = t_0; elseif (x <= 8.5e+41) tmp = 4.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.1e+18], t$95$1, If[LessEqual[x, -5.4e-185], 4.0, If[LessEqual[x, 1.55e-251], t$95$0, If[LessEqual[x, 8.5e+41], 4.0, If[LessEqual[x, 3.8e+132], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -4.1 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.4 \cdot 10^{-185}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-251}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+41}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+132}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.1e18 or 3.80000000000000006e132 < x Initial program 99.9%
Taylor expanded in x around inf 67.7%
if -4.1e18 < x < -5.39999999999999976e-185 or 1.55000000000000001e-251 < x < 8.49999999999999938e41Initial program 99.8%
Taylor expanded in y around inf 54.2%
if -5.39999999999999976e-185 < x < 1.55000000000000001e-251 or 8.49999999999999938e41 < x < 3.80000000000000006e132Initial program 99.9%
Taylor expanded in z around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification63.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (* 4.0 (/ x y))))
(if (<= x -7.5e+17)
t_1
(if (<= x -1.04e-184)
4.0
(if (<= x 1.2e-243)
t_0
(if (<= x 1.6e+43) 4.0 (if (<= x 7.4e+132) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -7.5e+17) {
tmp = t_1;
} else if (x <= -1.04e-184) {
tmp = 4.0;
} else if (x <= 1.2e-243) {
tmp = t_0;
} else if (x <= 1.6e+43) {
tmp = 4.0;
} else if (x <= 7.4e+132) {
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 = z * ((-4.0d0) / y)
t_1 = 4.0d0 * (x / y)
if (x <= (-7.5d+17)) then
tmp = t_1
else if (x <= (-1.04d-184)) then
tmp = 4.0d0
else if (x <= 1.2d-243) then
tmp = t_0
else if (x <= 1.6d+43) then
tmp = 4.0d0
else if (x <= 7.4d+132) 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 = z * (-4.0 / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -7.5e+17) {
tmp = t_1;
} else if (x <= -1.04e-184) {
tmp = 4.0;
} else if (x <= 1.2e-243) {
tmp = t_0;
} else if (x <= 1.6e+43) {
tmp = 4.0;
} else if (x <= 7.4e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = 4.0 * (x / y) tmp = 0 if x <= -7.5e+17: tmp = t_1 elif x <= -1.04e-184: tmp = 4.0 elif x <= 1.2e-243: tmp = t_0 elif x <= 1.6e+43: tmp = 4.0 elif x <= 7.4e+132: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -7.5e+17) tmp = t_1; elseif (x <= -1.04e-184) tmp = 4.0; elseif (x <= 1.2e-243) tmp = t_0; elseif (x <= 1.6e+43) tmp = 4.0; elseif (x <= 7.4e+132) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = 4.0 * (x / y); tmp = 0.0; if (x <= -7.5e+17) tmp = t_1; elseif (x <= -1.04e-184) tmp = 4.0; elseif (x <= 1.2e-243) tmp = t_0; elseif (x <= 1.6e+43) tmp = 4.0; elseif (x <= 7.4e+132) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.5e+17], t$95$1, If[LessEqual[x, -1.04e-184], 4.0, If[LessEqual[x, 1.2e-243], t$95$0, If[LessEqual[x, 1.6e+43], 4.0, If[LessEqual[x, 7.4e+132], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.04 \cdot 10^{-184}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-243}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+43}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+132}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.5e17 or 7.40000000000000022e132 < x Initial program 99.9%
Taylor expanded in x around inf 67.7%
if -7.5e17 < x < -1.03999999999999994e-184 or 1.2e-243 < x < 1.60000000000000007e43Initial program 99.8%
Taylor expanded in y around inf 54.2%
if -1.03999999999999994e-184 < x < 1.2e-243 or 1.60000000000000007e43 < x < 7.40000000000000022e132Initial program 99.9%
Taylor expanded in z around inf 70.0%
associate-*r/70.0%
*-commutative70.0%
associate-/l*69.7%
Simplified69.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.2e+21) (not (<= z 2.15e-23))) (* (- x z) (/ 4.0 y)) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e+21) || !(z <= 2.15e-23)) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
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 <= (-6.2d+21)) .or. (.not. (z <= 2.15d-23))) then
tmp = (x - z) * (4.0d0 / y)
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e+21) || !(z <= 2.15e-23)) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.2e+21) or not (z <= 2.15e-23): tmp = (x - z) * (4.0 / y) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.2e+21) || !(z <= 2.15e-23)) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.2e+21) || ~((z <= 2.15e-23))) tmp = (x - z) * (4.0 / y); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.2e+21], N[Not[LessEqual[z, 2.15e-23]], $MachinePrecision]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+21} \lor \neg \left(z \leq 2.15 \cdot 10^{-23}\right):\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -6.2e21 or 2.15000000000000001e-23 < z Initial program 99.9%
Taylor expanded in y around 0 82.8%
*-lft-identity82.8%
associate-*l/82.6%
associate-*r*82.6%
associate-*r/82.6%
metadata-eval82.6%
Simplified82.6%
if -6.2e21 < z < 2.15000000000000001e-23Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
distribute-lft-in93.4%
metadata-eval93.4%
associate-+r+93.5%
metadata-eval93.5%
associate-*r/93.5%
*-commutative93.5%
associate-*r/93.2%
Simplified93.2%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= z -4.5e+32) (* (- x z) (/ 4.0 y)) (if (<= z 1.5e-9) (+ 4.0 (/ (* 4.0 x) y)) (+ 4.0 (/ (* z -4.0) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+32) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 1.5e-9) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
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 <= (-4.5d+32)) then
tmp = (x - z) * (4.0d0 / y)
else if (z <= 1.5d-9) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+32) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 1.5e-9) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.5e+32: tmp = (x - z) * (4.0 / y) elif z <= 1.5e-9: tmp = 4.0 + ((4.0 * x) / y) else: tmp = 4.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.5e+32) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (z <= 1.5e-9) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.5e+32) tmp = (x - z) * (4.0 / y); elseif (z <= 1.5e-9) tmp = 4.0 + ((4.0 * x) / y); else tmp = 4.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.5e+32], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e-9], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+32}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-9}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if z < -4.5000000000000003e32Initial program 99.9%
Taylor expanded in y around 0 87.8%
*-lft-identity87.8%
associate-*l/87.5%
associate-*r*87.5%
associate-*r/87.5%
metadata-eval87.5%
Simplified87.5%
if -4.5000000000000003e32 < z < 1.49999999999999999e-9Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 92.8%
distribute-lft-in92.8%
metadata-eval92.8%
associate-+r+92.8%
metadata-eval92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r/92.6%
Simplified92.6%
*-commutative92.6%
associate-*l/92.8%
Applied egg-rr92.8%
if 1.49999999999999999e-9 < z Initial program 99.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 86.4%
+-commutative86.4%
associate-*r/86.4%
Simplified86.4%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= z -3.4e+32) (* (- x z) (/ 4.0 y)) (if (<= z 6.8e-10) (+ 4.0 (/ (* 4.0 x) y)) (+ 4.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e+32) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 6.8e-10) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
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.4d+32)) then
tmp = (x - z) * (4.0d0 / y)
else if (z <= 6.8d-10) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else
tmp = 4.0d0 + (z * ((-4.0d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e+32) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 6.8e-10) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.4e+32: tmp = (x - z) * (4.0 / y) elif z <= 6.8e-10: tmp = 4.0 + ((4.0 * x) / y) else: tmp = 4.0 + (z * (-4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.4e+32) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (z <= 6.8e-10) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.4e+32) tmp = (x - z) * (4.0 / y); elseif (z <= 6.8e-10) tmp = 4.0 + ((4.0 * x) / y); else tmp = 4.0 + (z * (-4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.4e+32], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.8e-10], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+32}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-10}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if z < -3.39999999999999979e32Initial program 99.9%
Taylor expanded in y around 0 87.8%
*-lft-identity87.8%
associate-*l/87.5%
associate-*r*87.5%
associate-*r/87.5%
metadata-eval87.5%
Simplified87.5%
if -3.39999999999999979e32 < z < 6.8000000000000003e-10Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 92.8%
distribute-lft-in92.8%
metadata-eval92.8%
associate-+r+92.8%
metadata-eval92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r/92.6%
Simplified92.6%
*-commutative92.6%
associate-*l/92.8%
Applied egg-rr92.8%
if 6.8000000000000003e-10 < z Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 86.4%
sub-neg86.4%
distribute-lft-in86.4%
metadata-eval86.4%
associate-+r+86.4%
metadata-eval86.4%
neg-mul-186.4%
associate-*r*86.4%
metadata-eval86.4%
associate-*r/86.4%
*-commutative86.4%
associate-/l*86.3%
Simplified86.3%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= z -2.3e+30) (* (- x z) (/ 4.0 y)) (if (<= z 6e-26) (+ 4.0 (* x (/ 4.0 y))) (+ 4.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+30) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 6e-26) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
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.3d+30)) then
tmp = (x - z) * (4.0d0 / y)
else if (z <= 6d-26) then
tmp = 4.0d0 + (x * (4.0d0 / y))
else
tmp = 4.0d0 + (z * ((-4.0d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+30) {
tmp = (x - z) * (4.0 / y);
} else if (z <= 6e-26) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.3e+30: tmp = (x - z) * (4.0 / y) elif z <= 6e-26: tmp = 4.0 + (x * (4.0 / y)) else: tmp = 4.0 + (z * (-4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.3e+30) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (z <= 6e-26) tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.3e+30) tmp = (x - z) * (4.0 / y); elseif (z <= 6e-26) tmp = 4.0 + (x * (4.0 / y)); else tmp = 4.0 + (z * (-4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.3e+30], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6e-26], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+30}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-26}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if z < -2.3e30Initial program 99.9%
Taylor expanded in y around 0 87.8%
*-lft-identity87.8%
associate-*l/87.5%
associate-*r*87.5%
associate-*r/87.5%
metadata-eval87.5%
Simplified87.5%
if -2.3e30 < z < 6.00000000000000023e-26Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
distribute-lft-in93.4%
metadata-eval93.4%
associate-+r+93.4%
metadata-eval93.4%
associate-*r/93.4%
*-commutative93.4%
associate-*r/93.2%
Simplified93.2%
if 6.00000000000000023e-26 < z Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 85.7%
sub-neg85.7%
distribute-lft-in85.7%
metadata-eval85.7%
associate-+r+85.7%
metadata-eval85.7%
neg-mul-185.7%
associate-*r*85.7%
metadata-eval85.7%
associate-*r/85.7%
*-commutative85.7%
associate-/l*85.6%
Simplified85.6%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (<= y -2.26e+80) 4.0 (if (<= y 2.8e+150) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.26e+80) {
tmp = 4.0;
} else if (y <= 2.8e+150) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.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.26d+80)) then
tmp = 4.0d0
else if (y <= 2.8d+150) then
tmp = (x - z) * (4.0d0 / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.26e+80) {
tmp = 4.0;
} else if (y <= 2.8e+150) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.26e+80: tmp = 4.0 elif y <= 2.8e+150: tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.26e+80) tmp = 4.0; elseif (y <= 2.8e+150) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.26e+80) tmp = 4.0; elseif (y <= 2.8e+150) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.26e+80], 4.0, If[LessEqual[y, 2.8e+150], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.26 \cdot 10^{+80}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+150}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -2.26e80 or 2.80000000000000009e150 < y Initial program 99.7%
Taylor expanded in y around inf 71.8%
if -2.26e80 < y < 2.80000000000000009e150Initial program 99.9%
Taylor expanded in y around 0 86.6%
*-lft-identity86.6%
associate-*l/86.3%
associate-*r*86.3%
associate-*r/86.3%
metadata-eval86.3%
Simplified86.3%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.5e+19) (not (<= x 6.6e+14))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+19) || !(x <= 6.6e+14)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.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 <= (-3.5d+19)) .or. (.not. (x <= 6.6d+14))) then
tmp = 4.0d0 * (x / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+19) || !(x <= 6.6e+14)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.5e+19) or not (x <= 6.6e+14): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.5e+19) || !(x <= 6.6e+14)) tmp = Float64(4.0 * Float64(x / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.5e+19) || ~((x <= 6.6e+14))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.5e+19], N[Not[LessEqual[x, 6.6e+14]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+19} \lor \neg \left(x \leq 6.6 \cdot 10^{+14}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -3.5e19 or 6.6e14 < x Initial program 99.9%
Taylor expanded in x around inf 61.3%
if -3.5e19 < x < 6.6e14Initial program 99.8%
Taylor expanded in y around inf 46.6%
Final simplification54.2%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.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
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 30.9%
herbie shell --seed 2024186
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))