
(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 87.9%
associate--l+87.9%
distribute-lft-out--89.0%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.65e+48)
(* d1 (- d2 d3))
(if (<= d2 -1.32e-83)
(* d1 (- d4 d1))
(if (<= d2 1.56e-218) (* d1 (- (- d1) d3)) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.65e+48) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.32e-83) {
tmp = d1 * (d4 - d1);
} else if (d2 <= 1.56e-218) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (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 (d2 <= (-1.65d+48)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-1.32d-83)) then
tmp = d1 * (d4 - d1)
else if (d2 <= 1.56d-218) then
tmp = d1 * (-d1 - d3)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.65e+48) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.32e-83) {
tmp = d1 * (d4 - d1);
} else if (d2 <= 1.56e-218) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.65e+48: tmp = d1 * (d2 - d3) elif d2 <= -1.32e-83: tmp = d1 * (d4 - d1) elif d2 <= 1.56e-218: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.65e+48) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -1.32e-83) tmp = Float64(d1 * Float64(d4 - d1)); elseif (d2 <= 1.56e-218) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.65e+48) tmp = d1 * (d2 - d3); elseif (d2 <= -1.32e-83) tmp = d1 * (d4 - d1); elseif (d2 <= 1.56e-218) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.65e+48], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -1.32e-83], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 1.56e-218], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.65 \cdot 10^{+48}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.32 \cdot 10^{-83}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d2 \leq 1.56 \cdot 10^{-218}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.65000000000000011e48Initial program 89.3%
associate--l+89.3%
distribute-lft-out--89.3%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.7%
+-commutative84.7%
associate--r+84.7%
Simplified84.7%
Taylor expanded in d1 around 0 74.7%
if -1.65000000000000011e48 < d2 < -1.31999999999999994e-83Initial program 92.9%
associate--l+92.9%
distribute-lft-out--92.9%
distribute-rgt-out--96.4%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 85.2%
associate--r+85.2%
Simplified85.2%
Taylor expanded in d3 around 0 72.6%
if -1.31999999999999994e-83 < d2 < 1.55999999999999995e-218Initial program 89.2%
associate--l+89.2%
distribute-lft-out--89.2%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d4 around 0 75.9%
associate-*r*75.9%
mul-1-neg75.9%
Simplified75.9%
if 1.55999999999999995e-218 < d2 Initial program 85.3%
associate--l+85.3%
distribute-lft-out--87.9%
distribute-rgt-out--90.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 86.0%
Taylor expanded in d2 around 0 64.9%
Final simplification70.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -9e+130) (* d1 (- d2 d1)) (if (<= d1 4e+79) (* d1 (- (+ d2 d4) d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -9e+130) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 4e+79) {
tmp = d1 * ((d2 + 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 (d1 <= (-9d+130)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 4d+79) then
tmp = d1 * ((d2 + 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 (d1 <= -9e+130) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 4e+79) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -9e+130: tmp = d1 * (d2 - d1) elif d1 <= 4e+79: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -9e+130) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 4e+79) tmp = Float64(d1 * Float64(Float64(d2 + 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 (d1 <= -9e+130) tmp = d1 * (d2 - d1); elseif (d1 <= 4e+79) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -9e+130], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 4e+79], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -9 \cdot 10^{+130}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 4 \cdot 10^{+79}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -9.00000000000000078e130Initial program 77.1%
associate--l+77.1%
distribute-lft-out--77.1%
distribute-rgt-out--85.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 98.5%
+-commutative98.5%
associate--r+98.5%
Simplified98.5%
Taylor expanded in d3 around 0 93.1%
if -9.00000000000000078e130 < d1 < 3.99999999999999987e79Initial program 98.8%
associate--l+98.8%
distribute-lft-out--98.8%
distribute-rgt-out--98.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.7%
if 3.99999999999999987e79 < d1 Initial program 61.1%
associate--l+61.1%
distribute-lft-out--66.6%
distribute-rgt-out--75.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 92.6%
associate--r+92.6%
Simplified92.6%
Taylor expanded in d3 around 0 78.6%
Final simplification89.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.9e+154) (not (<= d3 1.15e+175))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.9e+154) || !(d3 <= 1.15e+175)) {
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 <= (-2.9d+154)) .or. (.not. (d3 <= 1.15d+175))) 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 <= -2.9e+154) || !(d3 <= 1.15e+175)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.9e+154) or not (d3 <= 1.15e+175): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.9e+154) || !(d3 <= 1.15e+175)) 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 <= -2.9e+154) || ~((d3 <= 1.15e+175))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.9e+154], N[Not[LessEqual[d3, 1.15e+175]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.9 \cdot 10^{+154} \lor \neg \left(d3 \leq 1.15 \cdot 10^{+175}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -2.89999999999999979e154 or 1.15e175 < d3 Initial program 79.0%
associate--l+79.0%
distribute-lft-out--83.9%
distribute-rgt-out--83.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 90.4%
associate-*r*90.4%
neg-mul-190.4%
Simplified90.4%
if -2.89999999999999979e154 < d3 < 1.15e175Initial program 90.7%
Taylor expanded in d3 around 0 82.9%
distribute-lft-out83.4%
Simplified83.4%
Taylor expanded in d1 around 0 64.9%
Final simplification71.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.26e-166) (* d1 (- d2 d1)) (if (<= d4 5e+91) (* d1 (- d2 d3)) (* d1 (+ d2 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.26e-166) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5e+91) {
tmp = d1 * (d2 - 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 (d4 <= 1.26d-166) then
tmp = d1 * (d2 - d1)
else if (d4 <= 5d+91) then
tmp = d1 * (d2 - 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 (d4 <= 1.26e-166) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5e+91) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.26e-166: tmp = d1 * (d2 - d1) elif d4 <= 5e+91: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.26e-166) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 5e+91) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.26e-166) tmp = d1 * (d2 - d1); elseif (d4 <= 5e+91) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.26e-166], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 5e+91], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.26 \cdot 10^{-166}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 5 \cdot 10^{+91}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.26e-166Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.8%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.1%
+-commutative82.1%
associate--r+82.1%
Simplified82.1%
Taylor expanded in d3 around 0 58.7%
if 1.26e-166 < d4 < 5.0000000000000002e91Initial program 90.7%
associate--l+90.7%
distribute-lft-out--93.0%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 89.0%
+-commutative89.0%
associate--r+89.0%
Simplified89.0%
Taylor expanded in d1 around 0 66.6%
if 5.0000000000000002e91 < d4 Initial program 80.0%
Taylor expanded in d3 around 0 74.3%
distribute-lft-out74.3%
Simplified74.3%
Taylor expanded in d1 around 0 80.9%
Final simplification64.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.55e-166) (* d1 (- d2 d1)) (if (<= d4 3.2e+107) (* d1 (- d2 d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.55e-166) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.2e+107) {
tmp = d1 * (d2 - 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 (d4 <= 1.55d-166) then
tmp = d1 * (d2 - d1)
else if (d4 <= 3.2d+107) then
tmp = d1 * (d2 - 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 (d4 <= 1.55e-166) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.2e+107) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.55e-166: tmp = d1 * (d2 - d1) elif d4 <= 3.2e+107: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.55e-166) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 3.2e+107) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.55e-166) tmp = d1 * (d2 - d1); elseif (d4 <= 3.2e+107) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.55e-166], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 3.2e+107], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.55 \cdot 10^{-166}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 3.2 \cdot 10^{+107}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 1.54999999999999992e-166Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.8%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.1%
+-commutative82.1%
associate--r+82.1%
Simplified82.1%
Taylor expanded in d3 around 0 58.7%
if 1.54999999999999992e-166 < d4 < 3.20000000000000029e107Initial program 89.1%
associate--l+89.1%
distribute-lft-out--91.3%
distribute-rgt-out--93.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.6%
+-commutative87.6%
associate--r+87.6%
Simplified87.6%
Taylor expanded in d1 around 0 66.7%
if 3.20000000000000029e107 < d4 Initial program 80.8%
associate--l+80.8%
distribute-lft-out--80.8%
distribute-rgt-out--89.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 89.9%
associate--r+89.9%
Simplified89.9%
Taylor expanded in d3 around 0 77.5%
Final simplification63.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.68e-167) (* d1 (- d2 d1)) (if (<= d4 5.9e+60) (* d1 (- d2 d3)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.68e-167) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5.9e+60) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (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.68d-167) then
tmp = d1 * (d2 - d1)
else if (d4 <= 5.9d+60) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (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.68e-167) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5.9e+60) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.68e-167: tmp = d1 * (d2 - d1) elif d4 <= 5.9e+60: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.68e-167) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 5.9e+60) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.68e-167) tmp = d1 * (d2 - d1); elseif (d4 <= 5.9e+60) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.68e-167], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 5.9e+60], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.68 \cdot 10^{-167}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 5.9 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.67999999999999995e-167Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.8%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.1%
+-commutative82.1%
associate--r+82.1%
Simplified82.1%
Taylor expanded in d3 around 0 58.7%
if 1.67999999999999995e-167 < d4 < 5.9000000000000002e60Initial program 92.1%
associate--l+92.1%
distribute-lft-out--94.7%
distribute-rgt-out--97.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 92.4%
+-commutative92.4%
associate--r+92.4%
Simplified92.4%
Taylor expanded in d1 around 0 69.7%
if 5.9000000000000002e60 < d4 Initial program 80.0%
associate--l+80.0%
distribute-lft-out--80.0%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.4%
Taylor expanded in d2 around 0 79.2%
Final simplification64.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.55e-267) (* d1 d2) (if (<= d4 1.2e+93) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.55e-267) {
tmp = d1 * d2;
} else if (d4 <= 1.2e+93) {
tmp = d1 * -d3;
} 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 <= 1.55d-267) then
tmp = d1 * d2
else if (d4 <= 1.2d+93) then
tmp = d1 * -d3
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 <= 1.55e-267) {
tmp = d1 * d2;
} else if (d4 <= 1.2e+93) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.55e-267: tmp = d1 * d2 elif d4 <= 1.2e+93: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.55e-267) tmp = Float64(d1 * d2); elseif (d4 <= 1.2e+93) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.55e-267) tmp = d1 * d2; elseif (d4 <= 1.2e+93) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.55e-267], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.2e+93], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.55 \cdot 10^{-267}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.2 \cdot 10^{+93}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.5500000000000001e-267Initial program 88.0%
associate--l+88.0%
distribute-lft-out--89.4%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 29.1%
if 1.5500000000000001e-267 < d4 < 1.20000000000000005e93Initial program 93.7%
associate--l+93.7%
distribute-lft-out--95.3%
distribute-rgt-out--96.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 39.9%
associate-*r*39.9%
neg-mul-139.9%
Simplified39.9%
if 1.20000000000000005e93 < d4 Initial program 80.0%
associate--l+80.0%
distribute-lft-out--80.0%
distribute-rgt-out--88.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 69.5%
Final simplification39.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e-5) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e-5) {
tmp = d1 * ((d2 - d3) - 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 (d4 <= 6d-5) then
tmp = d1 * ((d2 - d3) - 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 (d4 <= 6e-5) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e-5: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e-5) tmp = Float64(d1 * Float64(Float64(d2 - d3) - 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 (d4 <= 6e-5) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e-5], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{-5}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 6.00000000000000015e-5Initial program 90.4%
associate--l+90.4%
distribute-lft-out--92.0%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.0%
+-commutative84.0%
associate--r+84.0%
Simplified84.0%
if 6.00000000000000015e-5 < d4 Initial program 80.9%
associate--l+80.9%
distribute-lft-out--80.9%
distribute-rgt-out--88.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.6%
Final simplification86.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e-5) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e-5) {
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 <= 6d-5) 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 <= 6e-5) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e-5: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e-5) 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 <= 6e-5) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e-5], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{-5}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 6.00000000000000015e-5Initial program 90.4%
associate--l+90.4%
distribute-lft-out--92.0%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.0%
+-commutative84.0%
associate--r+84.0%
Simplified84.0%
Taylor expanded in d3 around 0 60.6%
if 6.00000000000000015e-5 < d4 Initial program 80.9%
Taylor expanded in d3 around 0 72.4%
distribute-lft-out73.9%
Simplified73.9%
Taylor expanded in d1 around 0 76.0%
Final simplification64.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.4e+31) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.4e+31) {
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.4d+31)) 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.4e+31) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.4e+31: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.4e+31) 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.4e+31) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.4e+31], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.4 \cdot 10^{+31}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.39999999999999982e31Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.4%
distribute-rgt-out--94.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 56.1%
if -2.39999999999999982e31 < d2 Initial program 87.2%
associate--l+87.2%
distribute-lft-out--88.7%
distribute-rgt-out--91.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.6%
Final simplification38.9%
(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 87.9%
associate--l+87.9%
distribute-lft-out--89.0%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 26.5%
Final simplification26.5%
(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 2024059
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))