
(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.4%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -2.1e-188)
(* d1 d2)
(if (<= d4 0.000195)
(* d1 (- d1))
(if (<= d4 2.85e+110) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -2.1e-188) {
tmp = d1 * d2;
} else if (d4 <= 0.000195) {
tmp = d1 * -d1;
} else if (d4 <= 2.85e+110) {
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 <= (-2.1d-188)) then
tmp = d1 * d2
else if (d4 <= 0.000195d0) then
tmp = d1 * -d1
else if (d4 <= 2.85d+110) 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 <= -2.1e-188) {
tmp = d1 * d2;
} else if (d4 <= 0.000195) {
tmp = d1 * -d1;
} else if (d4 <= 2.85e+110) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -2.1e-188: tmp = d1 * d2 elif d4 <= 0.000195: tmp = d1 * -d1 elif d4 <= 2.85e+110: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -2.1e-188) tmp = Float64(d1 * d2); elseif (d4 <= 0.000195) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 2.85e+110) 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 <= -2.1e-188) tmp = d1 * d2; elseif (d4 <= 0.000195) tmp = d1 * -d1; elseif (d4 <= 2.85e+110) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -2.1e-188], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 0.000195], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 2.85e+110], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -2.1 \cdot 10^{-188}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 0.000195:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 2.85 \cdot 10^{+110}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -2.0999999999999999e-188Initial program 87.2%
associate--l+87.2%
distribute-lft-out--90.2%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 28.6%
if -2.0999999999999999e-188 < d4 < 1.94999999999999996e-4Initial program 93.8%
associate--l+93.8%
distribute-lft-out--93.8%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 42.0%
neg-mul-142.0%
Simplified42.0%
if 1.94999999999999996e-4 < d4 < 2.8500000000000001e110Initial program 92.2%
associate--l+92.2%
distribute-lft-out--92.2%
distribute-rgt-out--96.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 37.1%
associate-*r*37.1%
neg-mul-137.1%
Simplified37.1%
if 2.8500000000000001e110 < d4 Initial program 77.1%
associate--l+77.1%
distribute-lft-out--79.2%
distribute-rgt-out--89.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 78.7%
Final simplification43.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.22e+141) (* d1 (- (- d1) d3)) (if (<= d1 3.9e+89) (* d1 (- (+ d2 d4) d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.22e+141) {
tmp = d1 * (-d1 - d3);
} else if (d1 <= 3.9e+89) {
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 <= (-1.22d+141)) then
tmp = d1 * (-d1 - d3)
else if (d1 <= 3.9d+89) 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 <= -1.22e+141) {
tmp = d1 * (-d1 - d3);
} else if (d1 <= 3.9e+89) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.22e+141: tmp = d1 * (-d1 - d3) elif d1 <= 3.9e+89: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.22e+141) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d1 <= 3.9e+89) 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 <= -1.22e+141) tmp = d1 * (-d1 - d3); elseif (d1 <= 3.9e+89) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.22e+141], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 3.9e+89], 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 -1.22 \cdot 10^{+141}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d1 \leq 3.9 \cdot 10^{+89}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -1.2199999999999999e141Initial program 62.8%
associate--l+62.8%
distribute-lft-out--67.4%
distribute-rgt-out--72.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 96.7%
+-commutative96.7%
associate--r+96.7%
Simplified96.7%
Taylor expanded in d4 around 0 92.1%
associate-*r*92.1%
neg-mul-192.1%
Simplified92.1%
if -1.2199999999999999e141 < d1 < 3.90000000000000011e89Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.0%
if 3.90000000000000011e89 < d1 Initial program 71.7%
associate--l+71.7%
distribute-lft-out--75.5%
distribute-rgt-out--86.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 98.1%
+-commutative98.1%
associate--r+98.1%
Simplified98.1%
Taylor expanded in d3 around 0 89.5%
Final simplification92.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -4.7e-279) (* d1 (- d2 d3)) (if (<= d4 1.2e+109) (* d1 (- (- d1) d3)) (* d1 (+ d2 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -4.7e-279) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.2e+109) {
tmp = d1 * (-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 (d4 <= (-4.7d-279)) then
tmp = d1 * (d2 - d3)
else if (d4 <= 1.2d+109) then
tmp = d1 * (-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 (d4 <= -4.7e-279) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.2e+109) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -4.7e-279: tmp = d1 * (d2 - d3) elif d4 <= 1.2e+109: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -4.7e-279) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 1.2e+109) tmp = Float64(d1 * Float64(Float64(-d1) - 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 <= -4.7e-279) tmp = d1 * (d2 - d3); elseif (d4 <= 1.2e+109) tmp = d1 * (-d1 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -4.7e-279], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.2e+109], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -4.7 \cdot 10^{-279}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 1.2 \cdot 10^{+109}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < -4.69999999999999985e-279Initial program 88.0%
associate--l+88.0%
distribute-lft-out--90.6%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.0%
Taylor expanded in d4 around 0 55.3%
if -4.69999999999999985e-279 < d4 < 1.19999999999999994e109Initial program 93.4%
associate--l+93.4%
distribute-lft-out--93.4%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 73.9%
+-commutative73.9%
associate--r+73.9%
Simplified73.9%
Taylor expanded in d4 around 0 68.4%
associate-*r*68.4%
neg-mul-168.4%
Simplified68.4%
if 1.19999999999999994e109 < d4 Initial program 77.1%
associate--l+77.1%
distribute-lft-out--79.2%
distribute-rgt-out--89.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.8%
Taylor expanded in d3 around 0 92.9%
+-commutative92.9%
Simplified92.9%
Final simplification67.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.75e+141) (not (<= d1 2.5e+87))) (* d1 (- d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.75e+141) || !(d1 <= 2.5e+87)) {
tmp = d1 * -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 ((d1 <= (-2.75d+141)) .or. (.not. (d1 <= 2.5d+87))) then
tmp = d1 * -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 ((d1 <= -2.75e+141) || !(d1 <= 2.5e+87)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.75e+141) or not (d1 <= 2.5e+87): tmp = d1 * -d1 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.75e+141) || !(d1 <= 2.5e+87)) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -2.75e+141) || ~((d1 <= 2.5e+87))) tmp = d1 * -d1; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.75e+141], N[Not[LessEqual[d1, 2.5e+87]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.75 \cdot 10^{+141} \lor \neg \left(d1 \leq 2.5 \cdot 10^{+87}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d1 < -2.74999999999999984e141 or 2.4999999999999999e87 < d1 Initial program 68.0%
associate--l+68.0%
distribute-lft-out--72.1%
distribute-rgt-out--80.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 79.8%
neg-mul-179.8%
Simplified79.8%
if -2.74999999999999984e141 < d1 < 2.4999999999999999e87Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.0%
Taylor expanded in d3 around 0 65.9%
+-commutative65.9%
Simplified65.9%
Final simplification71.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -5.4e-192) (* d1 d2) (if (<= d4 2.4e+115) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -5.4e-192) {
tmp = d1 * d2;
} else if (d4 <= 2.4e+115) {
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 <= (-5.4d-192)) then
tmp = d1 * d2
else if (d4 <= 2.4d+115) 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 <= -5.4e-192) {
tmp = d1 * d2;
} else if (d4 <= 2.4e+115) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -5.4e-192: tmp = d1 * d2 elif d4 <= 2.4e+115: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -5.4e-192) tmp = Float64(d1 * d2); elseif (d4 <= 2.4e+115) 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 <= -5.4e-192) tmp = d1 * d2; elseif (d4 <= 2.4e+115) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -5.4e-192], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.4e+115], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -5.4 \cdot 10^{-192}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.4 \cdot 10^{+115}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -5.39999999999999982e-192Initial program 87.2%
associate--l+87.2%
distribute-lft-out--90.2%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 28.6%
if -5.39999999999999982e-192 < d4 < 2.4e115Initial program 93.4%
associate--l+93.4%
distribute-lft-out--93.4%
distribute-rgt-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 41.1%
neg-mul-141.1%
Simplified41.1%
if 2.4e115 < d4 Initial program 76.6%
associate--l+76.6%
distribute-lft-out--78.7%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 78.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.9e+19) (* d1 (- (+ d2 d4) d3)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.9e+19) {
tmp = d1 * ((d2 + d4) - 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 <= (-4.9d+19)) then
tmp = d1 * ((d2 + d4) - 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 <= -4.9e+19) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.9e+19: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.9e+19) tmp = Float64(d1 * Float64(Float64(d2 + d4) - 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 <= -4.9e+19) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4.9e+19], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.9 \cdot 10^{+19}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -4.9e19Initial program 81.5%
associate--l+81.5%
distribute-lft-out--87.7%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.1%
if -4.9e19 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--90.0%
distribute-rgt-out--92.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 85.9%
+-commutative85.9%
associate--r+85.9%
Simplified85.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -31000.0) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -31000.0) {
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 (d2 <= (-31000.0d0)) 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 (d2 <= -31000.0) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -31000.0: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -31000.0) 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 (d2 <= -31000.0) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -31000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -31000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -31000Initial program 80.6%
associate--l+80.6%
distribute-lft-out--86.6%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.4%
Taylor expanded in d4 around 0 69.2%
if -31000 < d2 Initial program 90.5%
associate--l+90.5%
distribute-lft-out--90.5%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 85.8%
+-commutative85.8%
associate--r+85.8%
Simplified85.8%
Taylor expanded in d3 around 0 62.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.15e+109) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.15e+109) {
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.15d+109) 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.15e+109) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.15e+109: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.15e+109) 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.15e+109) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.15e+109], 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.15 \cdot 10^{+109}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.15000000000000005e109Initial program 90.4%
associate--l+90.4%
distribute-lft-out--91.8%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 75.4%
Taylor expanded in d4 around 0 58.7%
if 1.15000000000000005e109 < d4 Initial program 77.1%
associate--l+77.1%
distribute-lft-out--79.2%
distribute-rgt-out--89.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.8%
Taylor expanded in d3 around 0 92.9%
+-commutative92.9%
Simplified92.9%
Final simplification65.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.3e+35) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.3e+35) {
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 <= (-5.3d+35)) 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 <= -5.3e+35) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.3e+35: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.3e+35) 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 <= -5.3e+35) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.3e+35], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.3 \cdot 10^{+35}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.30000000000000009e35Initial program 82.3%
associate--l+82.3%
distribute-lft-out--88.7%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 54.1%
if -5.30000000000000009e35 < d2 Initial program 89.7%
associate--l+89.7%
distribute-lft-out--89.7%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.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.4%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 27.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
double code(double d1, double d2, double d3, double d4) {
return 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 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
def code(d1, d2, d3, d4): return d1 * d1
function code(d1, d2, d3, d4) return Float64(d1 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d1
\end{array}
Initial program 87.9%
associate--l+87.9%
distribute-lft-out--89.4%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 36.1%
neg-mul-136.1%
Simplified36.1%
neg-sub036.1%
sub-neg36.1%
add-sqr-sqrt17.3%
sqrt-unprod20.1%
sqr-neg20.1%
sqrt-unprod2.8%
add-sqr-sqrt5.8%
Applied egg-rr5.8%
+-lft-identity5.8%
Simplified5.8%
(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 2024137
(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)))