
(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 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.4%
distribute-lft-out93.3%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.1e+84)
(* d1 (- d2 d3))
(if (<= d2 -1.5e+24)
(* d1 (- d2 d1))
(if (or (<= d2 -6.5e-286) (not (<= d2 1.65e-224)))
(* d1 (- d4 d3))
(* d1 (- d1))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.1e+84) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.5e+24) {
tmp = d1 * (d2 - d1);
} else if ((d2 <= -6.5e-286) || !(d2 <= 1.65e-224)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * -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 <= (-1.1d+84)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-1.5d+24)) then
tmp = d1 * (d2 - d1)
else if ((d2 <= (-6.5d-286)) .or. (.not. (d2 <= 1.65d-224))) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * -d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.1e+84) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.5e+24) {
tmp = d1 * (d2 - d1);
} else if ((d2 <= -6.5e-286) || !(d2 <= 1.65e-224)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * -d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.1e+84: tmp = d1 * (d2 - d3) elif d2 <= -1.5e+24: tmp = d1 * (d2 - d1) elif (d2 <= -6.5e-286) or not (d2 <= 1.65e-224): tmp = d1 * (d4 - d3) else: tmp = d1 * -d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.1e+84) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -1.5e+24) tmp = Float64(d1 * Float64(d2 - d1)); elseif ((d2 <= -6.5e-286) || !(d2 <= 1.65e-224)) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(-d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.1e+84) tmp = d1 * (d2 - d3); elseif (d2 <= -1.5e+24) tmp = d1 * (d2 - d1); elseif ((d2 <= -6.5e-286) || ~((d2 <= 1.65e-224))) tmp = d1 * (d4 - d3); else tmp = d1 * -d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.1e+84], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -1.5e+24], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -6.5e-286], N[Not[LessEqual[d2, 1.65e-224]], $MachinePrecision]], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d1)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.1 \cdot 10^{+84}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.5 \cdot 10^{+24}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d2 \leq -6.5 \cdot 10^{-286} \lor \neg \left(d2 \leq 1.65 \cdot 10^{-224}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d2 < -1.0999999999999999e84Initial program 91.5%
+-commutative91.5%
*-commutative91.5%
distribute-lft-out--91.4%
distribute-lft-out93.5%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around 0 93.5%
Taylor expanded in d4 around 0 82.7%
if -1.0999999999999999e84 < d2 < -1.49999999999999997e24Initial program 84.6%
+-commutative84.6%
*-commutative84.6%
distribute-lft-out--84.6%
distribute-lft-out84.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 84.7%
Taylor expanded in d4 around 0 62.2%
if -1.49999999999999997e24 < d2 < -6.5000000000000004e-286 or 1.6500000000000001e-224 < d2 Initial program 90.3%
+-commutative90.3%
*-commutative90.3%
distribute-lft-out--92.0%
distribute-lft-out93.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 83.3%
Taylor expanded in d2 around 0 63.0%
if -6.5000000000000004e-286 < d2 < 1.6500000000000001e-224Initial program 89.9%
+-commutative89.9%
*-commutative89.9%
distribute-lft-out--89.9%
distribute-lft-out95.0%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around inf 57.4%
neg-mul-157.4%
Simplified57.4%
Final simplification66.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d2 -5.5e+132)
(* d1 d2)
(if (<= d2 -2.05e-284)
t_0
(if (<= d2 2.6e-219)
(* d1 (- d1))
(if (<= d2 6e-165) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d2 <= -5.5e+132) {
tmp = d1 * d2;
} else if (d2 <= -2.05e-284) {
tmp = t_0;
} else if (d2 <= 2.6e-219) {
tmp = d1 * -d1;
} else if (d2 <= 6e-165) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * -d3
if (d2 <= (-5.5d+132)) then
tmp = d1 * d2
else if (d2 <= (-2.05d-284)) then
tmp = t_0
else if (d2 <= 2.6d-219) then
tmp = d1 * -d1
else if (d2 <= 6d-165) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d2 <= -5.5e+132) {
tmp = d1 * d2;
} else if (d2 <= -2.05e-284) {
tmp = t_0;
} else if (d2 <= 2.6e-219) {
tmp = d1 * -d1;
} else if (d2 <= 6e-165) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d2 <= -5.5e+132: tmp = d1 * d2 elif d2 <= -2.05e-284: tmp = t_0 elif d2 <= 2.6e-219: tmp = d1 * -d1 elif d2 <= 6e-165: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d2 <= -5.5e+132) tmp = Float64(d1 * d2); elseif (d2 <= -2.05e-284) tmp = t_0; elseif (d2 <= 2.6e-219) tmp = Float64(d1 * Float64(-d1)); elseif (d2 <= 6e-165) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d2 <= -5.5e+132) tmp = d1 * d2; elseif (d2 <= -2.05e-284) tmp = t_0; elseif (d2 <= 2.6e-219) tmp = d1 * -d1; elseif (d2 <= 6e-165) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d2, -5.5e+132], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -2.05e-284], t$95$0, If[LessEqual[d2, 2.6e-219], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d2, 6e-165], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d2 \leq -5.5 \cdot 10^{+132}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.05 \cdot 10^{-284}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d2 \leq 2.6 \cdot 10^{-219}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d2 \leq 6 \cdot 10^{-165}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.5e132Initial program 92.1%
+-commutative92.1%
*-commutative92.1%
distribute-lft-out--92.1%
distribute-lft-out94.7%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d2 around inf 72.4%
if -5.5e132 < d2 < -2.04999999999999999e-284 or 2.60000000000000002e-219 < d2 < 5.99999999999999958e-165Initial program 91.3%
+-commutative91.3%
*-commutative91.3%
distribute-lft-out--91.3%
distribute-lft-out92.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 49.2%
mul-1-neg49.2%
distribute-rgt-neg-out49.2%
Simplified49.2%
if -2.04999999999999999e-284 < d2 < 2.60000000000000002e-219Initial program 90.8%
+-commutative90.8%
*-commutative90.8%
distribute-lft-out--90.8%
distribute-lft-out95.5%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around inf 52.5%
neg-mul-152.5%
Simplified52.5%
if 5.99999999999999958e-165 < d2 Initial program 88.4%
+-commutative88.4%
*-commutative88.4%
distribute-lft-out--91.3%
distribute-lft-out93.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 23.7%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -2.6e+49)
t_0
(if (<= d3 -5.8e-258)
(* d1 (- d2 d1))
(if (<= d3 3.6e+68) (* d1 (+ d4 d2)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -2.6e+49) {
tmp = t_0;
} else if (d3 <= -5.8e-258) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 3.6e+68) {
tmp = d1 * (d4 + d2);
} else {
tmp = t_0;
}
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 (d3 <= (-2.6d+49)) then
tmp = t_0
else if (d3 <= (-5.8d-258)) then
tmp = d1 * (d2 - d1)
else if (d3 <= 3.6d+68) then
tmp = d1 * (d4 + d2)
else
tmp = t_0
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 (d3 <= -2.6e+49) {
tmp = t_0;
} else if (d3 <= -5.8e-258) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 3.6e+68) {
tmp = d1 * (d4 + d2);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -2.6e+49: tmp = t_0 elif d3 <= -5.8e-258: tmp = d1 * (d2 - d1) elif d3 <= 3.6e+68: tmp = d1 * (d4 + d2) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -2.6e+49) tmp = t_0; elseif (d3 <= -5.8e-258) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 3.6e+68) tmp = Float64(d1 * Float64(d4 + d2)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -2.6e+49) tmp = t_0; elseif (d3 <= -5.8e-258) tmp = d1 * (d2 - d1); elseif (d3 <= 3.6e+68) tmp = d1 * (d4 + d2); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -2.6e+49], t$95$0, If[LessEqual[d3, -5.8e-258], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 3.6e+68], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -2.6 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -5.8 \cdot 10^{-258}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+68}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -2.59999999999999989e49 or 3.5999999999999999e68 < 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%
Taylor expanded in d4 around 0 84.7%
if -2.59999999999999989e49 < d3 < -5.7999999999999999e-258Initial program 89.4%
+-commutative89.4%
*-commutative89.4%
distribute-lft-out--89.4%
distribute-lft-out90.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.8%
Taylor expanded in d4 around 0 71.1%
if -5.7999999999999999e-258 < d3 < 3.5999999999999999e68Initial program 93.8%
+-commutative93.8%
*-commutative93.8%
distribute-lft-out--93.8%
distribute-lft-out95.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.7%
Taylor expanded in d1 around 0 73.1%
Final simplification77.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d3 -1.26e+81)
t_0
(if (<= d3 -2.7e-258)
(* d1 (- d2 d1))
(if (<= d3 9.5e+98) (* d1 (+ d4 d2)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -1.26e+81) {
tmp = t_0;
} else if (d3 <= -2.7e-258) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 9.5e+98) {
tmp = d1 * (d4 + d2);
} else {
tmp = t_0;
}
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 * -d3
if (d3 <= (-1.26d+81)) then
tmp = t_0
else if (d3 <= (-2.7d-258)) then
tmp = d1 * (d2 - d1)
else if (d3 <= 9.5d+98) then
tmp = d1 * (d4 + d2)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -1.26e+81) {
tmp = t_0;
} else if (d3 <= -2.7e-258) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 9.5e+98) {
tmp = d1 * (d4 + d2);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d3 <= -1.26e+81: tmp = t_0 elif d3 <= -2.7e-258: tmp = d1 * (d2 - d1) elif d3 <= 9.5e+98: tmp = d1 * (d4 + d2) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d3 <= -1.26e+81) tmp = t_0; elseif (d3 <= -2.7e-258) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 9.5e+98) tmp = Float64(d1 * Float64(d4 + d2)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d3 <= -1.26e+81) tmp = t_0; elseif (d3 <= -2.7e-258) tmp = d1 * (d2 - d1); elseif (d3 <= 9.5e+98) tmp = d1 * (d4 + d2); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d3, -1.26e+81], t$95$0, If[LessEqual[d3, -2.7e-258], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 9.5e+98], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d3 \leq -1.26 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -2.7 \cdot 10^{-258}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 9.5 \cdot 10^{+98}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -1.25999999999999996e81 or 9.5000000000000001e98 < d3 Initial program 87.2%
+-commutative87.2%
*-commutative87.2%
distribute-lft-out--90.4%
distribute-lft-out93.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 76.6%
mul-1-neg76.6%
distribute-rgt-neg-out76.6%
Simplified76.6%
if -1.25999999999999996e81 < d3 < -2.69999999999999996e-258Initial program 90.5%
+-commutative90.5%
*-commutative90.5%
distribute-lft-out--90.5%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.4%
Taylor expanded in d4 around 0 69.0%
if -2.69999999999999996e-258 < d3 < 9.5000000000000001e98Initial program 93.1%
+-commutative93.1%
*-commutative93.1%
distribute-lft-out--93.1%
distribute-lft-out94.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.0%
Taylor expanded in d1 around 0 72.3%
Final simplification72.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -3.5e+49) (not (<= d3 3.8e+71))) (* d1 (- (+ d4 d2) d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.5e+49) || !(d3 <= 3.8e+71)) {
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 <= (-3.5d+49)) .or. (.not. (d3 <= 3.8d+71))) 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 <= -3.5e+49) || !(d3 <= 3.8e+71)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3.5e+49) or not (d3 <= 3.8e+71): tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3.5e+49) || !(d3 <= 3.8e+71)) 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 <= -3.5e+49) || ~((d3 <= 3.8e+71))) 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, -3.5e+49], N[Not[LessEqual[d3, 3.8e+71]], $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 -3.5 \cdot 10^{+49} \lor \neg \left(d3 \leq 3.8 \cdot 10^{+71}\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 < -3.49999999999999975e49 or 3.8000000000000001e71 < d3 Initial program 88.8%
+-commutative88.8%
*-commutative88.8%
distribute-lft-out--91.6%
distribute-lft-out94.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.3%
if -3.49999999999999975e49 < d3 < 3.8000000000000001e71Initial program 91.2%
+-commutative91.2%
*-commutative91.2%
distribute-lft-out--91.2%
distribute-lft-out92.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.7%
Final simplification97.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.5e+58) (not (<= d3 2.3e+86))) (* d1 (- d2 d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.5e+58) || !(d3 <= 2.3e+86)) {
tmp = d1 * (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.5d+58)) .or. (.not. (d3 <= 2.3d+86))) then
tmp = d1 * (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.5e+58) || !(d3 <= 2.3e+86)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.5e+58) or not (d3 <= 2.3e+86): tmp = d1 * (d2 - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.5e+58) || !(d3 <= 2.3e+86)) tmp = Float64(d1 * Float64(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.5e+58) || ~((d3 <= 2.3e+86))) tmp = d1 * (d2 - d3); else tmp = d1 * ((d4 + d2) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.5e+58], N[Not[LessEqual[d3, 2.3e+86]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.5 \cdot 10^{+58} \lor \neg \left(d3 \leq 2.3 \cdot 10^{+86}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -1.5000000000000001e58 or 2.2999999999999999e86 < d3 Initial program 88.2%
+-commutative88.2%
*-commutative88.2%
distribute-lft-out--91.1%
distribute-lft-out94.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.0%
Taylor expanded in d4 around 0 84.6%
if -1.5000000000000001e58 < d3 < 2.2999999999999999e86Initial program 91.5%
+-commutative91.5%
*-commutative91.5%
distribute-lft-out--91.5%
distribute-lft-out92.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.2%
Final simplification92.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.2e+81) (not (<= d3 5.5e+98))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.2e+81) || !(d3 <= 5.5e+98)) {
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.2d+81)) .or. (.not. (d3 <= 5.5d+98))) 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.2e+81) || !(d3 <= 5.5e+98)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.2e+81) or not (d3 <= 5.5e+98): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.2e+81) || !(d3 <= 5.5e+98)) 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.2e+81) || ~((d3 <= 5.5e+98))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.2e+81], N[Not[LessEqual[d3, 5.5e+98]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.2 \cdot 10^{+81} \lor \neg \left(d3 \leq 5.5 \cdot 10^{+98}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -1.19999999999999995e81 or 5.49999999999999946e98 < d3 Initial program 87.2%
+-commutative87.2%
*-commutative87.2%
distribute-lft-out--90.4%
distribute-lft-out93.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 76.6%
mul-1-neg76.6%
distribute-rgt-neg-out76.6%
Simplified76.6%
if -1.19999999999999995e81 < d3 < 5.49999999999999946e98Initial program 91.9%
+-commutative91.9%
*-commutative91.9%
distribute-lft-out--91.9%
distribute-lft-out93.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.7%
Taylor expanded in d1 around 0 68.6%
Final simplification71.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.15e+100) (* d1 d2) (if (<= d2 8.4e-221) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.15e+100) {
tmp = d1 * d2;
} else if (d2 <= 8.4e-221) {
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 (d2 <= (-1.15d+100)) then
tmp = d1 * d2
else if (d2 <= 8.4d-221) 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 (d2 <= -1.15e+100) {
tmp = d1 * d2;
} else if (d2 <= 8.4e-221) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.15e+100: tmp = d1 * d2 elif d2 <= 8.4e-221: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.15e+100) tmp = Float64(d1 * d2); elseif (d2 <= 8.4e-221) 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 (d2 <= -1.15e+100) tmp = d1 * d2; elseif (d2 <= 8.4e-221) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.15e+100], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 8.4e-221], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.15 \cdot 10^{+100}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 8.4 \cdot 10^{-221}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.14999999999999995e100Initial program 90.7%
+-commutative90.7%
*-commutative90.7%
distribute-lft-out--90.7%
distribute-lft-out93.0%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d2 around inf 71.0%
if -1.14999999999999995e100 < d2 < 8.4000000000000001e-221Initial program 91.3%
+-commutative91.3%
*-commutative91.3%
distribute-lft-out--91.3%
distribute-lft-out93.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 37.6%
neg-mul-137.6%
Simplified37.6%
if 8.4000000000000001e-221 < d2 Initial program 89.2%
+-commutative89.2%
*-commutative89.2%
distribute-lft-out--91.7%
distribute-lft-out93.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 25.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.7e+26) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e+26) {
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.7d+26)) 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.7e+26) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.7e+26: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.7e+26) 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.7e+26) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.7e+26], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.7 \cdot 10^{+26}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.7e26Initial program 91.5%
+-commutative91.5%
*-commutative91.5%
distribute-lft-out--91.5%
distribute-lft-out93.1%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d2 around inf 58.1%
if -2.7e26 < d2 Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--91.3%
distribute-lft-out93.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 28.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 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.4%
distribute-lft-out93.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.3%
(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 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.4%
distribute-lft-out93.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 32.5%
neg-mul-132.5%
Simplified32.5%
neg-sub032.5%
sub-neg32.5%
add-sqr-sqrt15.4%
sqrt-unprod19.4%
sqr-neg19.4%
sqrt-prod4.0%
add-sqr-sqrt6.0%
Applied egg-rr6.0%
+-lft-identity6.0%
Simplified6.0%
(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 2024188
(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)))