
(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 9 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 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 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 = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
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 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (/ (* x 4.0) y))))
(if (<= x -4.7e+80)
t_1
(if (<= x -1.55e-184)
t_0
(if (<= x -4.7e-245)
2.0
(if (<= x 1.85e-29) t_0 (if (<= x 8.8e+101) 2.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 + ((x * 4.0) / y);
double tmp;
if (x <= -4.7e+80) {
tmp = t_1;
} else if (x <= -1.55e-184) {
tmp = t_0;
} else if (x <= -4.7e-245) {
tmp = 2.0;
} else if (x <= 1.85e-29) {
tmp = t_0;
} else if (x <= 8.8e+101) {
tmp = 2.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 + ((x * 4.0d0) / y)
if (x <= (-4.7d+80)) then
tmp = t_1
else if (x <= (-1.55d-184)) then
tmp = t_0
else if (x <= (-4.7d-245)) then
tmp = 2.0d0
else if (x <= 1.85d-29) then
tmp = t_0
else if (x <= 8.8d+101) then
tmp = 2.0d0
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 + ((x * 4.0) / y);
double tmp;
if (x <= -4.7e+80) {
tmp = t_1;
} else if (x <= -1.55e-184) {
tmp = t_0;
} else if (x <= -4.7e-245) {
tmp = 2.0;
} else if (x <= 1.85e-29) {
tmp = t_0;
} else if (x <= 8.8e+101) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + ((x * 4.0) / y) tmp = 0 if x <= -4.7e+80: tmp = t_1 elif x <= -1.55e-184: tmp = t_0 elif x <= -4.7e-245: tmp = 2.0 elif x <= 1.85e-29: tmp = t_0 elif x <= 8.8e+101: tmp = 2.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(Float64(x * 4.0) / y)) tmp = 0.0 if (x <= -4.7e+80) tmp = t_1; elseif (x <= -1.55e-184) tmp = t_0; elseif (x <= -4.7e-245) tmp = 2.0; elseif (x <= 1.85e-29) tmp = t_0; elseif (x <= 8.8e+101) tmp = 2.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 + ((x * 4.0) / y); tmp = 0.0; if (x <= -4.7e+80) tmp = t_1; elseif (x <= -1.55e-184) tmp = t_0; elseif (x <= -4.7e-245) tmp = 2.0; elseif (x <= 1.85e-29) tmp = t_0; elseif (x <= 8.8e+101) tmp = 2.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[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e+80], t$95$1, If[LessEqual[x, -1.55e-184], t$95$0, If[LessEqual[x, -4.7e-245], 2.0, If[LessEqual[x, 1.85e-29], t$95$0, If[LessEqual[x, 8.8e+101], 2.0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + \frac{x \cdot 4}{y}\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+80}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-184}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4.7 \cdot 10^{-245}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+101}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.70000000000000009e80 or 8.8000000000000003e101 < x Initial program 100.0%
Taylor expanded in x around inf 77.3%
if -4.70000000000000009e80 < x < -1.5500000000000001e-184 or -4.7000000000000002e-245 < x < 1.8499999999999999e-29Initial program 100.0%
Taylor expanded in z around inf 60.9%
associate-*r/60.9%
metadata-eval60.9%
associate-*r*60.9%
neg-mul-160.9%
associate-*l/60.7%
*-commutative60.7%
distribute-lft-neg-out60.7%
distribute-rgt-neg-in60.7%
distribute-neg-frac60.7%
metadata-eval60.7%
Simplified60.7%
if -1.5500000000000001e-184 < x < -4.7000000000000002e-245 or 1.8499999999999999e-29 < x < 8.8000000000000003e101Initial program 100.0%
Taylor expanded in y around inf 65.6%
Final simplification68.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (/ (* x 4.0) y))))
(if (<= x -1.7e+76)
t_1
(if (<= x -6.5e-186)
t_0
(if (<= x -5.2e-240)
2.0
(if (<= x 6.8e-29) t_0 (if (<= x 6.2e+99) 2.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 + ((x * 4.0) / y);
double tmp;
if (x <= -1.7e+76) {
tmp = t_1;
} else if (x <= -6.5e-186) {
tmp = t_0;
} else if (x <= -5.2e-240) {
tmp = 2.0;
} else if (x <= 6.8e-29) {
tmp = t_0;
} else if (x <= 6.2e+99) {
tmp = 2.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 + ((x * 4.0d0) / y)
if (x <= (-1.7d+76)) then
tmp = t_1
else if (x <= (-6.5d-186)) then
tmp = t_0
else if (x <= (-5.2d-240)) then
tmp = 2.0d0
else if (x <= 6.8d-29) then
tmp = t_0
else if (x <= 6.2d+99) then
tmp = 2.0d0
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 + ((x * 4.0) / y);
double tmp;
if (x <= -1.7e+76) {
tmp = t_1;
} else if (x <= -6.5e-186) {
tmp = t_0;
} else if (x <= -5.2e-240) {
tmp = 2.0;
} else if (x <= 6.8e-29) {
tmp = t_0;
} else if (x <= 6.2e+99) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + ((x * 4.0) / y) tmp = 0 if x <= -1.7e+76: tmp = t_1 elif x <= -6.5e-186: tmp = t_0 elif x <= -5.2e-240: tmp = 2.0 elif x <= 6.8e-29: tmp = t_0 elif x <= 6.2e+99: tmp = 2.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(Float64(x * 4.0) / y)) tmp = 0.0 if (x <= -1.7e+76) tmp = t_1; elseif (x <= -6.5e-186) tmp = t_0; elseif (x <= -5.2e-240) tmp = 2.0; elseif (x <= 6.8e-29) tmp = t_0; elseif (x <= 6.2e+99) tmp = 2.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 + ((x * 4.0) / y); tmp = 0.0; if (x <= -1.7e+76) tmp = t_1; elseif (x <= -6.5e-186) tmp = t_0; elseif (x <= -5.2e-240) tmp = 2.0; elseif (x <= 6.8e-29) tmp = t_0; elseif (x <= 6.2e+99) tmp = 2.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[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e+76], t$95$1, If[LessEqual[x, -6.5e-186], t$95$0, If[LessEqual[x, -5.2e-240], 2.0, If[LessEqual[x, 6.8e-29], t$95$0, If[LessEqual[x, 6.2e+99], 2.0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + \frac{x \cdot 4}{y}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{+76}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-186}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-240}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+99}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.6999999999999999e76 or 6.2000000000000001e99 < x Initial program 100.0%
Taylor expanded in x around inf 77.3%
if -1.6999999999999999e76 < x < -6.49999999999999962e-186 or -5.19999999999999984e-240 < x < 6.79999999999999945e-29Initial program 100.0%
Taylor expanded in z around inf 60.9%
*-commutative60.9%
associate-*l/60.9%
Simplified60.9%
if -6.49999999999999962e-186 < x < -5.19999999999999984e-240 or 6.79999999999999945e-29 < x < 6.2000000000000001e99Initial program 100.0%
Taylor expanded in y around inf 65.6%
Final simplification68.1%
(FPCore (x y z)
:precision binary64
(if (or (<= x -5.6e+82)
(and (not (<= x 8e+102)) (or (<= x 1.95e+137) (not (<= x 3.5e+167)))))
(+ 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.6e+82) || (!(x <= 8e+102) && ((x <= 1.95e+137) || !(x <= 3.5e+167)))) {
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.6d+82)) .or. (.not. (x <= 8d+102)) .and. (x <= 1.95d+137) .or. (.not. (x <= 3.5d+167))) 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.6e+82) || (!(x <= 8e+102) && ((x <= 1.95e+137) || !(x <= 3.5e+167)))) {
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.6e+82) or (not (x <= 8e+102) and ((x <= 1.95e+137) or not (x <= 3.5e+167))): 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.6e+82) || (!(x <= 8e+102) && ((x <= 1.95e+137) || !(x <= 3.5e+167)))) 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.6e+82) || (~((x <= 8e+102)) && ((x <= 1.95e+137) || ~((x <= 3.5e+167))))) 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.6e+82], And[N[Not[LessEqual[x, 8e+102]], $MachinePrecision], Or[LessEqual[x, 1.95e+137], N[Not[LessEqual[x, 3.5e+167]], $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.6 \cdot 10^{+82} \lor \neg \left(x \leq 8 \cdot 10^{+102}\right) \land \left(x \leq 1.95 \cdot 10^{+137} \lor \neg \left(x \leq 3.5 \cdot 10^{+167}\right)\right):\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -5.6000000000000001e82 or 7.99999999999999982e102 < x < 1.95000000000000015e137 or 3.49999999999999987e167 < x Initial program 100.0%
Taylor expanded in x around inf 81.2%
if -5.6000000000000001e82 < x < 7.99999999999999982e102 or 1.95000000000000015e137 < x < 3.49999999999999987e167Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.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 0 87.1%
Final simplification84.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e+133) (not (<= z 550.0))) (+ 1.0 (* z (/ -4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+133) || !(z <= 550.0)) {
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 <= (-5.8d+133)) .or. (.not. (z <= 550.0d0))) 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 <= -5.8e+133) || !(z <= 550.0)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.8e+133) or not (z <= 550.0): tmp = 1.0 + (z * (-4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e+133) || !(z <= 550.0)) 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 <= -5.8e+133) || ~((z <= 550.0))) tmp = 1.0 + (z * (-4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+133], N[Not[LessEqual[z, 550.0]], $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 -5.8 \cdot 10^{+133} \lor \neg \left(z \leq 550\right):\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -5.8000000000000002e133 or 550 < z Initial program 100.0%
Taylor expanded in z around inf 70.5%
associate-*r/70.5%
metadata-eval70.5%
associate-*r*70.5%
neg-mul-170.5%
associate-*l/70.3%
*-commutative70.3%
distribute-lft-neg-out70.3%
distribute-rgt-neg-in70.3%
distribute-neg-frac70.3%
metadata-eval70.3%
Simplified70.3%
if -5.8000000000000002e133 < z < 550Initial program 100.0%
Taylor expanded in y around inf 43.8%
Final simplification54.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.2e+76) (not (<= x 1.65e-82))) (+ 2.0 (* 4.0 (/ x y))) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.2e+76) || !(x <= 1.65e-82)) {
tmp = 2.0 + (4.0 * (x / 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 <= (-8.2d+76)) .or. (.not. (x <= 1.65d-82))) then
tmp = 2.0d0 + (4.0d0 * (x / 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 <= -8.2e+76) || !(x <= 1.65e-82)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.2e+76) or not (x <= 1.65e-82): tmp = 2.0 + (4.0 * (x / y)) else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.2e+76) || !(x <= 1.65e-82)) tmp = Float64(2.0 + Float64(4.0 * Float64(x / 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 <= -8.2e+76) || ~((x <= 1.65e-82))) tmp = 2.0 + (4.0 * (x / y)); else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.2e+76], N[Not[LessEqual[x, 1.65e-82]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+76} \lor \neg \left(x \leq 1.65 \cdot 10^{-82}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -8.1999999999999997e76 or 1.65000000000000011e-82 < x Initial program 100.0%
+-commutative100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.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 87.7%
if -8.1999999999999997e76 < x < 1.65000000000000011e-82Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.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 0 92.1%
Final simplification89.8%
(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%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.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
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 43.1%
Taylor expanded in x around 0 7.6%
Final simplification7.6%
(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 31.7%
Final simplification31.7%
herbie shell --seed 2024055
(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)))