
(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 8 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 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* z -4.0) y)))
(if (<= y -490000000.0)
4.0
(if (<= y -1.55e-74)
t_0
(if (<= y -1.15e-142)
(* x (/ 4.0 y))
(if (<= y -1.7e-279)
t_0
(if (<= y 5.2e-102)
(/ 4.0 (/ y x))
(if (<= y 1.8e+63) t_0 4.0))))))))
double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (y <= -490000000.0) {
tmp = 4.0;
} else if (y <= -1.55e-74) {
tmp = t_0;
} else if (y <= -1.15e-142) {
tmp = x * (4.0 / y);
} else if (y <= -1.7e-279) {
tmp = t_0;
} else if (y <= 5.2e-102) {
tmp = 4.0 / (y / x);
} else if (y <= 1.8e+63) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z * (-4.0d0)) / y
if (y <= (-490000000.0d0)) then
tmp = 4.0d0
else if (y <= (-1.55d-74)) then
tmp = t_0
else if (y <= (-1.15d-142)) then
tmp = x * (4.0d0 / y)
else if (y <= (-1.7d-279)) then
tmp = t_0
else if (y <= 5.2d-102) then
tmp = 4.0d0 / (y / x)
else if (y <= 1.8d+63) then
tmp = t_0
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (y <= -490000000.0) {
tmp = 4.0;
} else if (y <= -1.55e-74) {
tmp = t_0;
} else if (y <= -1.15e-142) {
tmp = x * (4.0 / y);
} else if (y <= -1.7e-279) {
tmp = t_0;
} else if (y <= 5.2e-102) {
tmp = 4.0 / (y / x);
} else if (y <= 1.8e+63) {
tmp = t_0;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * -4.0) / y tmp = 0 if y <= -490000000.0: tmp = 4.0 elif y <= -1.55e-74: tmp = t_0 elif y <= -1.15e-142: tmp = x * (4.0 / y) elif y <= -1.7e-279: tmp = t_0 elif y <= 5.2e-102: tmp = 4.0 / (y / x) elif y <= 1.8e+63: tmp = t_0 else: tmp = 4.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * -4.0) / y) tmp = 0.0 if (y <= -490000000.0) tmp = 4.0; elseif (y <= -1.55e-74) tmp = t_0; elseif (y <= -1.15e-142) tmp = Float64(x * Float64(4.0 / y)); elseif (y <= -1.7e-279) tmp = t_0; elseif (y <= 5.2e-102) tmp = Float64(4.0 / Float64(y / x)); elseif (y <= 1.8e+63) tmp = t_0; else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * -4.0) / y; tmp = 0.0; if (y <= -490000000.0) tmp = 4.0; elseif (y <= -1.55e-74) tmp = t_0; elseif (y <= -1.15e-142) tmp = x * (4.0 / y); elseif (y <= -1.7e-279) tmp = t_0; elseif (y <= 5.2e-102) tmp = 4.0 / (y / x); elseif (y <= 1.8e+63) tmp = t_0; else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -490000000.0], 4.0, If[LessEqual[y, -1.55e-74], t$95$0, If[LessEqual[y, -1.15e-142], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.7e-279], t$95$0, If[LessEqual[y, 5.2e-102], N[(4.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+63], t$95$0, 4.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z \cdot -4}{y}\\
\mathbf{if}\;y \leq -490000000:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-74}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{-142}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-279}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{4}{\frac{y}{x}}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -4.9e8 or 1.79999999999999999e63 < y Initial program 99.9%
Taylor expanded in y around inf 65.4%
if -4.9e8 < y < -1.5500000000000001e-74 or -1.15000000000000001e-142 < y < -1.70000000000000007e-279 or 5.19999999999999973e-102 < y < 1.79999999999999999e63Initial program 100.0%
Taylor expanded in x around 0 96.3%
+-commutative96.3%
distribute-lft-out96.3%
Simplified96.3%
Taylor expanded in y around 0 89.6%
Taylor expanded in x around 0 62.3%
associate-*r/62.3%
Simplified62.3%
if -1.5500000000000001e-74 < y < -1.15000000000000001e-142Initial program 100.0%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in y around 0 76.8%
Taylor expanded in x around inf 61.0%
*-commutative61.0%
associate-*l/61.0%
associate-/l*61.0%
Simplified61.0%
if -1.70000000000000007e-279 < y < 5.19999999999999973e-102Initial program 99.9%
Taylor expanded in x around 0 95.6%
+-commutative95.6%
distribute-lft-out95.6%
Simplified95.6%
Taylor expanded in y around 0 91.1%
clear-num91.1%
un-div-inv91.1%
Applied egg-rr91.1%
Taylor expanded in x around inf 69.6%
Final simplification64.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.2e+86)
4.0
(if (or (<= y 3.2e+73) (and (not (<= y 4.4e+119)) (<= y 3.3e+155)))
(* 4.0 (/ (- x z) y))
4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.2e+86) {
tmp = 4.0;
} else if ((y <= 3.2e+73) || (!(y <= 4.4e+119) && (y <= 3.3e+155))) {
tmp = 4.0 * ((x - z) / 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 <= (-1.2d+86)) then
tmp = 4.0d0
else if ((y <= 3.2d+73) .or. (.not. (y <= 4.4d+119)) .and. (y <= 3.3d+155)) then
tmp = 4.0d0 * ((x - z) / 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 <= -1.2e+86) {
tmp = 4.0;
} else if ((y <= 3.2e+73) || (!(y <= 4.4e+119) && (y <= 3.3e+155))) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.2e+86: tmp = 4.0 elif (y <= 3.2e+73) or (not (y <= 4.4e+119) and (y <= 3.3e+155)): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.2e+86) tmp = 4.0; elseif ((y <= 3.2e+73) || (!(y <= 4.4e+119) && (y <= 3.3e+155))) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.2e+86) tmp = 4.0; elseif ((y <= 3.2e+73) || (~((y <= 4.4e+119)) && (y <= 3.3e+155))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.2e+86], 4.0, If[Or[LessEqual[y, 3.2e+73], And[N[Not[LessEqual[y, 4.4e+119]], $MachinePrecision], LessEqual[y, 3.3e+155]]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+86}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+73} \lor \neg \left(y \leq 4.4 \cdot 10^{+119}\right) \land y \leq 3.3 \cdot 10^{+155}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.2e86 or 3.19999999999999982e73 < y < 4.4000000000000003e119 or 3.2999999999999999e155 < y Initial program 99.9%
Taylor expanded in y around inf 79.0%
if -1.2e86 < y < 3.19999999999999982e73 or 4.4000000000000003e119 < y < 3.2999999999999999e155Initial program 99.9%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
distribute-lft-out97.1%
Simplified97.1%
Taylor expanded in y around 0 84.1%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* z -4.0) y)))
(if (<= y -760000000.0)
4.0
(if (<= y -1.2e-279)
t_0
(if (<= y 8.8e-102) (/ (* 4.0 x) y) (if (<= y 3.25e+63) t_0 4.0))))))
double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (y <= -760000000.0) {
tmp = 4.0;
} else if (y <= -1.2e-279) {
tmp = t_0;
} else if (y <= 8.8e-102) {
tmp = (4.0 * x) / y;
} else if (y <= 3.25e+63) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z * (-4.0d0)) / y
if (y <= (-760000000.0d0)) then
tmp = 4.0d0
else if (y <= (-1.2d-279)) then
tmp = t_0
else if (y <= 8.8d-102) then
tmp = (4.0d0 * x) / y
else if (y <= 3.25d+63) then
tmp = t_0
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (y <= -760000000.0) {
tmp = 4.0;
} else if (y <= -1.2e-279) {
tmp = t_0;
} else if (y <= 8.8e-102) {
tmp = (4.0 * x) / y;
} else if (y <= 3.25e+63) {
tmp = t_0;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * -4.0) / y tmp = 0 if y <= -760000000.0: tmp = 4.0 elif y <= -1.2e-279: tmp = t_0 elif y <= 8.8e-102: tmp = (4.0 * x) / y elif y <= 3.25e+63: tmp = t_0 else: tmp = 4.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * -4.0) / y) tmp = 0.0 if (y <= -760000000.0) tmp = 4.0; elseif (y <= -1.2e-279) tmp = t_0; elseif (y <= 8.8e-102) tmp = Float64(Float64(4.0 * x) / y); elseif (y <= 3.25e+63) tmp = t_0; else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * -4.0) / y; tmp = 0.0; if (y <= -760000000.0) tmp = 4.0; elseif (y <= -1.2e-279) tmp = t_0; elseif (y <= 8.8e-102) tmp = (4.0 * x) / y; elseif (y <= 3.25e+63) tmp = t_0; else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -760000000.0], 4.0, If[LessEqual[y, -1.2e-279], t$95$0, If[LessEqual[y, 8.8e-102], N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 3.25e+63], t$95$0, 4.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z \cdot -4}{y}\\
\mathbf{if}\;y \leq -760000000:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -1.2 \cdot 10^{-279}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-102}:\\
\;\;\;\;\frac{4 \cdot x}{y}\\
\mathbf{elif}\;y \leq 3.25 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -7.6e8 or 3.24999999999999996e63 < y Initial program 99.9%
Taylor expanded in y around inf 65.4%
if -7.6e8 < y < -1.19999999999999995e-279 or 8.80000000000000052e-102 < y < 3.24999999999999996e63Initial program 100.0%
Taylor expanded in x around 0 96.8%
+-commutative96.8%
distribute-lft-out96.8%
Simplified96.8%
Taylor expanded in y around 0 87.9%
Taylor expanded in x around 0 56.5%
associate-*r/56.5%
Simplified56.5%
if -1.19999999999999995e-279 < y < 8.80000000000000052e-102Initial program 99.9%
Taylor expanded in x around 0 95.6%
+-commutative95.6%
distribute-lft-out95.6%
Simplified95.6%
Taylor expanded in y around 0 91.1%
Taylor expanded in x around inf 69.6%
associate-*r/69.6%
Simplified69.6%
Final simplification62.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.5e+54) (not (<= z 2.7e+57))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e+54) || !(z <= 2.7e+57)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / 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 <= (-9.5d+54)) .or. (.not. (z <= 2.7d+57))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e+54) || !(z <= 2.7e+57)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.5e+54) or not (z <= 2.7e+57): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.5e+54) || !(z <= 2.7e+57)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.5e+54) || ~((z <= 2.7e+57))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.5e+54], N[Not[LessEqual[z, 2.7e+57]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+54} \lor \neg \left(z \leq 2.7 \cdot 10^{+57}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -9.4999999999999999e54 or 2.6999999999999998e57 < z Initial program 99.9%
Taylor expanded in x around 0 94.6%
+-commutative94.6%
distribute-lft-out94.6%
Simplified94.6%
Taylor expanded in y around 0 80.9%
if -9.4999999999999999e54 < z < 2.6999999999999998e57Initial 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 z around 0 94.7%
distribute-lft-in94.7%
metadata-eval94.7%
associate-+r+94.7%
metadata-eval94.7%
Simplified94.7%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.75e+60) (not (<= z 9.2e+51))) (+ 4.0 (/ (* z -4.0) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+60) || !(z <= 9.2e+51)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + (4.0 * (x / 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.75d+60)) .or. (.not. (z <= 9.2d+51))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+60) || !(z <= 9.2e+51)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.75e+60) or not (z <= 9.2e+51): tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.75e+60) || !(z <= 9.2e+51)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.75e+60) || ~((z <= 9.2e+51))) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.75e+60], N[Not[LessEqual[z, 9.2e+51]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+60} \lor \neg \left(z \leq 9.2 \cdot 10^{+51}\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -2.75e60 or 9.2000000000000002e51 < z Initial program 100.0%
+-commutative100.0%
associate-/l*100.0%
fma-define100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
associate--r+100.0%
div-sub100.0%
sub-neg100.0%
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 91.8%
sub-neg91.8%
distribute-lft-in91.8%
metadata-eval91.8%
associate-+r+91.8%
metadata-eval91.8%
neg-mul-191.8%
associate-*r*91.8%
metadata-eval91.8%
*-commutative91.8%
associate-*l/91.8%
Simplified91.8%
if -2.75e60 < z < 9.2000000000000002e51Initial 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 z around 0 94.6%
distribute-lft-in94.6%
metadata-eval94.6%
associate-+r+94.6%
metadata-eval94.6%
Simplified94.6%
Final simplification93.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e+47) 4.0 (if (<= y 6.1e-58) (* x (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+47) {
tmp = 4.0;
} else if (y <= 6.1e-58) {
tmp = x * (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 <= (-1.4d+47)) then
tmp = 4.0d0
else if (y <= 6.1d-58) then
tmp = x * (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 <= -1.4e+47) {
tmp = 4.0;
} else if (y <= 6.1e-58) {
tmp = x * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e+47: tmp = 4.0 elif y <= 6.1e-58: tmp = x * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e+47) tmp = 4.0; elseif (y <= 6.1e-58) tmp = Float64(x * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e+47) tmp = 4.0; elseif (y <= 6.1e-58) tmp = x * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e+47], 4.0, If[LessEqual[y, 6.1e-58], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+47}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{-58}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.39999999999999994e47 or 6.1000000000000003e-58 < y Initial program 99.9%
Taylor expanded in y around inf 62.1%
if -1.39999999999999994e47 < y < 6.1000000000000003e-58Initial program 99.9%
Taylor expanded in x around 0 96.1%
+-commutative96.1%
distribute-lft-out96.1%
Simplified96.1%
Taylor expanded in y around 0 89.5%
Taylor expanded in x around inf 52.0%
*-commutative52.0%
associate-*l/52.0%
associate-/l*51.9%
Simplified51.9%
Final simplification56.9%
(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 35.7%
Final simplification35.7%
herbie shell --seed 2024053
(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)))