
(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 9 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 (- x z) (/ 4.0 y) 4.0))
double code(double x, double y, double z) {
return fma((x - z), (4.0 / y), 4.0);
}
function code(x, y, z) return fma(Float64(x - z), Float64(4.0 / y), 4.0) end
code[x_, y_, z_] := N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision] + 4.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - z, \frac{4}{y}, 4\right)
\end{array}
Initial program 99.6%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (<= y -1e+118)
4.0
(if (or (<= y -5.2e+41)
(and (not (<= y -1.02e-5))
(or (<= y 2.05e+86)
(and (not (<= y 1.25e+140)) (<= y 9.5e+168)))))
(* (- x z) (/ 4.0 y))
4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+118) {
tmp = 4.0;
} else if ((y <= -5.2e+41) || (!(y <= -1.02e-5) && ((y <= 2.05e+86) || (!(y <= 1.25e+140) && (y <= 9.5e+168))))) {
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 <= (-1d+118)) then
tmp = 4.0d0
else if ((y <= (-5.2d+41)) .or. (.not. (y <= (-1.02d-5))) .and. (y <= 2.05d+86) .or. (.not. (y <= 1.25d+140)) .and. (y <= 9.5d+168)) 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 <= -1e+118) {
tmp = 4.0;
} else if ((y <= -5.2e+41) || (!(y <= -1.02e-5) && ((y <= 2.05e+86) || (!(y <= 1.25e+140) && (y <= 9.5e+168))))) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+118: tmp = 4.0 elif (y <= -5.2e+41) or (not (y <= -1.02e-5) and ((y <= 2.05e+86) or (not (y <= 1.25e+140) and (y <= 9.5e+168)))): tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+118) tmp = 4.0; elseif ((y <= -5.2e+41) || (!(y <= -1.02e-5) && ((y <= 2.05e+86) || (!(y <= 1.25e+140) && (y <= 9.5e+168))))) 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 <= -1e+118) tmp = 4.0; elseif ((y <= -5.2e+41) || (~((y <= -1.02e-5)) && ((y <= 2.05e+86) || (~((y <= 1.25e+140)) && (y <= 9.5e+168))))) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+118], 4.0, If[Or[LessEqual[y, -5.2e+41], And[N[Not[LessEqual[y, -1.02e-5]], $MachinePrecision], Or[LessEqual[y, 2.05e+86], And[N[Not[LessEqual[y, 1.25e+140]], $MachinePrecision], LessEqual[y, 9.5e+168]]]]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+118}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{+41} \lor \neg \left(y \leq -1.02 \cdot 10^{-5}\right) \land \left(y \leq 2.05 \cdot 10^{+86} \lor \neg \left(y \leq 1.25 \cdot 10^{+140}\right) \land y \leq 9.5 \cdot 10^{+168}\right):\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -9.99999999999999967e117 or -5.2000000000000001e41 < y < -1.0200000000000001e-5 or 2.05e86 < y < 1.25000000000000002e140 or 9.49999999999999979e168 < y Initial program 98.6%
associate-/l*99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 78.9%
if -9.99999999999999967e117 < y < -5.2000000000000001e41 or -1.0200000000000001e-5 < y < 2.05e86 or 1.25000000000000002e140 < y < 9.49999999999999979e168Initial program 100.0%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
distribute-lft-out97.8%
Simplified97.8%
Taylor expanded in y around 0 88.4%
associate-*r/88.4%
associate-*l/88.1%
*-commutative88.1%
Simplified88.1%
Final simplification85.5%
(FPCore (x y z)
:precision binary64
(if (or (<= z -2.3e+21)
(and (not (<= z 5.5e-36))
(or (<= z 45000000000000.0) (not (<= z 1.62e+148)))))
(* (- x z) (/ 4.0 y))
(+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+21) || (!(z <= 5.5e-36) && ((z <= 45000000000000.0) || !(z <= 1.62e+148)))) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.3d+21)) .or. (.not. (z <= 5.5d-36)) .and. (z <= 45000000000000.0d0) .or. (.not. (z <= 1.62d+148))) then
tmp = (x - z) * (4.0d0 / y)
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+21) || (!(z <= 5.5e-36) && ((z <= 45000000000000.0) || !(z <= 1.62e+148)))) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+21) or (not (z <= 5.5e-36) and ((z <= 45000000000000.0) or not (z <= 1.62e+148))): tmp = (x - z) * (4.0 / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+21) || (!(z <= 5.5e-36) && ((z <= 45000000000000.0) || !(z <= 1.62e+148)))) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+21) || (~((z <= 5.5e-36)) && ((z <= 45000000000000.0) || ~((z <= 1.62e+148))))) tmp = (x - z) * (4.0 / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+21], And[N[Not[LessEqual[z, 5.5e-36]], $MachinePrecision], Or[LessEqual[z, 45000000000000.0], N[Not[LessEqual[z, 1.62e+148]], $MachinePrecision]]]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+21} \lor \neg \left(z \leq 5.5 \cdot 10^{-36}\right) \land \left(z \leq 45000000000000 \lor \neg \left(z \leq 1.62 \cdot 10^{+148}\right)\right):\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -2.3e21 or 5.49999999999999984e-36 < z < 4.5e13 or 1.62000000000000006e148 < z Initial program 100.0%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around inf 96.3%
+-commutative96.3%
distribute-lft-out96.3%
Simplified96.3%
Taylor expanded in y around 0 89.4%
associate-*r/89.4%
associate-*l/89.2%
*-commutative89.2%
Simplified89.2%
if -2.3e21 < z < 5.49999999999999984e-36 or 4.5e13 < z < 1.62000000000000006e148Initial program 99.3%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 93.1%
Final simplification91.4%
(FPCore (x y z)
:precision binary64
(if (<= z -2.8e-36)
(+ 1.0 (/ 4.0 (/ y (- x z))))
(if (or (<= z 2.2e-37) (and (not (<= z 2.15e+16)) (<= z 3.85e+133)))
(+ 4.0 (* 4.0 (/ x y)))
(+ 4.0 (* (/ z y) -4.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.8e-36) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else if ((z <= 2.2e-37) || (!(z <= 2.15e+16) && (z <= 3.85e+133))) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -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.8d-36)) then
tmp = 1.0d0 + (4.0d0 / (y / (x - z)))
else if ((z <= 2.2d-37) .or. (.not. (z <= 2.15d+16)) .and. (z <= 3.85d+133)) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.8e-36) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else if ((z <= 2.2e-37) || (!(z <= 2.15e+16) && (z <= 3.85e+133))) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.8e-36: tmp = 1.0 + (4.0 / (y / (x - z))) elif (z <= 2.2e-37) or (not (z <= 2.15e+16) and (z <= 3.85e+133)): tmp = 4.0 + (4.0 * (x / y)) else: tmp = 4.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.8e-36) tmp = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))); elseif ((z <= 2.2e-37) || (!(z <= 2.15e+16) && (z <= 3.85e+133))) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.8e-36) tmp = 1.0 + (4.0 / (y / (x - z))); elseif ((z <= 2.2e-37) || (~((z <= 2.15e+16)) && (z <= 3.85e+133))) tmp = 4.0 + (4.0 * (x / y)); else tmp = 4.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.8e-36], N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 2.2e-37], And[N[Not[LessEqual[z, 2.15e+16]], $MachinePrecision], LessEqual[z, 3.85e+133]]], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-36}:\\
\;\;\;\;1 + \frac{4}{\frac{y}{x - z}}\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-37} \lor \neg \left(z \leq 2.15 \cdot 10^{+16}\right) \land z \leq 3.85 \cdot 10^{+133}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if z < -2.8000000000000001e-36Initial program 99.9%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around 0 91.9%
if -2.8000000000000001e-36 < z < 2.20000000000000002e-37 or 2.15e16 < z < 3.85e133Initial program 99.2%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 97.3%
if 2.20000000000000002e-37 < z < 2.15e16 or 3.85e133 < z Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 88.5%
*-commutative88.5%
Simplified88.5%
Final simplification93.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* (/ z y) -4.0)))
(if (<= x -2.7e+62)
t_0
(if (<= x 8.8e-282)
t_1
(if (<= x 5.5e-236) 4.0 (if (<= x 8e-15) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -2.7e+62) {
tmp = t_0;
} else if (x <= 8.8e-282) {
tmp = t_1;
} else if (x <= 5.5e-236) {
tmp = 4.0;
} else if (x <= 8e-15) {
tmp = t_1;
} else {
tmp = t_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 / y) * (-4.0d0)
if (x <= (-2.7d+62)) then
tmp = t_0
else if (x <= 8.8d-282) then
tmp = t_1
else if (x <= 5.5d-236) then
tmp = 4.0d0
else if (x <= 8d-15) then
tmp = t_1
else
tmp = t_0
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 / y) * -4.0;
double tmp;
if (x <= -2.7e+62) {
tmp = t_0;
} else if (x <= 8.8e-282) {
tmp = t_1;
} else if (x <= 5.5e-236) {
tmp = 4.0;
} else if (x <= 8e-15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = (z / y) * -4.0 tmp = 0 if x <= -2.7e+62: tmp = t_0 elif x <= 8.8e-282: tmp = t_1 elif x <= 5.5e-236: tmp = 4.0 elif x <= 8e-15: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (x <= -2.7e+62) tmp = t_0; elseif (x <= 8.8e-282) tmp = t_1; elseif (x <= 5.5e-236) tmp = 4.0; elseif (x <= 8e-15) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = (z / y) * -4.0; tmp = 0.0; if (x <= -2.7e+62) tmp = t_0; elseif (x <= 8.8e-282) tmp = t_1; elseif (x <= 5.5e-236) tmp = 4.0; elseif (x <= 8e-15) tmp = t_1; else tmp = t_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 / y), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -2.7e+62], t$95$0, If[LessEqual[x, 8.8e-282], t$95$1, If[LessEqual[x, 5.5e-236], 4.0, If[LessEqual[x, 8e-15], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-282}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-236}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-15}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.7e62 or 8.0000000000000006e-15 < x Initial program 99.1%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around inf 96.4%
+-commutative96.4%
distribute-lft-out96.4%
Simplified96.4%
Taylor expanded in x around inf 73.1%
if -2.7e62 < x < 8.79999999999999925e-282 or 5.49999999999999959e-236 < x < 8.0000000000000006e-15Initial program 99.9%
associate-/l*99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in z around inf 53.9%
*-commutative53.9%
Simplified53.9%
if 8.79999999999999925e-282 < x < 5.49999999999999959e-236Initial program 100.0%
associate-/l*99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 80.5%
Final simplification63.8%
(FPCore (x y z) :precision binary64 (+ 1.0 (/ 4.0 (/ y (+ x (- (* y 0.75) z))))))
double code(double x, double y, double z) {
return 1.0 + (4.0 / (y / (x + ((y * 0.75) - 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 + (4.0d0 / (y / (x + ((y * 0.75d0) - z))))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 / (y / (x + ((y * 0.75) - z))));
}
def code(x, y, z): return 1.0 + (4.0 / (y / (x + ((y * 0.75) - z))))
function code(x, y, z) return Float64(1.0 + Float64(4.0 / Float64(y / Float64(x + Float64(Float64(y * 0.75) - z))))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 / (y / (x + ((y * 0.75) - z)))); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 / N[(y / N[(x + N[(N[(y * 0.75), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4}{\frac{y}{x + \left(y \cdot 0.75 - z\right)}}
\end{array}
Initial program 99.6%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e+62) (not (<= x 1.15e-14))) (+ 4.0 (* 4.0 (/ x y))) (+ 4.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e+62) || !(x <= 1.15e-14)) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -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 ((x <= (-2.9d+62)) .or. (.not. (x <= 1.15d-14))) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e+62) || !(x <= 1.15e-14)) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e+62) or not (x <= 1.15e-14): tmp = 4.0 + (4.0 * (x / y)) else: tmp = 4.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e+62) || !(x <= 1.15e-14)) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.9e+62) || ~((x <= 1.15e-14))) tmp = 4.0 + (4.0 * (x / y)); else tmp = 4.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e+62], N[Not[LessEqual[x, 1.15e-14]], $MachinePrecision]], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+62} \lor \neg \left(x \leq 1.15 \cdot 10^{-14}\right):\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -2.89999999999999984e62 or 1.14999999999999999e-14 < x Initial program 99.1%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.7%
associate-/l*99.7%
*-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 90.7%
if -2.89999999999999984e62 < x < 1.14999999999999999e-14Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.7%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 90.3%
*-commutative90.3%
Simplified90.3%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.7e+62) (not (<= x 1.9e+44))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.7e+62) || !(x <= 1.9e+44)) {
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 ((x <= (-2.7d+62)) .or. (.not. (x <= 1.9d+44))) 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 ((x <= -2.7e+62) || !(x <= 1.9e+44)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.7e+62) or not (x <= 1.9e+44): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.7e+62) || !(x <= 1.9e+44)) 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 ((x <= -2.7e+62) || ~((x <= 1.9e+44))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.7e+62], N[Not[LessEqual[x, 1.9e+44]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+62} \lor \neg \left(x \leq 1.9 \cdot 10^{+44}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -2.7e62 or 1.9000000000000001e44 < x Initial program 99.0%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around inf 96.1%
+-commutative96.1%
distribute-lft-out96.1%
Simplified96.1%
Taylor expanded in x around inf 76.4%
if -2.7e62 < x < 1.9000000000000001e44Initial program 99.9%
associate-/l*99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 42.2%
Final simplification55.9%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.6%
associate-/l*99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 31.8%
Final simplification31.8%
herbie shell --seed 2023238
(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)))