
(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 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))))
(if (<= z -1.1e+45)
t_0
(if (<= z 5e-306) (* 4.0 (/ x y)) (if (<= z 1.2e+63) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -1.1e+45) {
tmp = t_0;
} else if (z <= 5e-306) {
tmp = 4.0 * (x / y);
} else if (z <= 1.2e+63) {
tmp = 4.0;
} 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) :: tmp
t_0 = (-4.0d0) * (z / y)
if (z <= (-1.1d+45)) then
tmp = t_0
else if (z <= 5d-306) then
tmp = 4.0d0 * (x / y)
else if (z <= 1.2d+63) then
tmp = 4.0d0
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 * (z / y);
double tmp;
if (z <= -1.1e+45) {
tmp = t_0;
} else if (z <= 5e-306) {
tmp = 4.0 * (x / y);
} else if (z <= 1.2e+63) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) tmp = 0 if z <= -1.1e+45: tmp = t_0 elif z <= 5e-306: tmp = 4.0 * (x / y) elif z <= 1.2e+63: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (z <= -1.1e+45) tmp = t_0; elseif (z <= 5e-306) tmp = Float64(4.0 * Float64(x / y)); elseif (z <= 1.2e+63) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); tmp = 0.0; if (z <= -1.1e+45) tmp = t_0; elseif (z <= 5e-306) tmp = 4.0 * (x / y); elseif (z <= 1.2e+63) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.1e+45], t$95$0, If[LessEqual[z, 5e-306], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e+63], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-306}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+63}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.1e45 or 1.2e63 < z Initial program 100.0%
Taylor expanded in z around inf 74.9%
*-commutative74.9%
Simplified74.9%
if -1.1e45 < z < 4.99999999999999998e-306Initial program 99.9%
Taylor expanded in x around inf 55.5%
if 4.99999999999999998e-306 < z < 1.2e63Initial program 99.9%
Taylor expanded in y around inf 52.6%
Final simplification61.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))))
(if (<= z -4.2e+45)
t_0
(if (<= z 5.1e-306) (* 4.0 (/ x y)) (if (<= z 3e+61) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -4.2e+45) {
tmp = t_0;
} else if (z <= 5.1e-306) {
tmp = 4.0 * (x / y);
} else if (z <= 3e+61) {
tmp = 4.0;
} 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) :: tmp
t_0 = z * ((-4.0d0) / y)
if (z <= (-4.2d+45)) then
tmp = t_0
else if (z <= 5.1d-306) then
tmp = 4.0d0 * (x / y)
else if (z <= 3d+61) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -4.2e+45) {
tmp = t_0;
} else if (z <= 5.1e-306) {
tmp = 4.0 * (x / y);
} else if (z <= 3e+61) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) tmp = 0 if z <= -4.2e+45: tmp = t_0 elif z <= 5.1e-306: tmp = 4.0 * (x / y) elif z <= 3e+61: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) tmp = 0.0 if (z <= -4.2e+45) tmp = t_0; elseif (z <= 5.1e-306) tmp = Float64(4.0 * Float64(x / y)); elseif (z <= 3e+61) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); tmp = 0.0; if (z <= -4.2e+45) tmp = t_0; elseif (z <= 5.1e-306) tmp = 4.0 * (x / y); elseif (z <= 3e+61) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+45], t$95$0, If[LessEqual[z, 5.1e-306], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e+61], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{-306}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+61}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.1999999999999999e45 or 3e61 < z Initial program 100.0%
Taylor expanded in z around inf 74.9%
associate-*r/74.9%
*-commutative74.9%
associate-/l*74.6%
Simplified74.6%
if -4.1999999999999999e45 < z < 5.09999999999999972e-306Initial program 99.9%
Taylor expanded in x around inf 55.5%
if 5.09999999999999972e-306 < z < 3e61Initial program 99.9%
Taylor expanded in y around inf 52.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.25e+44) (not (<= z 1.3e+57))) (/ (* 4.0 (- y z)) y) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+44) || !(z <= 1.3e+57)) {
tmp = (4.0 * (y - z)) / y;
} else {
tmp = 4.0 + (x * (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 ((z <= (-1.25d+44)) .or. (.not. (z <= 1.3d+57))) then
tmp = (4.0d0 * (y - z)) / y
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+44) || !(z <= 1.3e+57)) {
tmp = (4.0 * (y - z)) / y;
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.25e+44) or not (z <= 1.3e+57): tmp = (4.0 * (y - z)) / y else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.25e+44) || !(z <= 1.3e+57)) tmp = Float64(Float64(4.0 * Float64(y - z)) / y); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.25e+44) || ~((z <= 1.3e+57))) tmp = (4.0 * (y - z)) / y; else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.25e+44], N[Not[LessEqual[z, 1.3e+57]], $MachinePrecision]], N[(N[(4.0 * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+44} \lor \neg \left(z \leq 1.3 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{4 \cdot \left(y - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -1.2499999999999999e44 or 1.3e57 < z Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in x around 0 91.7%
if -1.2499999999999999e44 < z < 1.3e57Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 90.2%
distribute-lft-in90.2%
metadata-eval90.2%
associate-+r+90.2%
metadata-eval90.2%
associate-*r/90.2%
*-commutative90.2%
associate-*r/90.1%
Simplified90.1%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e+46) (not (<= z 6.5e+57))) (+ 4.0 (* z (/ -4.0 y))) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+46) || !(z <= 6.5e+57)) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 + (x * (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 ((z <= (-1d+46)) .or. (.not. (z <= 6.5d+57))) then
tmp = 4.0d0 + (z * ((-4.0d0) / y))
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+46) || !(z <= 6.5e+57)) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+46) or not (z <= 6.5e+57): tmp = 4.0 + (z * (-4.0 / y)) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+46) || !(z <= 6.5e+57)) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+46) || ~((z <= 6.5e+57))) tmp = 4.0 + (z * (-4.0 / y)); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+46], N[Not[LessEqual[z, 6.5e+57]], $MachinePrecision]], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+46} \lor \neg \left(z \leq 6.5 \cdot 10^{+57}\right):\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -9.9999999999999999e45 or 6.4999999999999997e57 < z Initial program 100.0%
+-commutative100.0%
associate-/l*100.0%
fma-define100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
associate--r+100.0%
div-sub100.0%
sub-neg100.0%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 91.7%
sub-neg91.7%
distribute-lft-in91.7%
metadata-eval91.7%
associate-+r+91.7%
metadata-eval91.7%
neg-mul-191.7%
associate-*r*91.7%
metadata-eval91.7%
associate-*r/91.7%
*-commutative91.7%
associate-/l*91.5%
Simplified91.5%
if -9.9999999999999999e45 < z < 6.4999999999999997e57Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 90.2%
distribute-lft-in90.2%
metadata-eval90.2%
associate-+r+90.2%
metadata-eval90.2%
associate-*r/90.2%
*-commutative90.2%
associate-*r/90.1%
Simplified90.1%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.75e+45) (not (<= z 2e+54))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+45) || !(z <= 2e+54)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (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 ((z <= (-2.75d+45)) .or. (.not. (z <= 2d+54))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+45) || !(z <= 2e+54)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.75e+45) or not (z <= 2e+54): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.75e+45) || !(z <= 2e+54)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.75e+45) || ~((z <= 2e+54))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.75e+45], N[Not[LessEqual[z, 2e+54]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+45} \lor \neg \left(z \leq 2 \cdot 10^{+54}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -2.75e45 or 2.0000000000000002e54 < z Initial program 100.0%
Taylor expanded in y around 0 83.0%
if -2.75e45 < z < 2.0000000000000002e54Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 90.2%
distribute-lft-in90.2%
metadata-eval90.2%
associate-+r+90.2%
metadata-eval90.2%
associate-*r/90.2%
*-commutative90.2%
associate-*r/90.1%
Simplified90.1%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e+139) 4.0 (if (<= y 1e+139) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+139) {
tmp = 4.0;
} else if (y <= 1e+139) {
tmp = 4.0 * ((x - z) / 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 <= (-7.5d+139)) then
tmp = 4.0d0
else if (y <= 1d+139) then
tmp = 4.0d0 * ((x - z) / 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 <= -7.5e+139) {
tmp = 4.0;
} else if (y <= 1e+139) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+139: tmp = 4.0 elif y <= 1e+139: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+139) tmp = 4.0; elseif (y <= 1e+139) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.5e+139) tmp = 4.0; elseif (y <= 1e+139) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+139], 4.0, If[LessEqual[y, 1e+139], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+139}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 10^{+139}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -7.49999999999999992e139 or 1.00000000000000003e139 < y Initial program 99.8%
Taylor expanded in y around inf 82.1%
if -7.49999999999999992e139 < y < 1.00000000000000003e139Initial program 99.9%
Taylor expanded in y around 0 80.5%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e-72) 4.0 (if (<= y 1.05e+139) (* 4.0 (/ x y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e-72) {
tmp = 4.0;
} else if (y <= 1.05e+139) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-8.2d-72)) then
tmp = 4.0d0
else if (y <= 1.05d+139) then
tmp = 4.0d0 * (x / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e-72) {
tmp = 4.0;
} else if (y <= 1.05e+139) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e-72: tmp = 4.0 elif y <= 1.05e+139: tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e-72) tmp = 4.0; elseif (y <= 1.05e+139) tmp = Float64(4.0 * Float64(x / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e-72) tmp = 4.0; elseif (y <= 1.05e+139) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e-72], 4.0, If[LessEqual[y, 1.05e+139], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-72}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+139}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -8.20000000000000007e-72 or 1.0499999999999999e139 < y Initial program 99.9%
Taylor expanded in y around inf 61.4%
if -8.20000000000000007e-72 < y < 1.0499999999999999e139Initial program 99.9%
Taylor expanded in x around inf 48.9%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (+ (- x z) y)) y))
double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - z) + y)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
def code(x, y, z): return (4.0 * ((x - z) + y)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - z) + y)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - z) + y)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - z\right) + y\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 35.2%
herbie shell --seed 2024139
(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)))