
(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 10 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 85.1%
associate--l+85.1%
distribute-lft-out--86.3%
distribute-rgt-out--89.8%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -8e+39)
(* d1 (- d2 d3))
(if (<= d2 -3.9e-35)
(* d1 (- d2 d1))
(if (or (<= d2 -5e-202) (not (<= d2 4.3e-266)))
(* d1 (- d4 d3))
(* d1 (- d4 d1))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8e+39) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -3.9e-35) {
tmp = d1 * (d2 - d1);
} else if ((d2 <= -5e-202) || !(d2 <= 4.3e-266)) {
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 <= (-8d+39)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-3.9d-35)) then
tmp = d1 * (d2 - d1)
else if ((d2 <= (-5d-202)) .or. (.not. (d2 <= 4.3d-266))) 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 <= -8e+39) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -3.9e-35) {
tmp = d1 * (d2 - d1);
} else if ((d2 <= -5e-202) || !(d2 <= 4.3e-266)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8e+39: tmp = d1 * (d2 - d3) elif d2 <= -3.9e-35: tmp = d1 * (d2 - d1) elif (d2 <= -5e-202) or not (d2 <= 4.3e-266): tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8e+39) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -3.9e-35) tmp = Float64(d1 * Float64(d2 - d1)); elseif ((d2 <= -5e-202) || !(d2 <= 4.3e-266)) 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 <= -8e+39) tmp = d1 * (d2 - d3); elseif (d2 <= -3.9e-35) tmp = d1 * (d2 - d1); elseif ((d2 <= -5e-202) || ~((d2 <= 4.3e-266))) tmp = d1 * (d4 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8e+39], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -3.9e-35], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -5e-202], N[Not[LessEqual[d2, 4.3e-266]], $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 -8 \cdot 10^{+39}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -3.9 \cdot 10^{-35}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d2 \leq -5 \cdot 10^{-202} \lor \neg \left(d2 \leq 4.3 \cdot 10^{-266}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -7.99999999999999952e39Initial program 83.3%
associate--l+83.3%
distribute-lft-out--86.7%
distribute-rgt-out--88.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.9%
Taylor expanded in d4 around 0 77.6%
if -7.99999999999999952e39 < d2 < -3.8999999999999998e-35Initial program 87.5%
associate--l+87.5%
distribute-lft-out--87.5%
distribute-rgt-out--93.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 85.1%
Taylor expanded in d4 around 0 57.6%
if -3.8999999999999998e-35 < d2 < -4.99999999999999973e-202 or 4.30000000000000028e-266 < d2 Initial program 84.0%
associate--l+84.0%
distribute-lft-out--84.6%
distribute-rgt-out--89.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.2%
Taylor expanded in d2 around 0 60.0%
if -4.99999999999999973e-202 < d2 < 4.30000000000000028e-266Initial program 95.8%
associate--l+95.8%
distribute-lft-out--95.8%
distribute-rgt-out--95.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.9%
Taylor expanded in d2 around 0 91.9%
Final simplification67.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- d2 d3))))
(if (<= d4 -2.4e-145)
t_1
(if (<= d4 6e-109)
t_0
(if (<= d4 8.4e-19)
t_1
(if (<= d4 2050000000000.0) t_0 (* d1 (+ d2 d4))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.4e-145) {
tmp = t_1;
} else if (d4 <= 6e-109) {
tmp = t_0;
} else if (d4 <= 8.4e-19) {
tmp = t_1;
} else if (d4 <= 2050000000000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * (d2 - d1)
t_1 = d1 * (d2 - d3)
if (d4 <= (-2.4d-145)) then
tmp = t_1
else if (d4 <= 6d-109) then
tmp = t_0
else if (d4 <= 8.4d-19) then
tmp = t_1
else if (d4 <= 2050000000000.0d0) then
tmp = t_0
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.4e-145) {
tmp = t_1;
} else if (d4 <= 6e-109) {
tmp = t_0;
} else if (d4 <= 8.4e-19) {
tmp = t_1;
} else if (d4 <= 2050000000000.0) {
tmp = t_0;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (d2 - d3) tmp = 0 if d4 <= -2.4e-145: tmp = t_1 elif d4 <= 6e-109: tmp = t_0 elif d4 <= 8.4e-19: tmp = t_1 elif d4 <= 2050000000000.0: tmp = t_0 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= -2.4e-145) tmp = t_1; elseif (d4 <= 6e-109) tmp = t_0; elseif (d4 <= 8.4e-19) tmp = t_1; elseif (d4 <= 2050000000000.0) tmp = t_0; else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= -2.4e-145) tmp = t_1; elseif (d4 <= 6e-109) tmp = t_0; elseif (d4 <= 8.4e-19) tmp = t_1; elseif (d4 <= 2050000000000.0) tmp = t_0; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -2.4e-145], t$95$1, If[LessEqual[d4, 6e-109], t$95$0, If[LessEqual[d4, 8.4e-19], t$95$1, If[LessEqual[d4, 2050000000000.0], t$95$0, N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq -2.4 \cdot 10^{-145}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 6 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 8.4 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 2050000000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < -2.40000000000000015e-145 or 6.00000000000000043e-109 < d4 < 8.3999999999999996e-19Initial program 86.9%
associate--l+86.9%
distribute-lft-out--87.7%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 83.1%
Taylor expanded in d4 around 0 54.6%
if -2.40000000000000015e-145 < d4 < 6.00000000000000043e-109 or 8.3999999999999996e-19 < d4 < 2.05e12Initial program 80.3%
associate--l+80.3%
distribute-lft-out--83.1%
distribute-rgt-out--84.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 72.7%
Taylor expanded in d4 around 0 72.7%
if 2.05e12 < d4 Initial program 87.3%
associate--l+87.3%
distribute-lft-out--87.3%
distribute-rgt-out--92.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.7%
Taylor expanded in d1 around 0 85.8%
Final simplification66.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -5.3e+156) (not (<= d3 3.3e+62))) (* d1 (- d2 d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -5.3e+156) || !(d3 <= 3.3e+62)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * ((d2 + 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 ((d3 <= (-5.3d+156)) .or. (.not. (d3 <= 3.3d+62))) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -5.3e+156) || !(d3 <= 3.3e+62)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -5.3e+156) or not (d3 <= 3.3e+62): tmp = d1 * (d2 - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -5.3e+156) || !(d3 <= 3.3e+62)) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -5.3e+156) || ~((d3 <= 3.3e+62))) tmp = d1 * (d2 - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -5.3e+156], N[Not[LessEqual[d3, 3.3e+62]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -5.3 \cdot 10^{+156} \lor \neg \left(d3 \leq 3.3 \cdot 10^{+62}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -5.2999999999999998e156 or 3.3e62 < d3 Initial program 77.6%
associate--l+77.6%
distribute-lft-out--79.1%
distribute-rgt-out--82.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.0%
Taylor expanded in d4 around 0 77.9%
if -5.2999999999999998e156 < d3 < 3.3e62Initial program 87.8%
associate--l+87.8%
distribute-lft-out--88.9%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.8%
Final simplification90.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -4.4e+128) (not (<= d1 1e+55))) (* d1 (- (+ d2 d4) d1)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.4e+128) || !(d1 <= 1e+55)) {
tmp = d1 * ((d2 + d4) - d1);
} 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 ((d1 <= (-4.4d+128)) .or. (.not. (d1 <= 1d+55))) then
tmp = d1 * ((d2 + d4) - d1)
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 ((d1 <= -4.4e+128) || !(d1 <= 1e+55)) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -4.4e+128) or not (d1 <= 1e+55): tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -4.4e+128) || !(d1 <= 1e+55)) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); 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 ((d1 <= -4.4e+128) || ~((d1 <= 1e+55))) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -4.4e+128], N[Not[LessEqual[d1, 1e+55]], $MachinePrecision]], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.4 \cdot 10^{+128} \lor \neg \left(d1 \leq 10^{+55}\right):\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -4.40000000000000033e128 or 1.00000000000000001e55 < d1 Initial program 57.9%
associate--l+57.9%
distribute-lft-out--61.3%
distribute-rgt-out--71.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.4%
if -4.40000000000000033e128 < d1 < 1.00000000000000001e55Initial program 99.4%
associate--l+99.4%
distribute-lft-out--99.4%
distribute-rgt-out--99.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.3%
Final simplification95.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -4.4e+155) (not (<= d3 3.3e+62))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.4e+155) || !(d3 <= 3.3e+62)) {
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 <= (-4.4d+155)) .or. (.not. (d3 <= 3.3d+62))) 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 <= -4.4e+155) || !(d3 <= 3.3e+62)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -4.4e+155) or not (d3 <= 3.3e+62): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -4.4e+155) || !(d3 <= 3.3e+62)) 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 <= -4.4e+155) || ~((d3 <= 3.3e+62))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -4.4e+155], N[Not[LessEqual[d3, 3.3e+62]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4.4 \cdot 10^{+155} \lor \neg \left(d3 \leq 3.3 \cdot 10^{+62}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -4.4000000000000005e155 or 3.3e62 < d3 Initial program 77.6%
associate--l+77.6%
distribute-lft-out--79.1%
distribute-rgt-out--82.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 75.0%
mul-1-neg75.0%
distribute-rgt-neg-out75.0%
Simplified75.0%
if -4.4000000000000005e155 < d3 < 3.3e62Initial program 87.8%
associate--l+87.8%
distribute-lft-out--88.9%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.8%
Taylor expanded in d1 around 0 75.6%
Final simplification75.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -4e-292) (* d1 d2) (if (<= d4 8.8e+24) (- (* d1 d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -4e-292) {
tmp = d1 * d2;
} else if (d4 <= 8.8e+24) {
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 (d4 <= (-4d-292)) then
tmp = d1 * d2
else if (d4 <= 8.8d+24) 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 (d4 <= -4e-292) {
tmp = d1 * d2;
} else if (d4 <= 8.8e+24) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -4e-292: tmp = d1 * d2 elif d4 <= 8.8e+24: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -4e-292) tmp = Float64(d1 * d2); elseif (d4 <= 8.8e+24) 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 (d4 <= -4e-292) tmp = d1 * d2; elseif (d4 <= 8.8e+24) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -4e-292], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 8.8e+24], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -4 \cdot 10^{-292}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 8.8 \cdot 10^{+24}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -4.0000000000000002e-292Initial program 85.9%
associate--l+85.9%
distribute-lft-out--87.4%
distribute-rgt-out--91.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around inf 32.1%
if -4.0000000000000002e-292 < d4 < 8.80000000000000007e24Initial program 81.8%
associate--l+81.8%
distribute-lft-out--83.3%
distribute-rgt-out--84.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 41.5%
neg-mul-141.5%
Simplified41.5%
if 8.80000000000000007e24 < d4 Initial program 87.3%
associate--l+87.3%
distribute-lft-out--87.3%
distribute-rgt-out--92.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 62.8%
Final simplification41.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1400000000000.0) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1400000000000.0) {
tmp = d1 * (d2 - d1);
} 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 (d4 <= 1400000000000.0d0) then
tmp = d1 * (d2 - d1)
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 (d4 <= 1400000000000.0) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1400000000000.0: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1400000000000.0) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1400000000000.0) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1400000000000.0], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1400000000000:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.4e12Initial program 84.6%
associate--l+84.6%
distribute-lft-out--86.1%
distribute-rgt-out--89.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.4%
Taylor expanded in d4 around 0 60.2%
if 1.4e12 < d4 Initial program 87.3%
associate--l+87.3%
distribute-lft-out--87.3%
distribute-rgt-out--92.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.7%
Taylor expanded in d1 around 0 85.8%
Final simplification65.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5e+57) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+57) {
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 <= (-5d+57)) 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 <= -5e+57) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5e+57: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5e+57) 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 <= -5e+57) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5e+57], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -4.99999999999999972e57Initial program 82.1%
associate--l+82.1%
distribute-lft-out--85.7%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 65.6%
if -4.99999999999999972e57 < d2 Initial program 86.0%
associate--l+86.0%
distribute-lft-out--86.5%
distribute-rgt-out--90.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 36.7%
Final simplification43.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
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
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 85.1%
associate--l+85.1%
distribute-lft-out--86.3%
distribute-rgt-out--89.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.6%
Final simplification33.6%
(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 2024048
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))