
(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 (- (+ 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 85.5%
+-commutative85.5%
*-commutative85.5%
distribute-lft-out--87.1%
distribute-lft-out90.2%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 -1.02e-135)
t_0
(if (<= d4 7.5e-158)
(* d1 (- (- d1) d3))
(if (<= d4 32000000.0) t_0 (* d1 (- d4 d3)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= -1.02e-135) {
tmp = t_0;
} else if (d4 <= 7.5e-158) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 32000000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d4 <= (-1.02d-135)) then
tmp = t_0
else if (d4 <= 7.5d-158) then
tmp = d1 * (-d1 - d3)
else if (d4 <= 32000000.0d0) then
tmp = t_0
else
tmp = d1 * (d4 - d3)
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 (d4 <= -1.02e-135) {
tmp = t_0;
} else if (d4 <= 7.5e-158) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 32000000.0) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= -1.02e-135: tmp = t_0 elif d4 <= 7.5e-158: tmp = d1 * (-d1 - d3) elif d4 <= 32000000.0: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= -1.02e-135) tmp = t_0; elseif (d4 <= 7.5e-158) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d4 <= 32000000.0) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= -1.02e-135) tmp = t_0; elseif (d4 <= 7.5e-158) tmp = d1 * (-d1 - d3); elseif (d4 <= 32000000.0) tmp = t_0; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -1.02e-135], t$95$0, If[LessEqual[d4, 7.5e-158], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 32000000.0], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq -1.02 \cdot 10^{-135}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 7.5 \cdot 10^{-158}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d4 \leq 32000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.01999999999999994e-135 or 7.5e-158 < d4 < 3.2e7Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--88.5%
distribute-lft-out92.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.1%
Taylor expanded in d4 around 0 66.0%
if -1.01999999999999994e-135 < d4 < 7.5e-158Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--88.9%
distribute-lft-out88.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 71.5%
Taylor expanded in d4 around 0 71.5%
associate-*r*71.5%
neg-mul-171.5%
Simplified71.5%
if 3.2e7 < d4 Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
distribute-lft-out--82.3%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.0%
Taylor expanded in d4 around 0 85.6%
Taylor expanded in d2 around 0 76.8%
+-commutative76.8%
neg-mul-176.8%
distribute-rgt-neg-in76.8%
distribute-lft-in78.4%
sub-neg78.4%
Simplified78.4%
Final simplification70.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -6.5e+185) (* d1 (- d1)) (if (<= d1 5.5e+126) (* d1 (- (+ d4 d2) d3)) (* d1 (- (- d1) d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -6.5e+185) {
tmp = d1 * -d1;
} else if (d1 <= 5.5e+126) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (-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 (d1 <= (-6.5d+185)) then
tmp = d1 * -d1
else if (d1 <= 5.5d+126) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * (-d1 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -6.5e+185) {
tmp = d1 * -d1;
} else if (d1 <= 5.5e+126) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (-d1 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -6.5e+185: tmp = d1 * -d1 elif d1 <= 5.5e+126: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (-d1 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -6.5e+185) tmp = Float64(d1 * Float64(-d1)); elseif (d1 <= 5.5e+126) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(Float64(-d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -6.5e+185) tmp = d1 * -d1; elseif (d1 <= 5.5e+126) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (-d1 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -6.5e+185], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d1, 5.5e+126], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -6.5 \cdot 10^{+185}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d1 \leq 5.5 \cdot 10^{+126}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -6.5000000000000002e185Initial program 40.6%
+-commutative40.6%
*-commutative40.6%
distribute-lft-out--50.0%
distribute-lft-out62.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 87.5%
neg-mul-187.5%
Simplified87.5%
if -6.5000000000000002e185 < d1 < 5.5000000000000004e126Initial program 98.4%
+-commutative98.4%
*-commutative98.4%
distribute-lft-out--98.4%
distribute-lft-out98.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.6%
if 5.5000000000000004e126 < d1 Initial program 58.3%
+-commutative58.3%
*-commutative58.3%
distribute-lft-out--61.1%
distribute-lft-out69.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 94.4%
Taylor expanded in d4 around 0 91.7%
associate-*r*91.7%
neg-mul-191.7%
Simplified91.7%
Final simplification91.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -9e+83) (not (<= d3 1.75e+150))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -9e+83) || !(d3 <= 1.75e+150)) {
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 <= (-9d+83)) .or. (.not. (d3 <= 1.75d+150))) 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 <= -9e+83) || !(d3 <= 1.75e+150)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -9e+83) or not (d3 <= 1.75e+150): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -9e+83) || !(d3 <= 1.75e+150)) 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 <= -9e+83) || ~((d3 <= 1.75e+150))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -9e+83], N[Not[LessEqual[d3, 1.75e+150]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -9 \cdot 10^{+83} \lor \neg \left(d3 \leq 1.75 \cdot 10^{+150}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -8.9999999999999999e83 or 1.74999999999999992e150 < d3 Initial program 84.6%
+-commutative84.6%
*-commutative84.6%
distribute-lft-out--86.8%
distribute-lft-out89.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 74.7%
mul-1-neg74.7%
distribute-rgt-neg-out74.7%
Simplified74.7%
if -8.9999999999999999e83 < d3 < 1.74999999999999992e150Initial program 86.0%
+-commutative86.0%
*-commutative86.0%
distribute-lft-out--87.3%
distribute-lft-out90.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 79.8%
Taylor expanded in d3 around 0 69.8%
Final simplification71.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -1.42e-260) (* d1 d2) (if (<= d4 8.6e-12) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.42e-260) {
tmp = d1 * d2;
} else if (d4 <= 8.6e-12) {
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.42d-260)) then
tmp = d1 * d2
else if (d4 <= 8.6d-12) 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.42e-260) {
tmp = d1 * d2;
} else if (d4 <= 8.6e-12) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.42e-260: tmp = d1 * d2 elif d4 <= 8.6e-12: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.42e-260) tmp = Float64(d1 * d2); elseif (d4 <= 8.6e-12) 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.42e-260) tmp = d1 * d2; elseif (d4 <= 8.6e-12) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.42e-260], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 8.6e-12], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.42 \cdot 10^{-260}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 8.6 \cdot 10^{-12}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.42000000000000004e-260Initial program 87.4%
+-commutative87.4%
*-commutative87.4%
distribute-lft-out--88.3%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.0%
if -1.42000000000000004e-260 < d4 < 8.59999999999999971e-12Initial program 87.9%
+-commutative87.9%
*-commutative87.9%
distribute-lft-out--89.1%
distribute-lft-out89.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 45.5%
mul-1-neg45.5%
distribute-rgt-neg-out45.5%
Simplified45.5%
if 8.59999999999999971e-12 < d4 Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
distribute-lft-out--82.3%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 60.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -6.5e-134) (* d1 d2) (if (<= d4 32000000.0) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -6.5e-134) {
tmp = d1 * d2;
} else if (d4 <= 32000000.0) {
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 <= (-6.5d-134)) then
tmp = d1 * d2
else if (d4 <= 32000000.0d0) 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 <= -6.5e-134) {
tmp = d1 * d2;
} else if (d4 <= 32000000.0) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -6.5e-134: tmp = d1 * d2 elif d4 <= 32000000.0: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -6.5e-134) tmp = Float64(d1 * d2); elseif (d4 <= 32000000.0) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -6.5e-134) tmp = d1 * d2; elseif (d4 <= 32000000.0) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -6.5e-134], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 32000000.0], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -6.5 \cdot 10^{-134}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 32000000:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -6.4999999999999998e-134Initial program 85.4%
+-commutative85.4%
*-commutative85.4%
distribute-lft-out--86.6%
distribute-lft-out91.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.9%
if -6.4999999999999998e-134 < d4 < 3.2e7Initial program 89.2%
+-commutative89.2%
*-commutative89.2%
distribute-lft-out--90.2%
distribute-lft-out90.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 36.2%
neg-mul-136.2%
Simplified36.2%
if 3.2e7 < d4 Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
distribute-lft-out--82.3%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 60.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.6e+20) (* d1 (- (+ d4 d2) d3)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+20) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 - d3) - 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.6d+20)) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * ((d4 - d3) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+20) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.6e+20: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.6e+20) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.6e+20) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.6e+20], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.6 \cdot 10^{+20}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -2.6e20Initial program 83.0%
+-commutative83.0%
*-commutative83.0%
distribute-lft-out--84.7%
distribute-lft-out91.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 98.3%
if -2.6e20 < d2 Initial program 86.3%
+-commutative86.3%
*-commutative86.3%
distribute-lft-out--87.8%
distribute-lft-out89.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 84.3%
Final simplification87.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 28000000.0) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 28000000.0) {
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 <= 28000000.0d0) 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 <= 28000000.0) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 28000000.0: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 28000000.0) 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 <= 28000000.0) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 28000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 28000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 2.8e7Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--88.6%
distribute-lft-out90.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.8%
Taylor expanded in d4 around 0 68.9%
if 2.8e7 < d4 Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
distribute-lft-out--82.3%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.0%
Taylor expanded in d4 around 0 85.6%
Taylor expanded in d2 around 0 76.8%
+-commutative76.8%
neg-mul-176.8%
distribute-rgt-neg-in76.8%
distribute-lft-in78.4%
sub-neg78.4%
Simplified78.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.8e+105) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e+105) {
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.8d+105) 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.8e+105) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.8e+105: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.8e+105) 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.8e+105) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.8e+105], 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.8 \cdot 10^{+105}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 3.8e105Initial program 87.5%
+-commutative87.5%
*-commutative87.5%
distribute-lft-out--88.5%
distribute-lft-out90.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 82.2%
Taylor expanded in d4 around 0 68.4%
if 3.8e105 < d4 Initial program 76.6%
+-commutative76.6%
*-commutative76.6%
distribute-lft-out--80.9%
distribute-lft-out87.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.6%
Taylor expanded in d3 around 0 80.2%
Final simplification70.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 10000000.0) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 10000000.0) {
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 <= 10000000.0d0) 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 <= 10000000.0) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 10000000.0: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 10000000.0) 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 <= 10000000.0) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 10000000.0], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 10000000:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1e7Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--88.6%
distribute-lft-out90.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.6%
if 1e7 < d4 Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
distribute-lft-out--82.3%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 60.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -2.75e+202) (* d1 d3) (* d1 d2)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.75e+202) {
tmp = d1 * d3;
} else {
tmp = d1 * 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 (d1 <= (-2.75d+202)) then
tmp = d1 * d3
else
tmp = d1 * d2
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.75e+202) {
tmp = d1 * d3;
} else {
tmp = d1 * d2;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -2.75e+202: tmp = d1 * d3 else: tmp = d1 * d2 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -2.75e+202) tmp = Float64(d1 * d3); else tmp = Float64(d1 * d2); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -2.75e+202) tmp = d1 * d3; else tmp = d1 * d2; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -2.75e+202], N[(d1 * d3), $MachinePrecision], N[(d1 * d2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.75 \cdot 10^{+202}:\\
\;\;\;\;d1 \cdot d3\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d2\\
\end{array}
\end{array}
if d1 < -2.75000000000000006e202Initial program 37.0%
+-commutative37.0%
*-commutative37.0%
distribute-lft-out--48.1%
distribute-lft-out59.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 66.7%
Taylor expanded in d4 around 0 55.6%
Taylor expanded in d3 around inf 16.3%
neg-mul-116.3%
distribute-lft-neg-in16.3%
Simplified16.3%
add-sqr-sqrt16.3%
sqrt-unprod40.7%
sqr-neg40.7%
sqrt-unprod0.0%
add-sqr-sqrt37.9%
pow137.9%
Applied egg-rr37.9%
unpow137.9%
Simplified37.9%
if -2.75000000000000006e202 < d1 Initial program 91.2%
+-commutative91.2%
*-commutative91.2%
distribute-lft-out--91.7%
distribute-lft-out93.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.7%
(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.5%
+-commutative85.5%
*-commutative85.5%
distribute-lft-out--87.1%
distribute-lft-out90.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.9%
(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 2024170
(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)))