
(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 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (/ (* z -4.0) y)))
(if (<= y -2.65e+64)
4.0
(if (<= y -6.5e-129)
t_1
(if (<= y -1.45e-217)
t_0
(if (<= y 2.3e-265) t_1 (if (<= y 3.4e-25) t_0 4.0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = (z * -4.0) / y;
double tmp;
if (y <= -2.65e+64) {
tmp = 4.0;
} else if (y <= -6.5e-129) {
tmp = t_1;
} else if (y <= -1.45e-217) {
tmp = t_0;
} else if (y <= 2.3e-265) {
tmp = t_1;
} else if (y <= 3.4e-25) {
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) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
t_1 = (z * (-4.0d0)) / y
if (y <= (-2.65d+64)) then
tmp = 4.0d0
else if (y <= (-6.5d-129)) then
tmp = t_1
else if (y <= (-1.45d-217)) then
tmp = t_0
else if (y <= 2.3d-265) then
tmp = t_1
else if (y <= 3.4d-25) 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 = 4.0 * (x / y);
double t_1 = (z * -4.0) / y;
double tmp;
if (y <= -2.65e+64) {
tmp = 4.0;
} else if (y <= -6.5e-129) {
tmp = t_1;
} else if (y <= -1.45e-217) {
tmp = t_0;
} else if (y <= 2.3e-265) {
tmp = t_1;
} else if (y <= 3.4e-25) {
tmp = t_0;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = (z * -4.0) / y tmp = 0 if y <= -2.65e+64: tmp = 4.0 elif y <= -6.5e-129: tmp = t_1 elif y <= -1.45e-217: tmp = t_0 elif y <= 2.3e-265: tmp = t_1 elif y <= 3.4e-25: tmp = t_0 else: tmp = 4.0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(Float64(z * -4.0) / y) tmp = 0.0 if (y <= -2.65e+64) tmp = 4.0; elseif (y <= -6.5e-129) tmp = t_1; elseif (y <= -1.45e-217) tmp = t_0; elseif (y <= 2.3e-265) tmp = t_1; elseif (y <= 3.4e-25) tmp = t_0; else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = (z * -4.0) / y; tmp = 0.0; if (y <= -2.65e+64) tmp = 4.0; elseif (y <= -6.5e-129) tmp = t_1; elseif (y <= -1.45e-217) tmp = t_0; elseif (y <= 2.3e-265) tmp = t_1; elseif (y <= 3.4e-25) tmp = t_0; else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -2.65e+64], 4.0, If[LessEqual[y, -6.5e-129], t$95$1, If[LessEqual[y, -1.45e-217], t$95$0, If[LessEqual[y, 2.3e-265], t$95$1, If[LessEqual[y, 3.4e-25], t$95$0, 4.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := \frac{z \cdot -4}{y}\\
\mathbf{if}\;y \leq -2.65 \cdot 10^{+64}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-217}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-265}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -2.6500000000000001e64 or 3.40000000000000002e-25 < y Initial program 99.8%
Taylor expanded in y around inf 68.6%
if -2.6500000000000001e64 < y < -6.49999999999999952e-129 or -1.44999999999999991e-217 < y < 2.2999999999999999e-265Initial program 100.0%
Taylor expanded in x around 0 67.0%
+-commutative67.0%
fma-define67.0%
div-sub67.0%
associate-/l*67.1%
*-inverses67.1%
metadata-eval67.1%
fma-define67.1%
+-commutative67.1%
sub-neg67.1%
distribute-lft-in67.1%
metadata-eval67.1%
associate-+r+67.1%
metadata-eval67.1%
neg-mul-167.1%
associate-*r*67.1%
metadata-eval67.1%
*-commutative67.1%
associate-*l/67.1%
Simplified67.1%
Taylor expanded in z around inf 57.5%
associate-*r/57.5%
Simplified57.5%
if -6.49999999999999952e-129 < y < -1.44999999999999991e-217 or 2.2999999999999999e-265 < y < 3.40000000000000002e-25Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in x around inf 61.2%
Final simplification63.4%
(FPCore (x y z)
:precision binary64
(if (<= y -3e+77)
4.0
(if (or (<= y 7.5e-7) (and (not (<= y 4.1e+42)) (<= y 1.46e+128)))
(* (- x z) (/ 4.0 y))
4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+77) {
tmp = 4.0;
} else if ((y <= 7.5e-7) || (!(y <= 4.1e+42) && (y <= 1.46e+128))) {
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 <= (-3d+77)) then
tmp = 4.0d0
else if ((y <= 7.5d-7) .or. (.not. (y <= 4.1d+42)) .and. (y <= 1.46d+128)) 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 <= -3e+77) {
tmp = 4.0;
} else if ((y <= 7.5e-7) || (!(y <= 4.1e+42) && (y <= 1.46e+128))) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3e+77: tmp = 4.0 elif (y <= 7.5e-7) or (not (y <= 4.1e+42) and (y <= 1.46e+128)): tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3e+77) tmp = 4.0; elseif ((y <= 7.5e-7) || (!(y <= 4.1e+42) && (y <= 1.46e+128))) 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 <= -3e+77) tmp = 4.0; elseif ((y <= 7.5e-7) || (~((y <= 4.1e+42)) && (y <= 1.46e+128))) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3e+77], 4.0, If[Or[LessEqual[y, 7.5e-7], And[N[Not[LessEqual[y, 4.1e+42]], $MachinePrecision], LessEqual[y, 1.46e+128]]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+77}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-7} \lor \neg \left(y \leq 4.1 \cdot 10^{+42}\right) \land y \leq 1.46 \cdot 10^{+128}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -2.9999999999999998e77 or 7.5000000000000002e-7 < y < 4.1e42 or 1.4599999999999999e128 < y Initial program 99.8%
Taylor expanded in y around inf 77.8%
if -2.9999999999999998e77 < y < 7.5000000000000002e-7 or 4.1e42 < y < 1.4599999999999999e128Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 89.2%
associate-*r/89.2%
associate-*l/88.9%
Simplified88.9%
Final simplification85.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 4.0 (/ (* z -4.0) y))))
(if (<= y -1.18e+70)
t_0
(if (<= y 4.4e-32)
(* (- x z) (/ 4.0 y))
(if (<= y 6e+107) t_0 (+ 4.0 (/ (* 4.0 x) y)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 + ((z * -4.0) / y);
double tmp;
if (y <= -1.18e+70) {
tmp = t_0;
} else if (y <= 4.4e-32) {
tmp = (x - z) * (4.0 / y);
} else if (y <= 6e+107) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 4.0d0 + ((z * (-4.0d0)) / y)
if (y <= (-1.18d+70)) then
tmp = t_0
else if (y <= 4.4d-32) then
tmp = (x - z) * (4.0d0 / y)
else if (y <= 6d+107) then
tmp = t_0
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 t_0 = 4.0 + ((z * -4.0) / y);
double tmp;
if (y <= -1.18e+70) {
tmp = t_0;
} else if (y <= 4.4e-32) {
tmp = (x - z) * (4.0 / y);
} else if (y <= 6e+107) {
tmp = t_0;
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 + ((z * -4.0) / y) tmp = 0 if y <= -1.18e+70: tmp = t_0 elif y <= 4.4e-32: tmp = (x - z) * (4.0 / y) elif y <= 6e+107: tmp = t_0 else: tmp = 4.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) t_0 = Float64(4.0 + Float64(Float64(z * -4.0) / y)) tmp = 0.0 if (y <= -1.18e+70) tmp = t_0; elseif (y <= 4.4e-32) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (y <= 6e+107) tmp = t_0; else tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 + ((z * -4.0) / y); tmp = 0.0; if (y <= -1.18e+70) tmp = t_0; elseif (y <= 4.4e-32) tmp = (x - z) * (4.0 / y); elseif (y <= 6e+107) tmp = t_0; else tmp = 4.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.18e+70], t$95$0, If[LessEqual[y, 4.4e-32], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+107], t$95$0, N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 + \frac{z \cdot -4}{y}\\
\mathbf{if}\;y \leq -1.18 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-32}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+107}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if y < -1.18000000000000001e70 or 4.4e-32 < y < 6.00000000000000046e107Initial program 99.8%
Taylor expanded in x around 0 88.5%
+-commutative88.5%
fma-define88.5%
div-sub88.5%
associate-/l*88.6%
*-inverses88.6%
metadata-eval88.6%
fma-define88.6%
+-commutative88.6%
sub-neg88.6%
distribute-lft-in88.6%
metadata-eval88.6%
associate-+r+88.7%
metadata-eval88.7%
neg-mul-188.7%
associate-*r*88.7%
metadata-eval88.7%
*-commutative88.7%
associate-*l/88.7%
Simplified88.7%
if -1.18000000000000001e70 < y < 4.4e-32Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 92.5%
associate-*r/92.5%
associate-*l/92.3%
Simplified92.3%
if 6.00000000000000046e107 < y 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-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 z around 0 94.4%
distribute-lft-in94.4%
metadata-eval94.4%
associate-+r+94.4%
metadata-eval94.4%
associate-*r/94.4%
Simplified94.4%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8e+66) (not (<= y 4.5e-39))) (+ 4.0 (/ (* 4.0 x) y)) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+66) || !(y <= 4.5e-39)) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = (x - 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 ((y <= (-8d+66)) .or. (.not. (y <= 4.5d-39))) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else
tmp = (x - z) * (4.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+66) || !(y <= 4.5e-39)) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8e+66) or not (y <= 4.5e-39): tmp = 4.0 + ((4.0 * x) / y) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8e+66) || !(y <= 4.5e-39)) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(Float64(x - z) * Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8e+66) || ~((y <= 4.5e-39))) tmp = 4.0 + ((4.0 * x) / y); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8e+66], N[Not[LessEqual[y, 4.5e-39]], $MachinePrecision]], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+66} \lor \neg \left(y \leq 4.5 \cdot 10^{-39}\right):\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -7.99999999999999956e66 or 4.5000000000000001e-39 < y 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 z around 0 84.6%
distribute-lft-in84.6%
metadata-eval84.6%
associate-+r+84.6%
metadata-eval84.6%
associate-*r/84.6%
Simplified84.6%
if -7.99999999999999956e66 < y < 4.5000000000000001e-39Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 92.4%
associate-*r/92.4%
associate-*l/92.2%
Simplified92.2%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e+67) 4.0 (if (<= y 3.4e-25) (* 4.0 (/ x y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+67) {
tmp = 4.0;
} else if (y <= 3.4e-25) {
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 (y <= (-4.2d+67)) then
tmp = 4.0d0
else if (y <= 3.4d-25) 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 (y <= -4.2e+67) {
tmp = 4.0;
} else if (y <= 3.4e-25) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+67: tmp = 4.0 elif y <= 3.4e-25: tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+67) tmp = 4.0; elseif (y <= 3.4e-25) 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 (y <= -4.2e+67) tmp = 4.0; elseif (y <= 3.4e-25) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+67], 4.0, If[LessEqual[y, 3.4e-25], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+67}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-25}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -4.2000000000000003e67 or 3.40000000000000002e-25 < y Initial program 99.8%
Taylor expanded in y around inf 69.2%
if -4.2000000000000003e67 < y < 3.40000000000000002e-25Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in x around inf 49.4%
Final simplification58.0%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (+ x y) z)) y))
double code(double x, double y, double z) {
return (4.0 * ((x + y) - 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 * ((x + y) - z)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x + y) - z)) / y;
}
def code(x, y, z): return (4.0 * ((x + y) - z)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x + y) - z)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x + y) - z)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x + y\right) - z\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
associate-+r-100.0%
Simplified100.0%
Final simplification100.0%
(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.6%
Final simplification35.6%
herbie shell --seed 2024059
(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)))