
(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 11 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.5%
+-commutative99.5%
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
(if (or (<= y -1.9e+47)
(and (not (<= y 3.3e-32)) (or (<= y 7.8e+44) (not (<= y 3.8e+92)))))
(+ 4.0 (/ (* 4.0 x) y))
(* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+47) || (!(y <= 3.3e-32) && ((y <= 7.8e+44) || !(y <= 3.8e+92)))) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 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) :: tmp
if ((y <= (-1.9d+47)) .or. (.not. (y <= 3.3d-32)) .and. (y <= 7.8d+44) .or. (.not. (y <= 3.8d+92))) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+47) || (!(y <= 3.3e-32) && ((y <= 7.8e+44) || !(y <= 3.8e+92)))) {
tmp = 4.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.9e+47) or (not (y <= 3.3e-32) and ((y <= 7.8e+44) or not (y <= 3.8e+92))): tmp = 4.0 + ((4.0 * x) / y) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.9e+47) || (!(y <= 3.3e-32) && ((y <= 7.8e+44) || !(y <= 3.8e+92)))) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.9e+47) || (~((y <= 3.3e-32)) && ((y <= 7.8e+44) || ~((y <= 3.8e+92))))) tmp = 4.0 + ((4.0 * x) / y); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.9e+47], And[N[Not[LessEqual[y, 3.3e-32]], $MachinePrecision], Or[LessEqual[y, 7.8e+44], N[Not[LessEqual[y, 3.8e+92]], $MachinePrecision]]]], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+47} \lor \neg \left(y \leq 3.3 \cdot 10^{-32}\right) \land \left(y \leq 7.8 \cdot 10^{+44} \lor \neg \left(y \leq 3.8 \cdot 10^{+92}\right)\right):\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -1.9000000000000002e47 or 3.30000000000000025e-32 < y < 7.8000000000000005e44 or 3.8e92 < y Initial program 99.0%
+-commutative99.0%
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 87.0%
distribute-lft-in87.0%
metadata-eval87.0%
associate-+r+87.0%
metadata-eval87.0%
*-commutative87.0%
associate-*l/87.0%
Simplified87.0%
if -1.9000000000000002e47 < y < 3.30000000000000025e-32 or 7.8000000000000005e44 < y < 3.8e92Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 91.5%
*-commutative91.5%
Simplified91.5%
Final simplification89.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* z -4.0) y)) (t_1 (/ (* 4.0 x) y)))
(if (<= z -6e+27)
t_0
(if (<= z 8.2e-275)
t_1
(if (<= z 3.3e-142) 4.0 (if (<= z 4.2e-20) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double t_1 = (4.0 * x) / y;
double tmp;
if (z <= -6e+27) {
tmp = t_0;
} else if (z <= 8.2e-275) {
tmp = t_1;
} else if (z <= 3.3e-142) {
tmp = 4.0;
} else if (z <= 4.2e-20) {
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 = (z * (-4.0d0)) / y
t_1 = (4.0d0 * x) / y
if (z <= (-6d+27)) then
tmp = t_0
else if (z <= 8.2d-275) then
tmp = t_1
else if (z <= 3.3d-142) then
tmp = 4.0d0
else if (z <= 4.2d-20) 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 = (z * -4.0) / y;
double t_1 = (4.0 * x) / y;
double tmp;
if (z <= -6e+27) {
tmp = t_0;
} else if (z <= 8.2e-275) {
tmp = t_1;
} else if (z <= 3.3e-142) {
tmp = 4.0;
} else if (z <= 4.2e-20) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * -4.0) / y t_1 = (4.0 * x) / y tmp = 0 if z <= -6e+27: tmp = t_0 elif z <= 8.2e-275: tmp = t_1 elif z <= 3.3e-142: tmp = 4.0 elif z <= 4.2e-20: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * -4.0) / y) t_1 = Float64(Float64(4.0 * x) / y) tmp = 0.0 if (z <= -6e+27) tmp = t_0; elseif (z <= 8.2e-275) tmp = t_1; elseif (z <= 3.3e-142) tmp = 4.0; elseif (z <= 4.2e-20) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * -4.0) / y; t_1 = (4.0 * x) / y; tmp = 0.0; if (z <= -6e+27) tmp = t_0; elseif (z <= 8.2e-275) tmp = t_1; elseif (z <= 3.3e-142) tmp = 4.0; elseif (z <= 4.2e-20) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, -6e+27], t$95$0, If[LessEqual[z, 8.2e-275], t$95$1, If[LessEqual[z, 3.3e-142], 4.0, If[LessEqual[z, 4.2e-20], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z \cdot -4}{y}\\
t_1 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;z \leq -6 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{-275}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-142}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.99999999999999953e27 or 4.1999999999999998e-20 < z Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 63.8%
*-commutative63.8%
associate-*l/63.8%
Simplified63.8%
if -5.99999999999999953e27 < z < 8.19999999999999949e-275 or 3.2999999999999997e-142 < z < 4.1999999999999998e-20Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 53.2%
*-commutative53.2%
associate-*l/53.2%
Simplified53.2%
if 8.19999999999999949e-275 < z < 3.2999999999999997e-142Initial program 97.4%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 61.1%
Final simplification59.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (/ (* 4.0 x) y)))
(if (<= z -1e+68)
t_0
(if (<= z 2.9e-273)
t_1
(if (<= z 2.4e-134) 4.0 (if (<= z 4.5e-20) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = (4.0 * x) / y;
double tmp;
if (z <= -1e+68) {
tmp = t_0;
} else if (z <= 2.9e-273) {
tmp = t_1;
} else if (z <= 2.4e-134) {
tmp = 4.0;
} else if (z <= 4.5e-20) {
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 = z * ((-4.0d0) / y)
t_1 = (4.0d0 * x) / y
if (z <= (-1d+68)) then
tmp = t_0
else if (z <= 2.9d-273) then
tmp = t_1
else if (z <= 2.4d-134) then
tmp = 4.0d0
else if (z <= 4.5d-20) 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 = z * (-4.0 / y);
double t_1 = (4.0 * x) / y;
double tmp;
if (z <= -1e+68) {
tmp = t_0;
} else if (z <= 2.9e-273) {
tmp = t_1;
} else if (z <= 2.4e-134) {
tmp = 4.0;
} else if (z <= 4.5e-20) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = (4.0 * x) / y tmp = 0 if z <= -1e+68: tmp = t_0 elif z <= 2.9e-273: tmp = t_1 elif z <= 2.4e-134: tmp = 4.0 elif z <= 4.5e-20: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(Float64(4.0 * x) / y) tmp = 0.0 if (z <= -1e+68) tmp = t_0; elseif (z <= 2.9e-273) tmp = t_1; elseif (z <= 2.4e-134) tmp = 4.0; elseif (z <= 4.5e-20) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = (4.0 * x) / y; tmp = 0.0; if (z <= -1e+68) tmp = t_0; elseif (z <= 2.9e-273) tmp = t_1; elseif (z <= 2.4e-134) tmp = 4.0; elseif (z <= 4.5e-20) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, -1e+68], t$95$0, If[LessEqual[z, 2.9e-273], t$95$1, If[LessEqual[z, 2.4e-134], 4.0, If[LessEqual[z, 4.5e-20], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-273}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-134}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.99999999999999953e67 or 4.5000000000000001e-20 < z Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 94.1%
Taylor expanded in z around inf 65.1%
metadata-eval65.1%
distribute-lft-neg-in65.1%
*-lft-identity65.1%
associate-*l/64.8%
associate-*l*64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
associate-*r/64.8%
metadata-eval64.8%
distribute-neg-frac64.8%
metadata-eval64.8%
Simplified64.8%
if -9.99999999999999953e67 < z < 2.89999999999999986e-273 or 2.4000000000000001e-134 < z < 4.5000000000000001e-20Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 52.1%
*-commutative52.1%
associate-*l/52.1%
Simplified52.1%
if 2.89999999999999986e-273 < z < 2.4000000000000001e-134Initial program 97.4%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 61.1%
Final simplification59.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (* x (/ 4.0 y))))
(if (<= z -9.5e+67)
t_0
(if (<= z 2.35e-272)
t_1
(if (<= z 7.8e-143) 4.0 (if (<= z 3.7e-22) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = x * (4.0 / y);
double tmp;
if (z <= -9.5e+67) {
tmp = t_0;
} else if (z <= 2.35e-272) {
tmp = t_1;
} else if (z <= 7.8e-143) {
tmp = 4.0;
} else if (z <= 3.7e-22) {
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 = z * ((-4.0d0) / y)
t_1 = x * (4.0d0 / y)
if (z <= (-9.5d+67)) then
tmp = t_0
else if (z <= 2.35d-272) then
tmp = t_1
else if (z <= 7.8d-143) then
tmp = 4.0d0
else if (z <= 3.7d-22) 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 = z * (-4.0 / y);
double t_1 = x * (4.0 / y);
double tmp;
if (z <= -9.5e+67) {
tmp = t_0;
} else if (z <= 2.35e-272) {
tmp = t_1;
} else if (z <= 7.8e-143) {
tmp = 4.0;
} else if (z <= 3.7e-22) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = x * (4.0 / y) tmp = 0 if z <= -9.5e+67: tmp = t_0 elif z <= 2.35e-272: tmp = t_1 elif z <= 7.8e-143: tmp = 4.0 elif z <= 3.7e-22: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (z <= -9.5e+67) tmp = t_0; elseif (z <= 2.35e-272) tmp = t_1; elseif (z <= 7.8e-143) tmp = 4.0; elseif (z <= 3.7e-22) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = x * (4.0 / y); tmp = 0.0; if (z <= -9.5e+67) tmp = t_0; elseif (z <= 2.35e-272) tmp = t_1; elseif (z <= 7.8e-143) tmp = 4.0; elseif (z <= 3.7e-22) tmp = t_1; 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]}, Block[{t$95$1 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+67], t$95$0, If[LessEqual[z, 2.35e-272], t$95$1, If[LessEqual[z, 7.8e-143], 4.0, If[LessEqual[z, 3.7e-22], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := x \cdot \frac{4}{y}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.35 \cdot 10^{-272}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{-143}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.5000000000000002e67 or 3.7e-22 < z Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 94.1%
Taylor expanded in z around inf 65.1%
metadata-eval65.1%
distribute-lft-neg-in65.1%
*-lft-identity65.1%
associate-*l/64.8%
associate-*l*64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
associate-*r/64.8%
metadata-eval64.8%
distribute-neg-frac64.8%
metadata-eval64.8%
Simplified64.8%
if -9.5000000000000002e67 < z < 2.3499999999999999e-272 or 7.80000000000000007e-143 < z < 3.7e-22Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around inf 52.1%
*-commutative52.1%
associate-*l/52.1%
associate-*r/52.0%
Simplified52.0%
if 2.3499999999999999e-272 < z < 7.80000000000000007e-143Initial program 97.4%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 61.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.3e+49) (+ 4.0 (/ (* 4.0 x) y)) (if (<= y 4.7e-14) (* 4.0 (/ (- x z) y)) (+ 4.0 (/ (* z -4.0) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.3e+49) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 4.7e-14) {
tmp = 4.0 * ((x - z) / 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 (y <= (-3.3d+49)) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else if (y <= 4.7d-14) then
tmp = 4.0d0 * ((x - z) / 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 (y <= -3.3e+49) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 4.7e-14) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.3e+49: tmp = 4.0 + ((4.0 * x) / y) elif y <= 4.7e-14: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.3e+49) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); elseif (y <= 4.7e-14) tmp = Float64(4.0 * Float64(Float64(x - z) / 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 (y <= -3.3e+49) tmp = 4.0 + ((4.0 * x) / y); elseif (y <= 4.7e-14) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.3e+49], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.7e-14], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+49}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{-14}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if y < -3.2999999999999998e49Initial program 97.8%
+-commutative97.8%
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 86.3%
distribute-lft-in86.3%
metadata-eval86.3%
associate-+r+86.3%
metadata-eval86.3%
*-commutative86.3%
associate-*l/86.3%
Simplified86.3%
if -3.2999999999999998e49 < y < 4.7000000000000002e-14Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 92.4%
*-commutative92.4%
Simplified92.4%
if 4.7000000000000002e-14 < y Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 83.8%
div-sub83.8%
*-commutative83.8%
*-lft-identity83.8%
associate-*l/83.7%
associate-*r*83.8%
lft-mult-inverse83.9%
metadata-eval83.9%
sub-neg83.9%
distribute-lft-in83.9%
metadata-eval83.9%
associate-+r+83.9%
metadata-eval83.9%
neg-mul-183.9%
associate-*r*83.9%
metadata-eval83.9%
*-commutative83.9%
associate-*l/83.9%
Simplified83.9%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (<= y -8.8e+181) 4.0 (if (<= y 2.6e+109) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+181) {
tmp = 4.0;
} else if (y <= 2.6e+109) {
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 <= (-8.8d+181)) then
tmp = 4.0d0
else if (y <= 2.6d+109) 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 <= -8.8e+181) {
tmp = 4.0;
} else if (y <= 2.6e+109) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.8e+181: tmp = 4.0 elif y <= 2.6e+109: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.8e+181) tmp = 4.0; elseif (y <= 2.6e+109) 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 <= -8.8e+181) tmp = 4.0; elseif (y <= 2.6e+109) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.8e+181], 4.0, If[LessEqual[y, 2.6e+109], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+181}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+109}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -8.8000000000000004e181 or 2.5999999999999998e109 < y Initial program 98.3%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 83.0%
if -8.8000000000000004e181 < y < 2.5999999999999998e109Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 82.7%
*-commutative82.7%
Simplified82.7%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e+141) (not (<= x 3.8e-8))) (* x (/ 4.0 y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+141) || !(x <= 3.8e-8)) {
tmp = x * (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 ((x <= (-9.5d+141)) .or. (.not. (x <= 3.8d-8))) then
tmp = x * (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 ((x <= -9.5e+141) || !(x <= 3.8e-8)) {
tmp = x * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+141) or not (x <= 3.8e-8): tmp = x * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+141) || !(x <= 3.8e-8)) tmp = Float64(x * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.5e+141) || ~((x <= 3.8e-8))) tmp = x * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+141], N[Not[LessEqual[x, 3.8e-8]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+141} \lor \neg \left(x \leq 3.8 \cdot 10^{-8}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -9.49999999999999974e141 or 3.80000000000000028e-8 < x Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 95.8%
Taylor expanded in x around inf 69.3%
*-commutative69.3%
associate-*l/69.3%
associate-*r/69.2%
Simplified69.2%
if -9.49999999999999974e141 < x < 3.80000000000000028e-8Initial program 99.3%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 45.7%
Final simplification54.4%
(FPCore (x y z) :precision binary64 (+ 1.0 (* 4.0 (/ (+ x (- (* 0.75 y) z)) y))))
double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - 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 + ((0.75d0 * y) - z)) / y))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y));
}
def code(x, y, z): return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y))
function code(x, y, z) return Float64(1.0 + Float64(4.0 * Float64(Float64(x + Float64(Float64(0.75 * y) - z)) / y))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y)); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 * N[(N[(x + N[(N[(0.75 * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \frac{x + \left(0.75 \cdot y - z\right)}{y}
\end{array}
Initial program 99.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (+ 1.0 (* 4.0 (- (+ 0.75 (/ x y)) (/ z y)))))
double code(double x, double y, double z) {
return 1.0 + (4.0 * ((0.75 + (x / y)) - (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 * ((0.75d0 + (x / y)) - (z / y)))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 * ((0.75 + (x / y)) - (z / y)));
}
def code(x, y, z): return 1.0 + (4.0 * ((0.75 + (x / y)) - (z / y)))
function code(x, y, z) return Float64(1.0 + Float64(4.0 * Float64(Float64(0.75 + Float64(x / y)) - Float64(z / y)))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 * ((0.75 + (x / y)) - (z / y))); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 * N[(N[(0.75 + N[(x / y), $MachinePrecision]), $MachinePrecision] - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \left(\left(0.75 + \frac{x}{y}\right) - \frac{z}{y}\right)
\end{array}
Initial program 99.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 97.3%
(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.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 34.0%
herbie shell --seed 2024085
(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)))