
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d3) (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d2 - d3) + (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d3) + (d4 - d1)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 88.7%
associate--l+88.7%
distribute-lft-out--89.8%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -1.9e+107)
t_0
(if (<= d3 -2.1e-173)
(* d1 (+ d2 d4))
(if (<= d3 1.9e-122)
(* d1 (- d2 d1))
(if (<= d3 1.15e+71) (* d1 (- d4 d1)) t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -1.9e+107) {
tmp = t_0;
} else if (d3 <= -2.1e-173) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.9e-122) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.15e+71) {
tmp = d1 * (d4 - d1);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d3 <= (-1.9d+107)) then
tmp = t_0
else if (d3 <= (-2.1d-173)) then
tmp = d1 * (d2 + d4)
else if (d3 <= 1.9d-122) then
tmp = d1 * (d2 - d1)
else if (d3 <= 1.15d+71) then
tmp = d1 * (d4 - d1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -1.9e+107) {
tmp = t_0;
} else if (d3 <= -2.1e-173) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.9e-122) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.15e+71) {
tmp = d1 * (d4 - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -1.9e+107: tmp = t_0 elif d3 <= -2.1e-173: tmp = d1 * (d2 + d4) elif d3 <= 1.9e-122: tmp = d1 * (d2 - d1) elif d3 <= 1.15e+71: tmp = d1 * (d4 - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -1.9e+107) tmp = t_0; elseif (d3 <= -2.1e-173) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 1.9e-122) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 1.15e+71) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -1.9e+107) tmp = t_0; elseif (d3 <= -2.1e-173) tmp = d1 * (d2 + d4); elseif (d3 <= 1.9e-122) tmp = d1 * (d2 - d1); elseif (d3 <= 1.15e+71) tmp = d1 * (d4 - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -1.9e+107], t$95$0, If[LessEqual[d3, -2.1e-173], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.9e-122], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.15e+71], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -1.9 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -2.1 \cdot 10^{-173}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 1.9 \cdot 10^{-122}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 1.15 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -1.8999999999999999e107 or 1.1500000000000001e71 < d3 Initial program 84.2%
associate--l+84.2%
distribute-lft-out--87.6%
distribute-rgt-out--87.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 84.4%
Taylor expanded in d1 around 0 77.7%
if -1.8999999999999999e107 < d3 < -2.10000000000000001e-173Initial program 94.5%
associate--l+94.5%
distribute-lft-out--94.5%
distribute-rgt-out--98.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 85.8%
Taylor expanded in d3 around 0 77.5%
+-commutative77.5%
Simplified77.5%
if -2.10000000000000001e-173 < d3 < 1.9e-122Initial program 89.9%
associate--l+89.9%
distribute-lft-out--89.9%
distribute-rgt-out--95.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 76.3%
Taylor expanded in d3 around 0 76.3%
if 1.9e-122 < d3 < 1.1500000000000001e71Initial program 88.3%
associate--l+88.3%
distribute-lft-out--88.3%
distribute-rgt-out--90.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 68.3%
Taylor expanded in d3 around 0 61.8%
Final simplification74.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -2.3e+138)
(* d1 (- d2 d3))
(if (or (<= d2 -1.45e-20) (not (<= d2 3.5e-43)))
(* d1 (- d4 d3))
(* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.3e+138) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -1.45e-20) || !(d2 <= 3.5e-43)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.3d+138)) then
tmp = d1 * (d2 - d3)
else if ((d2 <= (-1.45d-20)) .or. (.not. (d2 <= 3.5d-43))) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.3e+138) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -1.45e-20) || !(d2 <= 3.5e-43)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.3e+138: tmp = d1 * (d2 - d3) elif (d2 <= -1.45e-20) or not (d2 <= 3.5e-43): tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.3e+138) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d2 <= -1.45e-20) || !(d2 <= 3.5e-43)) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.3e+138) tmp = d1 * (d2 - d3); elseif ((d2 <= -1.45e-20) || ~((d2 <= 3.5e-43))) tmp = d1 * (d4 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.3e+138], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -1.45e-20], N[Not[LessEqual[d2, 3.5e-43]], $MachinePrecision]], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.3 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.45 \cdot 10^{-20} \lor \neg \left(d2 \leq 3.5 \cdot 10^{-43}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -2.30000000000000008e138Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.1%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.2%
Taylor expanded in d1 around 0 75.9%
if -2.30000000000000008e138 < d2 < -1.45e-20 or 3.49999999999999997e-43 < d2 Initial program 86.6%
associate--l+86.6%
distribute-lft-out--87.6%
distribute-rgt-out--90.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 62.2%
Taylor expanded in d1 around 0 50.4%
if -1.45e-20 < d2 < 3.49999999999999997e-43Initial program 92.7%
associate--l+92.7%
distribute-lft-out--92.7%
distribute-rgt-out--95.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d3 around 0 70.3%
Final simplification63.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -2.2e+138)
(* d1 d2)
(if (<= d2 -7.2e+21)
(* d1 d4)
(if (<= d2 2.35e-297) (- (* d1 d1)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.2e+138) {
tmp = d1 * d2;
} else if (d2 <= -7.2e+21) {
tmp = d1 * d4;
} else if (d2 <= 2.35e-297) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.2d+138)) then
tmp = d1 * d2
else if (d2 <= (-7.2d+21)) then
tmp = d1 * d4
else if (d2 <= 2.35d-297) then
tmp = -(d1 * d1)
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.2e+138) {
tmp = d1 * d2;
} else if (d2 <= -7.2e+21) {
tmp = d1 * d4;
} else if (d2 <= 2.35e-297) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.2e+138: tmp = d1 * d2 elif d2 <= -7.2e+21: tmp = d1 * d4 elif d2 <= 2.35e-297: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.2e+138) tmp = Float64(d1 * d2); elseif (d2 <= -7.2e+21) tmp = Float64(d1 * d4); elseif (d2 <= 2.35e-297) tmp = Float64(-Float64(d1 * d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.2e+138) tmp = d1 * d2; elseif (d2 <= -7.2e+21) tmp = d1 * d4; elseif (d2 <= 2.35e-297) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.2e+138], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -7.2e+21], N[(d1 * d4), $MachinePrecision], If[LessEqual[d2, 2.35e-297], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.2 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -7.2 \cdot 10^{+21}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{elif}\;d2 \leq 2.35 \cdot 10^{-297}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.2000000000000001e138Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.1%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 70.3%
if -2.2000000000000001e138 < d2 < -7.2e21 or 2.34999999999999993e-297 < d2 Initial program 88.4%
associate--l+88.4%
distribute-lft-out--89.1%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 35.1%
if -7.2e21 < d2 < 2.34999999999999993e-297Initial program 93.2%
associate--l+93.2%
distribute-lft-out--93.2%
distribute-rgt-out--97.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 44.4%
unpow244.4%
mul-1-neg44.4%
distribute-rgt-neg-out44.4%
Simplified44.4%
Final simplification42.7%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -2.35e+138)
(* d1 d2)
(if (<= d2 -4.5e-18)
(* d1 (- d3))
(if (<= d2 2.7e-296) (- (* d1 d1)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.35e+138) {
tmp = d1 * d2;
} else if (d2 <= -4.5e-18) {
tmp = d1 * -d3;
} else if (d2 <= 2.7e-296) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.35d+138)) then
tmp = d1 * d2
else if (d2 <= (-4.5d-18)) then
tmp = d1 * -d3
else if (d2 <= 2.7d-296) then
tmp = -(d1 * d1)
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.35e+138) {
tmp = d1 * d2;
} else if (d2 <= -4.5e-18) {
tmp = d1 * -d3;
} else if (d2 <= 2.7e-296) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.35e+138: tmp = d1 * d2 elif d2 <= -4.5e-18: tmp = d1 * -d3 elif d2 <= 2.7e-296: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.35e+138) tmp = Float64(d1 * d2); elseif (d2 <= -4.5e-18) tmp = Float64(d1 * Float64(-d3)); elseif (d2 <= 2.7e-296) tmp = Float64(-Float64(d1 * d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.35e+138) tmp = d1 * d2; elseif (d2 <= -4.5e-18) tmp = d1 * -d3; elseif (d2 <= 2.7e-296) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.35e+138], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -4.5e-18], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d2, 2.7e-296], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.35 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4.5 \cdot 10^{-18}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d2 \leq 2.7 \cdot 10^{-296}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.3499999999999999e138Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.1%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 70.3%
if -2.3499999999999999e138 < d2 < -4.49999999999999994e-18Initial program 88.5%
associate--l+88.5%
distribute-lft-out--88.5%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 25.2%
associate-*r*25.2%
neg-mul-125.2%
*-commutative25.2%
Simplified25.2%
if -4.49999999999999994e-18 < d2 < 2.69999999999999999e-296Initial program 92.5%
associate--l+92.5%
distribute-lft-out--92.5%
distribute-rgt-out--97.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 45.2%
unpow245.2%
mul-1-neg45.2%
distribute-rgt-neg-out45.2%
Simplified45.2%
if 2.69999999999999999e-296 < d2 Initial program 88.9%
associate--l+88.9%
distribute-lft-out--89.7%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 31.0%
Final simplification39.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.65e+112) (not (<= d3 1.85e+157))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.65e+112) || !(d3 <= 1.85e+157)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-1.65d+112)) .or. (.not. (d3 <= 1.85d+157))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.65e+112) || !(d3 <= 1.85e+157)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.65e+112) or not (d3 <= 1.85e+157): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.65e+112) || !(d3 <= 1.85e+157)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.65e+112) || ~((d3 <= 1.85e+157))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.65e+112], N[Not[LessEqual[d3, 1.85e+157]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.65 \cdot 10^{+112} \lor \neg \left(d3 \leq 1.85 \cdot 10^{+157}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.64999999999999995e112 or 1.8499999999999999e157 < d3 Initial program 81.8%
associate--l+81.8%
distribute-lft-out--86.3%
distribute-rgt-out--86.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around inf 76.3%
associate-*r*76.3%
neg-mul-176.3%
*-commutative76.3%
Simplified76.3%
if -1.64999999999999995e112 < d3 < 1.8499999999999999e157Initial program 91.0%
associate--l+91.0%
distribute-lft-out--91.0%
distribute-rgt-out--94.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 75.5%
Taylor expanded in d3 around 0 67.5%
+-commutative67.5%
Simplified67.5%
Final simplification69.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -680000000000.0) (* d1 (+ d2 d4)) (if (<= d2 -2.5e-17) (* d1 (- d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -680000000000.0) {
tmp = d1 * (d2 + d4);
} else if (d2 <= -2.5e-17) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-680000000000.0d0)) then
tmp = d1 * (d2 + d4)
else if (d2 <= (-2.5d-17)) then
tmp = d1 * -d3
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -680000000000.0) {
tmp = d1 * (d2 + d4);
} else if (d2 <= -2.5e-17) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -680000000000.0: tmp = d1 * (d2 + d4) elif d2 <= -2.5e-17: tmp = d1 * -d3 else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -680000000000.0) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d2 <= -2.5e-17) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -680000000000.0) tmp = d1 * (d2 + d4); elseif (d2 <= -2.5e-17) tmp = d1 * -d3; else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -680000000000.0], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -2.5e-17], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -680000000000:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d2 \leq -2.5 \cdot 10^{-17}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -6.8e11Initial program 82.8%
associate--l+82.8%
distribute-lft-out--86.2%
distribute-rgt-out--87.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.4%
Taylor expanded in d3 around 0 83.8%
+-commutative83.8%
Simplified83.8%
if -6.8e11 < d2 < -2.4999999999999999e-17Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 75.5%
associate-*r*75.5%
neg-mul-175.5%
*-commutative75.5%
Simplified75.5%
if -2.4999999999999999e-17 < d2 Initial program 90.2%
associate--l+90.2%
distribute-lft-out--90.7%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.1%
Taylor expanded in d3 around 0 57.7%
Final simplification63.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.75e+138) (* d1 (- d2 d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.75e+138) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.75d+138)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.75e+138) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.75e+138: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.75e+138) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.75e+138) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.75e+138], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.75 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -2.7499999999999999e138Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.1%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.2%
Taylor expanded in d1 around 0 75.9%
if -2.7499999999999999e138 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--90.4%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.3%
Final simplification82.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5e+14) (* d1 (- (+ d2 d4) d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+14) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5d+14)) then
tmp = d1 * ((d2 + d4) - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+14) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5e+14: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5e+14) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5e+14) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5e+14], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5 \cdot 10^{+14}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -5e14Initial program 82.8%
associate--l+82.8%
distribute-lft-out--86.2%
distribute-rgt-out--87.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.4%
if -5e14 < d2 Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.9%
distribute-rgt-out--93.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.4%
Final simplification85.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.02e+38) (* d1 (- d2 (+ d1 d3))) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.02e+38) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 1.02d+38) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.02e+38) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.02e+38: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.02e+38) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.02e+38) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.02e+38], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.02 \cdot 10^{+38}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 1.02000000000000006e38Initial program 89.1%
associate--l+89.1%
distribute-lft-out--90.6%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 81.6%
if 1.02000000000000006e38 < d4 Initial program 87.0%
associate--l+87.0%
distribute-lft-out--87.0%
distribute-rgt-out--94.4%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 92.7%
Final simplification83.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.75e+138) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.75e+138) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.75d+138)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.75e+138) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.75e+138: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.75e+138) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.75e+138) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.75e+138], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.75 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.7499999999999999e138Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.1%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 70.3%
if -2.7499999999999999e138 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--90.4%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.0%
Final simplification39.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d4))
double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d4
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
def code(d1, d2, d3, d4): return d1 * d4
function code(d1, d2, d3, d4) return Float64(d1 * d4) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d4; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d4), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d4
\end{array}
Initial program 88.7%
associate--l+88.7%
distribute-lft-out--89.8%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 32.4%
Final simplification32.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2023194
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:herbie-target
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))