
(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 11 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 (- (+ d4 (- d2 d3)) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - 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 * ((d4 + (d2 - d3)) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - d1);
}
def code(d1, d2, d3, d4): return d1 * ((d4 + (d2 - d3)) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 + Float64(d2 - d3)) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 + (d2 - d3)) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 + \left(d2 - d3\right)\right) - d1\right)
\end{array}
Initial program 89.0%
+-commutative89.0%
*-commutative89.0%
distribute-lft-out--90.6%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.8e+102) (not (<= d3 70000000000000.0))) (* d1 (- (+ d4 d2) d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+102) || !(d3 <= 70000000000000.0)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - 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 <= (-1.8d+102)) .or. (.not. (d3 <= 70000000000000.0d0))) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * ((d4 + d2) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+102) || !(d3 <= 70000000000000.0)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.8e+102) or not (d3 <= 70000000000000.0): tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.8e+102) || !(d3 <= 70000000000000.0)) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.8e+102) || ~((d3 <= 70000000000000.0))) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * ((d4 + d2) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.8e+102], N[Not[LessEqual[d3, 70000000000000.0]], $MachinePrecision]], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.8 \cdot 10^{+102} \lor \neg \left(d3 \leq 70000000000000\right):\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -1.8000000000000001e102 or 7e13 < d3 Initial program 88.0%
+-commutative88.0%
*-commutative88.0%
distribute-lft-out--90.8%
distribute-lft-out93.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.4%
if -1.8000000000000001e102 < d3 < 7e13Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--90.5%
distribute-lft-out90.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.8%
Final simplification96.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -1.6e+137) (* d1 (- d2 d3)) (if (<= d3 3.35e+67) (* d1 (- (+ d4 d2) d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -1.6e+137) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 3.35e+67) {
tmp = d1 * ((d4 + d2) - d1);
} 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 (d3 <= (-1.6d+137)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 3.35d+67) then
tmp = d1 * ((d4 + d2) - d1)
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 (d3 <= -1.6e+137) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 3.35e+67) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -1.6e+137: tmp = d1 * (d2 - d3) elif d3 <= 3.35e+67: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -1.6e+137) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 3.35e+67) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -1.6e+137) tmp = d1 * (d2 - d3); elseif (d3 <= 3.35e+67) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -1.6e+137], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 3.35e+67], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.6 \cdot 10^{+137}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 3.35 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -1.60000000000000009e137Initial program 80.6%
sub-neg80.6%
associate-+l+80.6%
*-commutative80.6%
+-commutative80.6%
*-commutative80.6%
sub-neg80.6%
+-commutative80.6%
associate--l+80.6%
distribute-lft-out--83.3%
fma-define91.6%
distribute-rgt-out--91.6%
Simplified91.6%
Taylor expanded in d4 around 0 71.7%
mul-1-neg71.7%
+-commutative71.7%
unsub-neg71.7%
Simplified71.7%
Taylor expanded in d1 around 0 80.0%
if -1.60000000000000009e137 < d3 < 3.35000000000000022e67Initial program 90.6%
+-commutative90.6%
*-commutative90.6%
distribute-lft-out--91.7%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.0%
if 3.35000000000000022e67 < d3 Initial program 90.0%
+-commutative90.0%
*-commutative90.0%
distribute-lft-out--90.0%
distribute-lft-out94.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.0%
Taylor expanded in d2 around 0 69.6%
Final simplification87.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.35e+169) (not (<= d3 8.2e+181))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.35e+169) || !(d3 <= 8.2e+181)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
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.35d+169)) .or. (.not. (d3 <= 8.2d+181))) then
tmp = d1 * -d3
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.35e+169) || !(d3 <= 8.2e+181)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.35e+169) or not (d3 <= 8.2e+181): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.35e+169) || !(d3 <= 8.2e+181)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.35e+169) || ~((d3 <= 8.2e+181))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.35e+169], N[Not[LessEqual[d3, 8.2e+181]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.35 \cdot 10^{+169} \lor \neg \left(d3 \leq 8.2 \cdot 10^{+181}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -1.34999999999999995e169 or 8.20000000000000035e181 < d3 Initial program 82.0%
+-commutative82.0%
*-commutative82.0%
distribute-lft-out--84.0%
distribute-lft-out86.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 77.6%
associate-*r*77.6%
neg-mul-177.6%
*-commutative77.6%
Simplified77.6%
if -1.34999999999999995e169 < d3 < 8.20000000000000035e181Initial program 90.8%
+-commutative90.8%
*-commutative90.8%
distribute-lft-out--92.2%
distribute-lft-out93.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 88.4%
Taylor expanded in d1 around 0 70.8%
+-commutative70.8%
Simplified70.8%
Final simplification72.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.15e-148) (* d1 (- d2 d3)) (if (<= d4 2.2e+35) (* d1 (- d2 d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.15e-148) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 2.2e+35) {
tmp = d1 * (d2 - d1);
} 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.15d-148) then
tmp = d1 * (d2 - d3)
else if (d4 <= 2.2d+35) then
tmp = d1 * (d2 - d1)
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.15e-148) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 2.2e+35) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.15e-148: tmp = d1 * (d2 - d3) elif d4 <= 2.2e+35: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.15e-148) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 2.2e+35) tmp = Float64(d1 * Float64(d2 - d1)); 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.15e-148) tmp = d1 * (d2 - d3); elseif (d4 <= 2.2e+35) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.15e-148], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 2.2e+35], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.15 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 2.2 \cdot 10^{+35}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.14999999999999999e-148Initial program 90.8%
sub-neg90.8%
associate-+l+90.8%
*-commutative90.8%
+-commutative90.8%
*-commutative90.8%
sub-neg90.8%
+-commutative90.8%
associate--l+90.8%
distribute-lft-out--91.4%
fma-define94.5%
distribute-rgt-out--96.9%
Simplified96.9%
Taylor expanded in d4 around 0 74.5%
mul-1-neg74.5%
+-commutative74.5%
unsub-neg74.5%
Simplified74.5%
Taylor expanded in d1 around 0 62.9%
if 1.14999999999999999e-148 < d4 < 2.1999999999999999e35Initial program 87.1%
+-commutative87.1%
*-commutative87.1%
distribute-lft-out--89.7%
distribute-lft-out89.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 88.0%
Taylor expanded in d4 around 0 78.4%
if 2.1999999999999999e35 < d4 Initial program 85.2%
+-commutative85.2%
*-commutative85.2%
distribute-lft-out--85.2%
distribute-lft-out88.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.6%
Taylor expanded in d2 around 0 74.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4e+43) (* d1 d2) (if (<= d2 5.4e-151) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4e+43) {
tmp = d1 * d2;
} else if (d2 <= 5.4e-151) {
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 (d2 <= (-4d+43)) then
tmp = d1 * d2
else if (d2 <= 5.4d-151) 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 (d2 <= -4e+43) {
tmp = d1 * d2;
} else if (d2 <= 5.4e-151) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4e+43: tmp = d1 * d2 elif d2 <= 5.4e-151: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4e+43) tmp = Float64(d1 * d2); elseif (d2 <= 5.4e-151) 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 (d2 <= -4e+43) tmp = d1 * d2; elseif (d2 <= 5.4e-151) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4e+43], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 5.4e-151], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4 \cdot 10^{+43}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 5.4 \cdot 10^{-151}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -4.00000000000000006e43Initial program 83.9%
+-commutative83.9%
*-commutative83.9%
distribute-lft-out--90.3%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 66.0%
if -4.00000000000000006e43 < d2 < 5.40000000000000014e-151Initial program 91.6%
+-commutative91.6%
*-commutative91.6%
distribute-lft-out--91.6%
distribute-lft-out91.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 45.9%
associate-*r*45.9%
neg-mul-145.9%
*-commutative45.9%
Simplified45.9%
if 5.40000000000000014e-151 < d2 Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--89.9%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 30.1%
Final simplification44.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.2e-157) (* d1 d2) (if (<= d4 2.9e+82) (- (* d1 d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.2e-157) {
tmp = d1 * d2;
} else if (d4 <= 2.9e+82) {
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 <= 1.2d-157) then
tmp = d1 * d2
else if (d4 <= 2.9d+82) 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 <= 1.2e-157) {
tmp = d1 * d2;
} else if (d4 <= 2.9e+82) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.2e-157: tmp = d1 * d2 elif d4 <= 2.9e+82: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.2e-157) tmp = Float64(d1 * d2); elseif (d4 <= 2.9e+82) 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 <= 1.2e-157) tmp = d1 * d2; elseif (d4 <= 2.9e+82) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.2e-157], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.9e+82], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.2 \cdot 10^{-157}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.9 \cdot 10^{+82}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.2e-157Initial program 90.7%
+-commutative90.7%
*-commutative90.7%
distribute-lft-out--92.5%
distribute-lft-out93.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 34.7%
if 1.2e-157 < d4 < 2.9000000000000001e82Initial program 85.7%
+-commutative85.7%
*-commutative85.7%
distribute-lft-out--87.7%
distribute-lft-out89.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 35.1%
neg-mul-135.1%
Simplified35.1%
if 2.9000000000000001e82 < d4 Initial program 86.9%
+-commutative86.9%
*-commutative86.9%
distribute-lft-out--87.0%
distribute-lft-out89.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 63.4%
Final simplification39.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.5e+80) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.5e+80) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
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 <= 3.5d+80) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.5e+80) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.5e+80: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.5e+80) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.5e+80) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.5e+80], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.5 \cdot 10^{+80}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 3.49999999999999994e80Initial program 89.5%
sub-neg89.5%
associate-+l+89.5%
*-commutative89.5%
+-commutative89.5%
*-commutative89.5%
sub-neg89.5%
+-commutative89.5%
associate--l+89.5%
distribute-lft-out--89.9%
fma-define93.3%
distribute-rgt-out--97.1%
Simplified97.1%
Taylor expanded in d4 around 0 75.5%
mul-1-neg75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in d1 around 0 62.8%
if 3.49999999999999994e80 < d4 Initial program 87.2%
+-commutative87.2%
*-commutative87.2%
distribute-lft-out--87.2%
distribute-lft-out89.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.8%
Taylor expanded in d1 around 0 83.8%
+-commutative83.8%
Simplified83.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.6e+83) (* d1 (- d2 d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+83) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
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.6d+83) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+83) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.6e+83: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.6e+83) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.6e+83) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.6e+83], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.6 \cdot 10^{+83}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 1.5999999999999999e83Initial program 89.5%
+-commutative89.5%
*-commutative89.5%
distribute-lft-out--91.4%
distribute-lft-out92.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 74.4%
Taylor expanded in d4 around 0 55.2%
if 1.5999999999999999e83 < d4 Initial program 86.9%
+-commutative86.9%
*-commutative86.9%
distribute-lft-out--87.0%
distribute-lft-out89.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.6%
Taylor expanded in d1 around 0 85.3%
+-commutative85.3%
Simplified85.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.3e+64) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.3e+64) {
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 (d4 <= 2.3d+64) 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 (d4 <= 2.3e+64) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.3e+64: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.3e+64) 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 (d4 <= 2.3e+64) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.3e+64], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.3 \cdot 10^{+64}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.3e64Initial program 89.7%
+-commutative89.7%
*-commutative89.7%
distribute-lft-out--91.6%
distribute-lft-out92.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.2%
if 2.3e64 < d4 Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
distribute-lft-out--86.5%
distribute-lft-out90.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 60.2%
(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 89.0%
+-commutative89.0%
*-commutative89.0%
distribute-lft-out--90.6%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.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 2024163
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))