
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\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.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 2.0 (/ (- x z) (* y 0.25))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) / (y * 0.25));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 + ((x - z) / (y * 0.25d0))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) / (y * 0.25));
}
def code(x, y, z): return 2.0 + ((x - z) / (y * 0.25))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) / Float64(y * 0.25))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) / (y * 0.25)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \frac{x - z}{y \cdot 0.25}
\end{array}
Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* x 4.0) y))) (t_1 (+ 1.0 (* z (/ -4.0 y)))))
(if (<= z -64000.0)
t_1
(if (<= z -2.05e-56)
t_0
(if (<= z -2.9e-165)
2.0
(if (<= z -3.7e-259)
t_0
(if (<= z 5.7e-84) 2.0 (if (<= z 5e+88) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((x * 4.0) / y);
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -64000.0) {
tmp = t_1;
} else if (z <= -2.05e-56) {
tmp = t_0;
} else if (z <= -2.9e-165) {
tmp = 2.0;
} else if (z <= -3.7e-259) {
tmp = t_0;
} else if (z <= 5.7e-84) {
tmp = 2.0;
} else if (z <= 5e+88) {
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 + ((x * 4.0d0) / y)
t_1 = 1.0d0 + (z * ((-4.0d0) / y))
if (z <= (-64000.0d0)) then
tmp = t_1
else if (z <= (-2.05d-56)) then
tmp = t_0
else if (z <= (-2.9d-165)) then
tmp = 2.0d0
else if (z <= (-3.7d-259)) then
tmp = t_0
else if (z <= 5.7d-84) then
tmp = 2.0d0
else if (z <= 5d+88) 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 + ((x * 4.0) / y);
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -64000.0) {
tmp = t_1;
} else if (z <= -2.05e-56) {
tmp = t_0;
} else if (z <= -2.9e-165) {
tmp = 2.0;
} else if (z <= -3.7e-259) {
tmp = t_0;
} else if (z <= 5.7e-84) {
tmp = 2.0;
} else if (z <= 5e+88) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((x * 4.0) / y) t_1 = 1.0 + (z * (-4.0 / y)) tmp = 0 if z <= -64000.0: tmp = t_1 elif z <= -2.05e-56: tmp = t_0 elif z <= -2.9e-165: tmp = 2.0 elif z <= -3.7e-259: tmp = t_0 elif z <= 5.7e-84: tmp = 2.0 elif z <= 5e+88: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(x * 4.0) / y)) t_1 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) tmp = 0.0 if (z <= -64000.0) tmp = t_1; elseif (z <= -2.05e-56) tmp = t_0; elseif (z <= -2.9e-165) tmp = 2.0; elseif (z <= -3.7e-259) tmp = t_0; elseif (z <= 5.7e-84) tmp = 2.0; elseif (z <= 5e+88) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((x * 4.0) / y); t_1 = 1.0 + (z * (-4.0 / y)); tmp = 0.0; if (z <= -64000.0) tmp = t_1; elseif (z <= -2.05e-56) tmp = t_0; elseif (z <= -2.9e-165) tmp = 2.0; elseif (z <= -3.7e-259) tmp = t_0; elseif (z <= 5.7e-84) tmp = 2.0; elseif (z <= 5e+88) 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[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -64000.0], t$95$1, If[LessEqual[z, -2.05e-56], t$95$0, If[LessEqual[z, -2.9e-165], 2.0, If[LessEqual[z, -3.7e-259], t$95$0, If[LessEqual[z, 5.7e-84], 2.0, If[LessEqual[z, 5e+88], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x \cdot 4}{y}\\
t_1 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -64000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -2.05 \cdot 10^{-56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{-165}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-259}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{-84}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -64000 or 4.99999999999999997e88 < z Initial program 100.0%
Taylor expanded in z around inf 74.4%
associate-*r/74.4%
metadata-eval74.4%
associate-*r*74.4%
neg-mul-174.4%
associate-*l/74.3%
distribute-rgt-neg-out74.3%
*-commutative74.3%
distribute-rgt-neg-in74.3%
distribute-neg-frac74.3%
metadata-eval74.3%
Simplified74.3%
if -64000 < z < -2.0500000000000001e-56 or -2.9e-165 < z < -3.69999999999999991e-259 or 5.7e-84 < z < 4.99999999999999997e88Initial program 100.0%
Taylor expanded in x around inf 60.3%
associate-*r/60.3%
Simplified60.3%
if -2.0500000000000001e-56 < z < -2.9e-165 or -3.69999999999999991e-259 < z < 5.7e-84Initial program 100.0%
Taylor expanded in y around inf 68.5%
Final simplification68.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* x 4.0) y))) (t_1 (+ 1.0 (/ (* z -4.0) y))))
(if (<= z -116000.0)
t_1
(if (<= z -6.3e-56)
t_0
(if (<= z -6.2e-165)
2.0
(if (<= z -1.4e-262)
t_0
(if (<= z 1.46e-83) 2.0 (if (<= z 8.5e+88) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((x * 4.0) / y);
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -116000.0) {
tmp = t_1;
} else if (z <= -6.3e-56) {
tmp = t_0;
} else if (z <= -6.2e-165) {
tmp = 2.0;
} else if (z <= -1.4e-262) {
tmp = t_0;
} else if (z <= 1.46e-83) {
tmp = 2.0;
} else if (z <= 8.5e+88) {
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 + ((x * 4.0d0) / y)
t_1 = 1.0d0 + ((z * (-4.0d0)) / y)
if (z <= (-116000.0d0)) then
tmp = t_1
else if (z <= (-6.3d-56)) then
tmp = t_0
else if (z <= (-6.2d-165)) then
tmp = 2.0d0
else if (z <= (-1.4d-262)) then
tmp = t_0
else if (z <= 1.46d-83) then
tmp = 2.0d0
else if (z <= 8.5d+88) 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 + ((x * 4.0) / y);
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -116000.0) {
tmp = t_1;
} else if (z <= -6.3e-56) {
tmp = t_0;
} else if (z <= -6.2e-165) {
tmp = 2.0;
} else if (z <= -1.4e-262) {
tmp = t_0;
} else if (z <= 1.46e-83) {
tmp = 2.0;
} else if (z <= 8.5e+88) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((x * 4.0) / y) t_1 = 1.0 + ((z * -4.0) / y) tmp = 0 if z <= -116000.0: tmp = t_1 elif z <= -6.3e-56: tmp = t_0 elif z <= -6.2e-165: tmp = 2.0 elif z <= -1.4e-262: tmp = t_0 elif z <= 1.46e-83: tmp = 2.0 elif z <= 8.5e+88: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(x * 4.0) / y)) t_1 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) tmp = 0.0 if (z <= -116000.0) tmp = t_1; elseif (z <= -6.3e-56) tmp = t_0; elseif (z <= -6.2e-165) tmp = 2.0; elseif (z <= -1.4e-262) tmp = t_0; elseif (z <= 1.46e-83) tmp = 2.0; elseif (z <= 8.5e+88) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((x * 4.0) / y); t_1 = 1.0 + ((z * -4.0) / y); tmp = 0.0; if (z <= -116000.0) tmp = t_1; elseif (z <= -6.3e-56) tmp = t_0; elseif (z <= -6.2e-165) tmp = 2.0; elseif (z <= -1.4e-262) tmp = t_0; elseif (z <= 1.46e-83) tmp = 2.0; elseif (z <= 8.5e+88) 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[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -116000.0], t$95$1, If[LessEqual[z, -6.3e-56], t$95$0, If[LessEqual[z, -6.2e-165], 2.0, If[LessEqual[z, -1.4e-262], t$95$0, If[LessEqual[z, 1.46e-83], 2.0, If[LessEqual[z, 8.5e+88], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x \cdot 4}{y}\\
t_1 := 1 + \frac{z \cdot -4}{y}\\
\mathbf{if}\;z \leq -116000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -6.3 \cdot 10^{-56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{-165}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-262}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.46 \cdot 10^{-83}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -116000 or 8.5000000000000005e88 < z Initial program 100.0%
Taylor expanded in z around inf 74.4%
*-commutative74.4%
associate-*l/74.4%
Simplified74.4%
if -116000 < z < -6.2999999999999997e-56 or -6.19999999999999992e-165 < z < -1.39999999999999988e-262 or 1.4600000000000001e-83 < z < 8.5000000000000005e88Initial program 100.0%
Taylor expanded in x around inf 60.3%
associate-*r/60.3%
Simplified60.3%
if -6.2999999999999997e-56 < z < -6.19999999999999992e-165 or -1.39999999999999988e-262 < z < 1.4600000000000001e-83Initial program 100.0%
Taylor expanded in y around inf 68.5%
Final simplification68.5%
(FPCore (x y z)
:precision binary64
(if (or (<= x -5.8e+163)
(and (not (<= x 1.4e+141))
(or (<= x 3.5e+170) (not (<= x 4.2e+187)))))
(+ 1.0 (/ (* x 4.0) y))
(+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+163) || (!(x <= 1.4e+141) && ((x <= 3.5e+170) || !(x <= 4.2e+187)))) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0 + (-4.0 * (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) :: tmp
if ((x <= (-5.8d+163)) .or. (.not. (x <= 1.4d+141)) .and. (x <= 3.5d+170) .or. (.not. (x <= 4.2d+187))) then
tmp = 1.0d0 + ((x * 4.0d0) / y)
else
tmp = 2.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+163) || (!(x <= 1.4e+141) && ((x <= 3.5e+170) || !(x <= 4.2e+187)))) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e+163) or (not (x <= 1.4e+141) and ((x <= 3.5e+170) or not (x <= 4.2e+187))): tmp = 1.0 + ((x * 4.0) / y) else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e+163) || (!(x <= 1.4e+141) && ((x <= 3.5e+170) || !(x <= 4.2e+187)))) tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y)); else tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.8e+163) || (~((x <= 1.4e+141)) && ((x <= 3.5e+170) || ~((x <= 4.2e+187))))) tmp = 1.0 + ((x * 4.0) / y); else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e+163], And[N[Not[LessEqual[x, 1.4e+141]], $MachinePrecision], Or[LessEqual[x, 3.5e+170], N[Not[LessEqual[x, 4.2e+187]], $MachinePrecision]]]], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+163} \lor \neg \left(x \leq 1.4 \cdot 10^{+141}\right) \land \left(x \leq 3.5 \cdot 10^{+170} \lor \neg \left(x \leq 4.2 \cdot 10^{+187}\right)\right):\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -5.79999999999999996e163 or 1.39999999999999996e141 < x < 3.50000000000000005e170 or 4.2e187 < x Initial program 100.0%
Taylor expanded in x around inf 87.1%
associate-*r/87.1%
Simplified87.1%
if -5.79999999999999996e163 < x < 1.39999999999999996e141 or 3.50000000000000005e170 < x < 4.2e187Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.9%
associate-+r+99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 85.4%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.55e-17) (not (<= z 1.35e+14))) (+ 1.0 (* z (/ -4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-17) || !(z <= 1.35e+14)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.55d-17)) .or. (.not. (z <= 1.35d+14))) then
tmp = 1.0d0 + (z * ((-4.0d0) / y))
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-17) || !(z <= 1.35e+14)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.55e-17) or not (z <= 1.35e+14): tmp = 1.0 + (z * (-4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.55e-17) || !(z <= 1.35e+14)) tmp = Float64(1.0 + Float64(z * Float64(-4.0 / y))); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.55e-17) || ~((z <= 1.35e+14))) tmp = 1.0 + (z * (-4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.55e-17], N[Not[LessEqual[z, 1.35e+14]], $MachinePrecision]], N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-17} \lor \neg \left(z \leq 1.35 \cdot 10^{+14}\right):\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -1.5499999999999999e-17 or 1.35e14 < z Initial program 100.0%
Taylor expanded in z around inf 68.5%
associate-*r/68.5%
metadata-eval68.5%
associate-*r*68.5%
neg-mul-168.5%
associate-*l/68.4%
distribute-rgt-neg-out68.4%
*-commutative68.4%
distribute-rgt-neg-in68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
Simplified68.4%
if -1.5499999999999999e-17 < z < 1.35e14Initial program 100.0%
Taylor expanded in y around inf 53.8%
Final simplification61.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -96000.0) (not (<= z 5.3e+88))) (+ 2.0 (* -4.0 (/ z y))) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -96000.0) || !(z <= 5.3e+88)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.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 <= (-96000.0d0)) .or. (.not. (z <= 5.3d+88))) then
tmp = 2.0d0 + ((-4.0d0) * (z / y))
else
tmp = 2.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 <= -96000.0) || !(z <= 5.3e+88)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -96000.0) or not (z <= 5.3e+88): tmp = 2.0 + (-4.0 * (z / y)) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -96000.0) || !(z <= 5.3e+88)) tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -96000.0) || ~((z <= 5.3e+88))) tmp = 2.0 + (-4.0 * (z / y)); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -96000.0], N[Not[LessEqual[z, 5.3e+88]], $MachinePrecision]], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -96000 \lor \neg \left(z \leq 5.3 \cdot 10^{+88}\right):\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -96000 or 5.29999999999999987e88 < z Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 86.9%
if -96000 < z < 5.29999999999999987e88Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 92.7%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
return 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0
end function
public static double code(double x, double y, double z) {
return 2.0;
}
def code(x, y, z): return 2.0
function code(x, y, z) return 2.0 end
function tmp = code(x, y, z) tmp = 2.0; end
code[x_, y_, z_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 34.6%
Final simplification34.6%
herbie shell --seed 2024031
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))