
(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 (+ 1.0 (+ (/ (* 4.0 (- x z)) y) 3.0)))
double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.0);
}
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 - z)) / y) + 3.0d0)
end function
public static double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.0);
}
def code(x, y, z): return 1.0 + (((4.0 * (x - z)) / y) + 3.0)
function code(x, y, z) return Float64(1.0 + Float64(Float64(Float64(4.0 * Float64(x - z)) / y) + 3.0)) end
function tmp = code(x, y, z) tmp = 1.0 + (((4.0 * (x - z)) / y) + 3.0); end
code[x_, y_, z_] := N[(1.0 + N[(N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{4 \cdot \left(x - z\right)}{y} + 3\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -1.32e+118)
t_1
(if (<= x -2.8e+79)
t_0
(if (<= x -6.5e+45)
t_1
(if (<= x -3e-63) 4.0 (if (<= x 9.5e+46) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -2.8e+79) {
tmp = t_0;
} else if (x <= -6.5e+45) {
tmp = t_1;
} else if (x <= -3e-63) {
tmp = 4.0;
} else if (x <= 9.5e+46) {
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 = 1.0d0 + (z * ((-4.0d0) / y))
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-1.32d+118)) then
tmp = t_1
else if (x <= (-2.8d+79)) then
tmp = t_0
else if (x <= (-6.5d+45)) then
tmp = t_1
else if (x <= (-3d-63)) then
tmp = 4.0d0
else if (x <= 9.5d+46) 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 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -2.8e+79) {
tmp = t_0;
} else if (x <= -6.5e+45) {
tmp = t_1;
} else if (x <= -3e-63) {
tmp = 4.0;
} else if (x <= 9.5e+46) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -1.32e+118: tmp = t_1 elif x <= -2.8e+79: tmp = t_0 elif x <= -6.5e+45: tmp = t_1 elif x <= -3e-63: tmp = 4.0 elif x <= 9.5e+46: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -1.32e+118) tmp = t_1; elseif (x <= -2.8e+79) tmp = t_0; elseif (x <= -6.5e+45) tmp = t_1; elseif (x <= -3e-63) tmp = 4.0; elseif (x <= 9.5e+46) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (-4.0 / y)); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -1.32e+118) tmp = t_1; elseif (x <= -2.8e+79) tmp = t_0; elseif (x <= -6.5e+45) tmp = t_1; elseif (x <= -3e-63) tmp = 4.0; elseif (x <= 9.5e+46) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.32e+118], t$95$1, If[LessEqual[x, -2.8e+79], t$95$0, If[LessEqual[x, -6.5e+45], t$95$1, If[LessEqual[x, -3e-63], 4.0, If[LessEqual[x, 9.5e+46], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-63}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.3199999999999999e118 or -2.8000000000000001e79 < x < -6.50000000000000034e45 or 9.5000000000000008e46 < x Initial program 100.0%
Taylor expanded in x around inf 73.3%
*-commutative73.3%
Simplified73.3%
if -1.3199999999999999e118 < x < -2.8000000000000001e79 or -2.99999999999999979e-63 < x < 9.5000000000000008e46Initial program 99.9%
Taylor expanded in z around inf 56.7%
metadata-eval56.7%
distribute-lft-neg-in56.7%
*-lft-identity56.7%
associate-*l/56.5%
associate-*l*56.5%
*-commutative56.5%
distribute-rgt-neg-in56.5%
associate-*r/56.5%
metadata-eval56.5%
distribute-neg-frac56.5%
metadata-eval56.5%
Simplified56.5%
if -6.50000000000000034e45 < x < -2.99999999999999979e-63Initial program 99.9%
Taylor expanded in x around 0 71.0%
div-sub71.0%
associate-/l*71.1%
*-inverses71.1%
metadata-eval71.1%
sub-neg71.1%
distribute-lft-in71.1%
metadata-eval71.1%
distribute-rgt-neg-in71.1%
*-lft-identity71.1%
associate-*l/71.1%
associate-*l*71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in z around 0 66.2%
Final simplification64.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -1.1e+119)
t_1
(if (<= x -2.35e+75)
t_0
(if (<= x -1.9e+47)
t_1
(if (<= x -6e-65) 4.0 (if (<= x 1.95e+52) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -1.1e+119) {
tmp = t_1;
} else if (x <= -2.35e+75) {
tmp = t_0;
} else if (x <= -1.9e+47) {
tmp = t_1;
} else if (x <= -6e-65) {
tmp = 4.0;
} else if (x <= 1.95e+52) {
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 = 1.0d0 + ((z * (-4.0d0)) / y)
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-1.1d+119)) then
tmp = t_1
else if (x <= (-2.35d+75)) then
tmp = t_0
else if (x <= (-1.9d+47)) then
tmp = t_1
else if (x <= (-6d-65)) then
tmp = 4.0d0
else if (x <= 1.95d+52) 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 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -1.1e+119) {
tmp = t_1;
} else if (x <= -2.35e+75) {
tmp = t_0;
} else if (x <= -1.9e+47) {
tmp = t_1;
} else if (x <= -6e-65) {
tmp = 4.0;
} else if (x <= 1.95e+52) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -1.1e+119: tmp = t_1 elif x <= -2.35e+75: tmp = t_0 elif x <= -1.9e+47: tmp = t_1 elif x <= -6e-65: tmp = 4.0 elif x <= 1.95e+52: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -1.1e+119) tmp = t_1; elseif (x <= -2.35e+75) tmp = t_0; elseif (x <= -1.9e+47) tmp = t_1; elseif (x <= -6e-65) tmp = 4.0; elseif (x <= 1.95e+52) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z * -4.0) / y); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -1.1e+119) tmp = t_1; elseif (x <= -2.35e+75) tmp = t_0; elseif (x <= -1.9e+47) tmp = t_1; elseif (x <= -6e-65) tmp = 4.0; elseif (x <= 1.95e+52) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.1e+119], t$95$1, If[LessEqual[x, -2.35e+75], t$95$0, If[LessEqual[x, -1.9e+47], t$95$1, If[LessEqual[x, -6e-65], 4.0, If[LessEqual[x, 1.95e+52], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.35 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-65}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+52}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.1000000000000001e119 or -2.34999999999999992e75 < x < -1.9000000000000002e47 or 1.95e52 < x Initial program 100.0%
Taylor expanded in x around inf 73.3%
*-commutative73.3%
Simplified73.3%
if -1.1000000000000001e119 < x < -2.34999999999999992e75 or -5.99999999999999996e-65 < x < 1.95e52Initial program 99.9%
Taylor expanded in z around inf 56.7%
*-commutative56.7%
associate-*l/56.7%
Simplified56.7%
if -1.9000000000000002e47 < x < -5.99999999999999996e-65Initial program 99.9%
Taylor expanded in x around 0 71.0%
div-sub71.0%
associate-/l*71.1%
*-inverses71.1%
metadata-eval71.1%
sub-neg71.1%
distribute-lft-in71.1%
metadata-eval71.1%
distribute-rgt-neg-in71.1%
*-lft-identity71.1%
associate-*l/71.1%
associate-*l*71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in z around 0 66.2%
Final simplification64.3%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.32e+118)
(not (or (<= x -2.1e+79) (and (not (<= x -2.2e-55)) (<= x 1.8e+44)))))
(+ 1.0 (+ 3.0 (* 4.0 (/ x y))))
(+ 4.0 (/ (* z -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.32e+118) || !((x <= -2.1e+79) || (!(x <= -2.2e-55) && (x <= 1.8e+44)))) {
tmp = 1.0 + (3.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 ((x <= (-1.32d+118)) .or. (.not. (x <= (-2.1d+79)) .or. (.not. (x <= (-2.2d-55))) .and. (x <= 1.8d+44))) then
tmp = 1.0d0 + (3.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 ((x <= -1.32e+118) || !((x <= -2.1e+79) || (!(x <= -2.2e-55) && (x <= 1.8e+44)))) {
tmp = 1.0 + (3.0 + (4.0 * (x / y)));
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.32e+118) or not ((x <= -2.1e+79) or (not (x <= -2.2e-55) and (x <= 1.8e+44))): tmp = 1.0 + (3.0 + (4.0 * (x / y))) else: tmp = 4.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.32e+118) || !((x <= -2.1e+79) || (!(x <= -2.2e-55) && (x <= 1.8e+44)))) tmp = Float64(1.0 + Float64(3.0 + Float64(4.0 * Float64(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 ((x <= -1.32e+118) || ~(((x <= -2.1e+79) || (~((x <= -2.2e-55)) && (x <= 1.8e+44))))) tmp = 1.0 + (3.0 + (4.0 * (x / y))); else tmp = 4.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.32e+118], N[Not[Or[LessEqual[x, -2.1e+79], And[N[Not[LessEqual[x, -2.2e-55]], $MachinePrecision], LessEqual[x, 1.8e+44]]]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{+118} \lor \neg \left(x \leq -2.1 \cdot 10^{+79} \lor \neg \left(x \leq -2.2 \cdot 10^{-55}\right) \land x \leq 1.8 \cdot 10^{+44}\right):\\
\;\;\;\;1 + \left(3 + 4 \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if x < -1.3199999999999999e118 or -2.10000000000000008e79 < x < -2.2e-55 or 1.8e44 < x Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 89.2%
if -1.3199999999999999e118 < x < -2.10000000000000008e79 or -2.2e-55 < x < 1.8e44Initial program 99.9%
Taylor expanded in x around 0 94.0%
div-sub94.0%
associate-/l*94.1%
*-inverses94.1%
metadata-eval94.1%
sub-neg94.1%
distribute-lft-in94.1%
metadata-eval94.1%
distribute-rgt-neg-in94.1%
*-lft-identity94.1%
associate-*l/93.9%
associate-*l*93.9%
*-commutative93.9%
distribute-rgt-neg-in93.9%
associate-*r/93.9%
metadata-eval93.9%
distribute-neg-frac93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in z around 0 94.1%
associate-*r/94.1%
Simplified94.1%
Final simplification91.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 4.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (+ 3.0 (* 4.0 (/ x y))))))
(if (<= x -1.32e+118)
t_1
(if (<= x -1.6e+76)
t_0
(if (<= x -2.75e-55)
t_1
(if (<= x 5.9e+52) t_0 (+ 1.0 (/ 4.0 (/ y (- x z))))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (3.0 + (4.0 * (x / y)));
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -1.6e+76) {
tmp = t_0;
} else if (x <= -2.75e-55) {
tmp = t_1;
} else if (x <= 5.9e+52) {
tmp = t_0;
} else {
tmp = 1.0 + (4.0 / (y / (x - z)));
}
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 * (-4.0d0)) / y)
t_1 = 1.0d0 + (3.0d0 + (4.0d0 * (x / y)))
if (x <= (-1.32d+118)) then
tmp = t_1
else if (x <= (-1.6d+76)) then
tmp = t_0
else if (x <= (-2.75d-55)) then
tmp = t_1
else if (x <= 5.9d+52) then
tmp = t_0
else
tmp = 1.0d0 + (4.0d0 / (y / (x - z)))
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 t_1 = 1.0 + (3.0 + (4.0 * (x / y)));
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -1.6e+76) {
tmp = t_0;
} else if (x <= -2.75e-55) {
tmp = t_1;
} else if (x <= 5.9e+52) {
tmp = t_0;
} else {
tmp = 1.0 + (4.0 / (y / (x - z)));
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 + ((z * -4.0) / y) t_1 = 1.0 + (3.0 + (4.0 * (x / y))) tmp = 0 if x <= -1.32e+118: tmp = t_1 elif x <= -1.6e+76: tmp = t_0 elif x <= -2.75e-55: tmp = t_1 elif x <= 5.9e+52: tmp = t_0 else: tmp = 1.0 + (4.0 / (y / (x - z))) return tmp
function code(x, y, z) t_0 = Float64(4.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(3.0 + Float64(4.0 * Float64(x / y)))) tmp = 0.0 if (x <= -1.32e+118) tmp = t_1; elseif (x <= -1.6e+76) tmp = t_0; elseif (x <= -2.75e-55) tmp = t_1; elseif (x <= 5.9e+52) tmp = t_0; else tmp = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 + ((z * -4.0) / y); t_1 = 1.0 + (3.0 + (4.0 * (x / y))); tmp = 0.0; if (x <= -1.32e+118) tmp = t_1; elseif (x <= -1.6e+76) tmp = t_0; elseif (x <= -2.75e-55) tmp = t_1; elseif (x <= 5.9e+52) tmp = t_0; else tmp = 1.0 + (4.0 / (y / (x - z))); 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]}, Block[{t$95$1 = N[(1.0 + N[(3.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.32e+118], t$95$1, If[LessEqual[x, -1.6e+76], t$95$0, If[LessEqual[x, -2.75e-55], t$95$1, If[LessEqual[x, 5.9e+52], t$95$0, N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 + \frac{z \cdot -4}{y}\\
t_1 := 1 + \left(3 + 4 \cdot \frac{x}{y}\right)\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.75 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{+52}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{4}{\frac{y}{x - z}}\\
\end{array}
\end{array}
if x < -1.3199999999999999e118 or -1.59999999999999988e76 < x < -2.7499999999999999e-55Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 92.7%
if -1.3199999999999999e118 < x < -1.59999999999999988e76 or -2.7499999999999999e-55 < x < 5.89999999999999996e52Initial program 99.9%
Taylor expanded in x around 0 94.0%
div-sub94.0%
associate-/l*94.1%
*-inverses94.1%
metadata-eval94.1%
sub-neg94.1%
distribute-lft-in94.1%
metadata-eval94.1%
distribute-rgt-neg-in94.1%
*-lft-identity94.1%
associate-*l/93.9%
associate-*l*93.9%
*-commutative93.9%
distribute-rgt-neg-in93.9%
associate-*r/93.9%
metadata-eval93.9%
distribute-neg-frac93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in z around 0 94.1%
associate-*r/94.1%
Simplified94.1%
if 5.89999999999999996e52 < x Initial program 99.9%
Taylor expanded in x around inf 86.7%
clear-num86.6%
inv-pow86.6%
*-un-lft-identity86.6%
times-frac86.6%
metadata-eval86.6%
Applied egg-rr86.6%
unpow-186.6%
associate-/r*86.6%
metadata-eval86.6%
Simplified86.6%
Final simplification92.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 4.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (+ 3.0 (* 4.0 (/ x y))))))
(if (<= x -1.7e+118)
t_1
(if (<= x -6.2e+78)
t_0
(if (<= x -2.25e-55)
t_1
(if (<= x 4.05e+43) t_0 (+ 1.0 (/ (* 4.0 (- x z)) y))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (3.0 + (4.0 * (x / y)));
double tmp;
if (x <= -1.7e+118) {
tmp = t_1;
} else if (x <= -6.2e+78) {
tmp = t_0;
} else if (x <= -2.25e-55) {
tmp = t_1;
} else if (x <= 4.05e+43) {
tmp = t_0;
} else {
tmp = 1.0 + ((4.0 * (x - z)) / 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) :: t_1
real(8) :: tmp
t_0 = 4.0d0 + ((z * (-4.0d0)) / y)
t_1 = 1.0d0 + (3.0d0 + (4.0d0 * (x / y)))
if (x <= (-1.7d+118)) then
tmp = t_1
else if (x <= (-6.2d+78)) then
tmp = t_0
else if (x <= (-2.25d-55)) then
tmp = t_1
else if (x <= 4.05d+43) then
tmp = t_0
else
tmp = 1.0d0 + ((4.0d0 * (x - z)) / 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 t_1 = 1.0 + (3.0 + (4.0 * (x / y)));
double tmp;
if (x <= -1.7e+118) {
tmp = t_1;
} else if (x <= -6.2e+78) {
tmp = t_0;
} else if (x <= -2.25e-55) {
tmp = t_1;
} else if (x <= 4.05e+43) {
tmp = t_0;
} else {
tmp = 1.0 + ((4.0 * (x - z)) / y);
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 + ((z * -4.0) / y) t_1 = 1.0 + (3.0 + (4.0 * (x / y))) tmp = 0 if x <= -1.7e+118: tmp = t_1 elif x <= -6.2e+78: tmp = t_0 elif x <= -2.25e-55: tmp = t_1 elif x <= 4.05e+43: tmp = t_0 else: tmp = 1.0 + ((4.0 * (x - z)) / y) return tmp
function code(x, y, z) t_0 = Float64(4.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(3.0 + Float64(4.0 * Float64(x / y)))) tmp = 0.0 if (x <= -1.7e+118) tmp = t_1; elseif (x <= -6.2e+78) tmp = t_0; elseif (x <= -2.25e-55) tmp = t_1; elseif (x <= 4.05e+43) tmp = t_0; else tmp = Float64(1.0 + Float64(Float64(4.0 * Float64(x - z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 + ((z * -4.0) / y); t_1 = 1.0 + (3.0 + (4.0 * (x / y))); tmp = 0.0; if (x <= -1.7e+118) tmp = t_1; elseif (x <= -6.2e+78) tmp = t_0; elseif (x <= -2.25e-55) tmp = t_1; elseif (x <= 4.05e+43) tmp = t_0; else tmp = 1.0 + ((4.0 * (x - z)) / 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]}, Block[{t$95$1 = N[(1.0 + N[(3.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e+118], t$95$1, If[LessEqual[x, -6.2e+78], t$95$0, If[LessEqual[x, -2.25e-55], t$95$1, If[LessEqual[x, 4.05e+43], t$95$0, N[(1.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 + \frac{z \cdot -4}{y}\\
t_1 := 1 + \left(3 + 4 \cdot \frac{x}{y}\right)\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.25 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.05 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{4 \cdot \left(x - z\right)}{y}\\
\end{array}
\end{array}
if x < -1.69999999999999993e118 or -6.2e78 < x < -2.24999999999999985e-55Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 92.7%
if -1.69999999999999993e118 < x < -6.2e78 or -2.24999999999999985e-55 < x < 4.0499999999999998e43Initial program 99.9%
Taylor expanded in x around 0 94.0%
div-sub94.0%
associate-/l*94.0%
*-inverses94.0%
metadata-eval94.0%
sub-neg94.0%
distribute-lft-in94.0%
metadata-eval94.0%
distribute-rgt-neg-in94.0%
*-lft-identity94.0%
associate-*l/93.9%
associate-*l*93.9%
*-commutative93.9%
distribute-rgt-neg-in93.9%
associate-*r/93.9%
metadata-eval93.9%
distribute-neg-frac93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in z around 0 94.0%
associate-*r/94.0%
Simplified94.0%
if 4.0499999999999998e43 < x Initial program 99.9%
Taylor expanded in x around inf 86.9%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.6e+34) (not (<= z 1.25e+58))) (+ 1.0 (* z (/ -4.0 y))) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.6e+34) || !(z <= 1.25e+58)) {
tmp = 1.0 + (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 ((z <= (-2.6d+34)) .or. (.not. (z <= 1.25d+58))) then
tmp = 1.0d0 + (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 ((z <= -2.6e+34) || !(z <= 1.25e+58)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.6e+34) or not (z <= 1.25e+58): tmp = 1.0 + (z * (-4.0 / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.6e+34) || !(z <= 1.25e+58)) tmp = Float64(1.0 + Float64(z * Float64(-4.0 / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.6e+34) || ~((z <= 1.25e+58))) tmp = 1.0 + (z * (-4.0 / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.6e+34], N[Not[LessEqual[z, 1.25e+58]], $MachinePrecision]], N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+34} \lor \neg \left(z \leq 1.25 \cdot 10^{+58}\right):\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -2.59999999999999997e34 or 1.24999999999999996e58 < z Initial program 99.9%
Taylor expanded in z around inf 67.0%
metadata-eval67.0%
distribute-lft-neg-in67.0%
*-lft-identity67.0%
associate-*l/66.9%
associate-*l*66.9%
*-commutative66.9%
distribute-rgt-neg-in66.9%
associate-*r/66.9%
metadata-eval66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
Simplified66.9%
if -2.59999999999999997e34 < z < 1.24999999999999996e58Initial program 100.0%
Taylor expanded in x around 0 58.6%
div-sub58.6%
associate-/l*58.6%
*-inverses58.6%
metadata-eval58.6%
sub-neg58.6%
distribute-lft-in58.6%
metadata-eval58.6%
distribute-rgt-neg-in58.6%
*-lft-identity58.6%
associate-*l/58.6%
associate-*l*58.6%
*-commutative58.6%
distribute-rgt-neg-in58.6%
associate-*r/58.6%
metadata-eval58.6%
distribute-neg-frac58.6%
metadata-eval58.6%
Simplified58.6%
Taylor expanded in z around 0 49.3%
Final simplification56.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.75e+118) (not (<= x 7.8e+100))) (+ 1.0 (* 4.0 (/ x y))) (+ 4.0 (/ (* z -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.75e+118) || !(x <= 7.8e+100)) {
tmp = 1.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 ((x <= (-1.75d+118)) .or. (.not. (x <= 7.8d+100))) then
tmp = 1.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 ((x <= -1.75e+118) || !(x <= 7.8e+100)) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.75e+118) or not (x <= 7.8e+100): tmp = 1.0 + (4.0 * (x / y)) else: tmp = 4.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.75e+118) || !(x <= 7.8e+100)) tmp = Float64(1.0 + Float64(4.0 * Float64(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 ((x <= -1.75e+118) || ~((x <= 7.8e+100))) tmp = 1.0 + (4.0 * (x / y)); else tmp = 4.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.75e+118], N[Not[LessEqual[x, 7.8e+100]], $MachinePrecision]], N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{+118} \lor \neg \left(x \leq 7.8 \cdot 10^{+100}\right):\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if x < -1.75000000000000008e118 or 7.8e100 < x Initial program 99.9%
Taylor expanded in x around inf 76.6%
*-commutative76.6%
Simplified76.6%
if -1.75000000000000008e118 < x < 7.8e100Initial program 99.9%
Taylor expanded in x around 0 85.3%
div-sub85.3%
associate-/l*85.3%
*-inverses85.3%
metadata-eval85.3%
sub-neg85.3%
distribute-lft-in85.3%
metadata-eval85.3%
distribute-rgt-neg-in85.3%
*-lft-identity85.3%
associate-*l/85.2%
associate-*l*85.2%
*-commutative85.2%
distribute-rgt-neg-in85.2%
associate-*r/85.2%
metadata-eval85.2%
distribute-neg-frac85.2%
metadata-eval85.2%
Simplified85.2%
Taylor expanded in z around 0 85.3%
associate-*r/85.3%
Simplified85.3%
Final simplification82.5%
(FPCore (x y z) :precision binary64 (+ 1.0 (+ 3.0 (/ 4.0 (/ y (- x z))))))
double code(double x, double y, double z) {
return 1.0 + (3.0 + (4.0 / (y / (x - z))));
}
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 + (3.0d0 + (4.0d0 / (y / (x - z))))
end function
public static double code(double x, double y, double z) {
return 1.0 + (3.0 + (4.0 / (y / (x - z))));
}
def code(x, y, z): return 1.0 + (3.0 + (4.0 / (y / (x - z))))
function code(x, y, z) return Float64(1.0 + Float64(3.0 + Float64(4.0 / Float64(y / Float64(x - z))))) end
function tmp = code(x, y, z) tmp = 1.0 + (3.0 + (4.0 / (y / (x - z)))); end
code[x_, y_, z_] := N[(1.0 + N[(3.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(3 + \frac{4}{\frac{y}{x - z}}\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
clear-num69.8%
inv-pow69.8%
*-un-lft-identity69.8%
times-frac69.8%
metadata-eval69.8%
Applied egg-rr99.8%
unpow-169.8%
associate-/r*69.8%
metadata-eval69.8%
Simplified99.8%
Final simplification99.8%
(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 x around 0 68.2%
div-sub68.2%
associate-/l*68.2%
*-inverses68.2%
metadata-eval68.2%
sub-neg68.2%
distribute-lft-in68.2%
metadata-eval68.2%
distribute-rgt-neg-in68.2%
*-lft-identity68.2%
associate-*l/68.1%
associate-*l*68.1%
*-commutative68.1%
distribute-rgt-neg-in68.1%
associate-*r/68.1%
metadata-eval68.1%
distribute-neg-frac68.1%
metadata-eval68.1%
Simplified68.1%
Taylor expanded in z around 0 37.2%
Final simplification37.2%
herbie shell --seed 2024066
(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)))