
(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 d3) d1) d2)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d4 - d3) - 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 * (((d4 - d3) - d1) + d2)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d4 - d3) - d1) + d2);
}
def code(d1, d2, d3, d4): return d1 * (((d4 - d3) - d1) + d2)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d4 - d3) - d1) + d2)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d4 - d3) - d1) + d2); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] + d2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d4 - d3\right) - d1\right) + d2\right)
\end{array}
Initial program 87.1%
associate--l+87.1%
sub-neg87.1%
associate-+l+87.1%
+-commutative87.1%
--rgt-identity87.1%
associate--r-87.1%
associate-+r-87.1%
+-commutative87.1%
*-commutative87.1%
sub-neg87.1%
distribute-lft-out--87.5%
distribute-lft-out--93.3%
neg-sub093.3%
distribute-rgt-neg-out93.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))) (t_1 (* d1 (- d2 d3))))
(if (<= d4 1.32e-205)
t_1
(if (<= d4 6.7e-189)
t_0
(if (<= d4 1.15e-62)
t_1
(if (<= d4 11600000.0)
t_0
(if (<= d4 9e+30) t_1 (* d1 (- d4 d3)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= 1.32e-205) {
tmp = t_1;
} else if (d4 <= 6.7e-189) {
tmp = t_0;
} else if (d4 <= 1.15e-62) {
tmp = t_1;
} else if (d4 <= 11600000.0) {
tmp = t_0;
} else if (d4 <= 9e+30) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = d1 * -d1
t_1 = d1 * (d2 - d3)
if (d4 <= 1.32d-205) then
tmp = t_1
else if (d4 <= 6.7d-189) then
tmp = t_0
else if (d4 <= 1.15d-62) then
tmp = t_1
else if (d4 <= 11600000.0d0) then
tmp = t_0
else if (d4 <= 9d+30) then
tmp = t_1
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 * -d1;
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= 1.32e-205) {
tmp = t_1;
} else if (d4 <= 6.7e-189) {
tmp = t_0;
} else if (d4 <= 1.15e-62) {
tmp = t_1;
} else if (d4 <= 11600000.0) {
tmp = t_0;
} else if (d4 <= 9e+30) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 t_1 = d1 * (d2 - d3) tmp = 0 if d4 <= 1.32e-205: tmp = t_1 elif d4 <= 6.7e-189: tmp = t_0 elif d4 <= 1.15e-62: tmp = t_1 elif d4 <= 11600000.0: tmp = t_0 elif d4 <= 9e+30: tmp = t_1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) t_1 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 1.32e-205) tmp = t_1; elseif (d4 <= 6.7e-189) tmp = t_0; elseif (d4 <= 1.15e-62) tmp = t_1; elseif (d4 <= 11600000.0) tmp = t_0; elseif (d4 <= 9e+30) tmp = t_1; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; t_1 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 1.32e-205) tmp = t_1; elseif (d4 <= 6.7e-189) tmp = t_0; elseif (d4 <= 1.15e-62) tmp = t_1; elseif (d4 <= 11600000.0) tmp = t_0; elseif (d4 <= 9e+30) tmp = t_1; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 1.32e-205], t$95$1, If[LessEqual[d4, 6.7e-189], t$95$0, If[LessEqual[d4, 1.15e-62], t$95$1, If[LessEqual[d4, 11600000.0], t$95$0, If[LessEqual[d4, 9e+30], t$95$1, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 1.32 \cdot 10^{-205}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 6.7 \cdot 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.15 \cdot 10^{-62}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 11600000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 9 \cdot 10^{+30}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.31999999999999992e-205 or 6.7000000000000002e-189 < d4 < 1.15e-62 or 1.16e7 < d4 < 8.9999999999999999e30Initial program 88.1%
associate--l+88.1%
sub-neg88.1%
associate-+l+88.1%
+-commutative88.1%
--rgt-identity88.1%
associate--r-88.1%
associate-+r-88.1%
+-commutative88.1%
*-commutative88.1%
sub-neg88.1%
distribute-lft-out--88.1%
distribute-lft-out--93.5%
neg-sub093.5%
distribute-rgt-neg-out93.5%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 61.0%
neg-mul-161.0%
Simplified61.0%
Taylor expanded in d1 around 0 61.0%
if 1.31999999999999992e-205 < d4 < 6.7000000000000002e-189 or 1.15e-62 < d4 < 1.16e7Initial program 82.6%
associate--l+82.6%
sub-neg82.6%
associate-+l+82.6%
+-commutative82.6%
--rgt-identity82.6%
associate--r-82.6%
associate-+r-82.6%
+-commutative82.6%
*-commutative82.6%
sub-neg82.6%
distribute-lft-out--82.6%
distribute-lft-out--95.7%
neg-sub095.7%
distribute-rgt-neg-out95.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 66.7%
unpow266.7%
mul-1-neg66.7%
distribute-rgt-neg-out66.7%
Simplified66.7%
if 8.9999999999999999e30 < d4 Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--87.5%
distribute-lft-out--92.2%
neg-sub092.2%
distribute-rgt-neg-out92.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 88.5%
associate--r+88.5%
Simplified88.5%
Taylor expanded in d1 around 0 79.5%
Final simplification66.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d2 -3.7e+134)
(* d1 d2)
(if (<= d2 -2.45e+31)
t_0
(if (<= d2 -7e-89)
(* d1 (- d3))
(if (<= d2 -3.9e-293) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d2 <= -3.7e+134) {
tmp = d1 * d2;
} else if (d2 <= -2.45e+31) {
tmp = t_0;
} else if (d2 <= -7e-89) {
tmp = d1 * -d3;
} else if (d2 <= -3.9e-293) {
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 * -d1
if (d2 <= (-3.7d+134)) then
tmp = d1 * d2
else if (d2 <= (-2.45d+31)) then
tmp = t_0
else if (d2 <= (-7d-89)) then
tmp = d1 * -d3
else if (d2 <= (-3.9d-293)) 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 * -d1;
double tmp;
if (d2 <= -3.7e+134) {
tmp = d1 * d2;
} else if (d2 <= -2.45e+31) {
tmp = t_0;
} else if (d2 <= -7e-89) {
tmp = d1 * -d3;
} else if (d2 <= -3.9e-293) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d2 <= -3.7e+134: tmp = d1 * d2 elif d2 <= -2.45e+31: tmp = t_0 elif d2 <= -7e-89: tmp = d1 * -d3 elif d2 <= -3.9e-293: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d2 <= -3.7e+134) tmp = Float64(d1 * d2); elseif (d2 <= -2.45e+31) tmp = t_0; elseif (d2 <= -7e-89) tmp = Float64(d1 * Float64(-d3)); elseif (d2 <= -3.9e-293) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; tmp = 0.0; if (d2 <= -3.7e+134) tmp = d1 * d2; elseif (d2 <= -2.45e+31) tmp = t_0; elseif (d2 <= -7e-89) tmp = d1 * -d3; elseif (d2 <= -3.9e-293) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, If[LessEqual[d2, -3.7e+134], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -2.45e+31], t$95$0, If[LessEqual[d2, -7e-89], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d2, -3.9e-293], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d2 \leq -3.7 \cdot 10^{+134}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.45 \cdot 10^{+31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -7 \cdot 10^{-89}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d2 \leq -3.9 \cdot 10^{-293}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -3.70000000000000013e134Initial program 75.0%
associate--l+75.0%
sub-neg75.0%
associate-+l+75.0%
+-commutative75.0%
--rgt-identity75.0%
associate--r-75.0%
associate-+r-75.0%
+-commutative75.0%
*-commutative75.0%
sub-neg75.0%
distribute-lft-out--75.0%
distribute-lft-out--79.5%
neg-sub079.5%
distribute-rgt-neg-out79.5%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 61.2%
if -3.70000000000000013e134 < d2 < -2.44999999999999998e31 or -6.9999999999999994e-89 < d2 < -3.9e-293Initial program 83.6%
associate--l+83.6%
sub-neg83.6%
associate-+l+83.6%
+-commutative83.6%
--rgt-identity83.6%
associate--r-83.6%
associate-+r-83.6%
+-commutative83.6%
*-commutative83.6%
sub-neg83.6%
distribute-lft-out--85.4%
distribute-lft-out--96.3%
neg-sub096.3%
distribute-rgt-neg-out96.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 48.4%
unpow248.4%
mul-1-neg48.4%
distribute-rgt-neg-out48.4%
Simplified48.4%
if -2.44999999999999998e31 < d2 < -6.9999999999999994e-89Initial program 96.6%
associate--l+96.6%
sub-neg96.6%
associate-+l+96.6%
+-commutative96.6%
--rgt-identity96.6%
associate--r-96.6%
associate-+r-96.6%
+-commutative96.6%
*-commutative96.6%
sub-neg96.6%
distribute-lft-out--96.6%
distribute-lft-out--100.0%
neg-sub0100.0%
distribute-rgt-neg-out100.0%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around inf 28.0%
mul-1-neg28.0%
distribute-rgt-neg-out28.0%
Simplified28.0%
if -3.9e-293 < d2 Initial program 90.6%
associate--l+90.6%
sub-neg90.6%
associate-+l+90.6%
+-commutative90.6%
--rgt-identity90.6%
associate--r-90.6%
associate-+r-90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
distribute-lft-out--90.6%
distribute-lft-out--95.3%
neg-sub095.3%
distribute-rgt-neg-out95.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.3%
Final simplification41.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d2 -3.5e+132) (and (not (<= d2 -3.9e+84)) (<= d2 -2.4e-15))) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d2 <= -3.5e+132) || (!(d2 <= -3.9e+84) && (d2 <= -2.4e-15))) {
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 <= (-3.5d+132)) .or. (.not. (d2 <= (-3.9d+84))) .and. (d2 <= (-2.4d-15))) 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 <= -3.5e+132) || (!(d2 <= -3.9e+84) && (d2 <= -2.4e-15))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d2 <= -3.5e+132) or (not (d2 <= -3.9e+84) and (d2 <= -2.4e-15)): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d2 <= -3.5e+132) || (!(d2 <= -3.9e+84) && (d2 <= -2.4e-15))) 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 <= -3.5e+132) || (~((d2 <= -3.9e+84)) && (d2 <= -2.4e-15))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d2, -3.5e+132], And[N[Not[LessEqual[d2, -3.9e+84]], $MachinePrecision], LessEqual[d2, -2.4e-15]]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.5 \cdot 10^{+132} \lor \neg \left(d2 \leq -3.9 \cdot 10^{+84}\right) \land d2 \leq -2.4 \cdot 10^{-15}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -3.5000000000000002e132 or -3.90000000000000016e84 < d2 < -2.39999999999999995e-15Initial program 80.3%
associate--l+80.3%
sub-neg80.3%
associate-+l+80.3%
+-commutative80.3%
--rgt-identity80.3%
associate--r-80.3%
associate-+r-80.3%
+-commutative80.3%
*-commutative80.3%
sub-neg80.3%
distribute-lft-out--80.3%
distribute-lft-out--85.2%
neg-sub085.2%
distribute-rgt-neg-out85.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 65.7%
neg-mul-165.7%
Simplified65.7%
Taylor expanded in d1 around 0 65.7%
if -3.5000000000000002e132 < d2 < -3.90000000000000016e84 or -2.39999999999999995e-15 < d2 Initial program 89.2%
associate--l+89.2%
sub-neg89.2%
associate-+l+89.2%
+-commutative89.2%
--rgt-identity89.2%
associate--r-89.2%
associate-+r-89.2%
+-commutative89.2%
*-commutative89.2%
sub-neg89.2%
distribute-lft-out--89.7%
distribute-lft-out--95.9%
neg-sub095.9%
distribute-rgt-neg-out95.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.4%
associate--r+82.4%
Simplified82.4%
Taylor expanded in d3 around 0 59.5%
Final simplification60.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d4 -1.15e-270)
t_0
(if (<= d4 5.6e-208)
(* d1 (- d2 d3))
(if (<= d4 2.95e+29) t_0 (* d1 (- d4 d3)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= -1.15e-270) {
tmp = t_0;
} else if (d4 <= 5.6e-208) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 2.95e+29) {
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 - d1)
if (d4 <= (-1.15d-270)) then
tmp = t_0
else if (d4 <= 5.6d-208) then
tmp = d1 * (d2 - d3)
else if (d4 <= 2.95d+29) 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 - d1);
double tmp;
if (d4 <= -1.15e-270) {
tmp = t_0;
} else if (d4 <= 5.6e-208) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 2.95e+29) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= -1.15e-270: tmp = t_0 elif d4 <= 5.6e-208: tmp = d1 * (d2 - d3) elif d4 <= 2.95e+29: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= -1.15e-270) tmp = t_0; elseif (d4 <= 5.6e-208) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 2.95e+29) 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 - d1); tmp = 0.0; if (d4 <= -1.15e-270) tmp = t_0; elseif (d4 <= 5.6e-208) tmp = d1 * (d2 - d3); elseif (d4 <= 2.95e+29) 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 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -1.15e-270], t$95$0, If[LessEqual[d4, 5.6e-208], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 2.95e+29], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq -1.15 \cdot 10^{-270}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.6 \cdot 10^{-208}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 2.95 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.1500000000000001e-270 or 5.60000000000000003e-208 < d4 < 2.9499999999999999e29Initial program 86.5%
associate--l+86.5%
sub-neg86.5%
associate-+l+86.5%
+-commutative86.5%
--rgt-identity86.5%
associate--r-86.5%
associate-+r-86.5%
+-commutative86.5%
*-commutative86.5%
sub-neg86.5%
distribute-lft-out--86.5%
distribute-lft-out--93.2%
neg-sub093.2%
distribute-rgt-neg-out93.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 62.4%
neg-mul-162.4%
Simplified62.4%
if -1.1500000000000001e-270 < d4 < 5.60000000000000003e-208Initial program 93.1%
associate--l+93.1%
sub-neg93.1%
associate-+l+93.1%
+-commutative93.1%
--rgt-identity93.1%
associate--r-93.1%
associate-+r-93.1%
+-commutative93.1%
*-commutative93.1%
sub-neg93.1%
distribute-lft-out--93.1%
distribute-lft-out--96.6%
neg-sub096.6%
distribute-rgt-neg-out96.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 87.1%
neg-mul-187.1%
Simplified87.1%
Taylor expanded in d1 around 0 87.1%
if 2.9499999999999999e29 < d4 Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--87.5%
distribute-lft-out--92.2%
neg-sub092.2%
distribute-rgt-neg-out92.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 88.5%
associate--r+88.5%
Simplified88.5%
Taylor expanded in d1 around 0 79.5%
Final simplification69.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d4 2.15e-302)
t_0
(if (<= d4 6.2e-145)
(* d1 (- (- d1) d3))
(if (<= d4 1.32e+32) t_0 (* d1 (- d4 d3)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= 2.15e-302) {
tmp = t_0;
} else if (d4 <= 6.2e-145) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 1.32e+32) {
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 - d1)
if (d4 <= 2.15d-302) then
tmp = t_0
else if (d4 <= 6.2d-145) then
tmp = d1 * (-d1 - d3)
else if (d4 <= 1.32d+32) 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 - d1);
double tmp;
if (d4 <= 2.15e-302) {
tmp = t_0;
} else if (d4 <= 6.2e-145) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 1.32e+32) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= 2.15e-302: tmp = t_0 elif d4 <= 6.2e-145: tmp = d1 * (-d1 - d3) elif d4 <= 1.32e+32: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= 2.15e-302) tmp = t_0; elseif (d4 <= 6.2e-145) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d4 <= 1.32e+32) 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 - d1); tmp = 0.0; if (d4 <= 2.15e-302) tmp = t_0; elseif (d4 <= 6.2e-145) tmp = d1 * (-d1 - d3); elseif (d4 <= 1.32e+32) 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 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 2.15e-302], t$95$0, If[LessEqual[d4, 6.2e-145], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.32e+32], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq 2.15 \cdot 10^{-302}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 6.2 \cdot 10^{-145}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d4 \leq 1.32 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 2.1500000000000001e-302 or 6.20000000000000001e-145 < d4 < 1.31999999999999997e32Initial program 85.5%
associate--l+85.5%
sub-neg85.5%
associate-+l+85.5%
+-commutative85.5%
--rgt-identity85.5%
associate--r-85.5%
associate-+r-85.5%
+-commutative85.5%
*-commutative85.5%
sub-neg85.5%
distribute-lft-out--85.5%
distribute-lft-out--92.4%
neg-sub092.4%
distribute-rgt-neg-out92.4%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 63.1%
neg-mul-163.1%
Simplified63.1%
if 2.1500000000000001e-302 < d4 < 6.20000000000000001e-145Initial program 97.0%
associate--l+97.0%
sub-neg97.0%
associate-+l+97.0%
+-commutative97.0%
--rgt-identity97.0%
associate--r-97.0%
associate-+r-97.0%
+-commutative97.0%
*-commutative97.0%
sub-neg97.0%
distribute-lft-out--97.0%
distribute-lft-out--100.0%
neg-sub0100.0%
distribute-rgt-neg-out100.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 71.5%
associate--r+71.5%
Simplified71.5%
Taylor expanded in d4 around 0 71.5%
mul-1-neg71.5%
*-commutative71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
if 1.31999999999999997e32 < d4 Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--87.5%
distribute-lft-out--92.2%
neg-sub092.2%
distribute-rgt-neg-out92.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 88.5%
associate--r+88.5%
Simplified88.5%
Taylor expanded in d1 around 0 79.5%
Final simplification68.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.35e+76) (not (<= d1 1.35e+123))) (* d1 (- d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.35e+76) || !(d1 <= 1.35e+123)) {
tmp = d1 * -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 ((d1 <= (-2.35d+76)) .or. (.not. (d1 <= 1.35d+123))) then
tmp = d1 * -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 ((d1 <= -2.35e+76) || !(d1 <= 1.35e+123)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.35e+76) or not (d1 <= 1.35e+123): tmp = d1 * -d1 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.35e+76) || !(d1 <= 1.35e+123)) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -2.35e+76) || ~((d1 <= 1.35e+123))) tmp = d1 * -d1; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.35e+76], N[Not[LessEqual[d1, 1.35e+123]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.35 \cdot 10^{+76} \lor \neg \left(d1 \leq 1.35 \cdot 10^{+123}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d1 < -2.3500000000000002e76 or 1.35000000000000007e123 < d1 Initial program 62.5%
associate--l+62.5%
sub-neg62.5%
associate-+l+62.5%
+-commutative62.5%
--rgt-identity62.5%
associate--r-62.5%
associate-+r-62.5%
+-commutative62.5%
*-commutative62.5%
sub-neg62.5%
distribute-lft-out--63.6%
distribute-lft-out--80.7%
neg-sub080.7%
distribute-rgt-neg-out80.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 75.7%
unpow275.7%
mul-1-neg75.7%
distribute-rgt-neg-out75.7%
Simplified75.7%
if -2.3500000000000002e76 < d1 < 1.35000000000000007e123Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
--rgt-identity100.0%
associate--r-100.0%
associate-+r-100.0%
+-commutative100.0%
*-commutative100.0%
sub-neg100.0%
distribute-lft-out--100.0%
distribute-lft-out--100.0%
neg-sub0100.0%
distribute-rgt-neg-out100.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 66.5%
Final simplification69.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.4e+109) (not (<= d3 1.85e+62))) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.4e+109) || !(d3 <= 1.85e+62)) {
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 ((d3 <= (-2.4d+109)) .or. (.not. (d3 <= 1.85d+62))) 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 ((d3 <= -2.4e+109) || !(d3 <= 1.85e+62)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.4e+109) or not (d3 <= 1.85e+62): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.4e+109) || !(d3 <= 1.85e+62)) 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 ((d3 <= -2.4e+109) || ~((d3 <= 1.85e+62))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.4e+109], N[Not[LessEqual[d3, 1.85e+62]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.4 \cdot 10^{+109} \lor \neg \left(d3 \leq 1.85 \cdot 10^{+62}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -2.39999999999999987e109 or 1.85000000000000007e62 < d3 Initial program 80.5%
associate--l+80.5%
sub-neg80.5%
associate-+l+80.5%
+-commutative80.5%
--rgt-identity80.5%
associate--r-80.5%
associate-+r-80.5%
+-commutative80.5%
*-commutative80.5%
sub-neg80.5%
distribute-lft-out--81.7%
distribute-lft-out--92.7%
neg-sub092.7%
distribute-rgt-neg-out92.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 76.7%
neg-mul-176.7%
Simplified76.7%
Taylor expanded in d1 around 0 76.7%
if -2.39999999999999987e109 < d3 < 1.85000000000000007e62Initial program 90.2%
associate--l+90.2%
sub-neg90.2%
associate-+l+90.2%
+-commutative90.2%
--rgt-identity90.2%
associate--r-90.2%
associate-+r-90.2%
+-commutative90.2%
*-commutative90.2%
sub-neg90.2%
distribute-lft-out--90.2%
distribute-lft-out--93.6%
neg-sub093.6%
distribute-rgt-neg-out93.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 68.9%
Final simplification71.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.45e+175) (* d1 (- d2 d1)) (* d1 (- (- d4 d1) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+175) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * ((d4 - 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 (d2 <= (-1.45d+175)) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * ((d4 - d1) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+175) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.45e+175: tmp = d1 * (d2 - d1) else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.45e+175) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.45e+175) tmp = d1 * (d2 - d1); else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.45e+175], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+175}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d2 < -1.45e175Initial program 73.1%
associate--l+73.1%
sub-neg73.1%
associate-+l+73.1%
+-commutative73.1%
--rgt-identity73.1%
associate--r-73.1%
associate-+r-73.1%
+-commutative73.1%
*-commutative73.1%
sub-neg73.1%
distribute-lft-out--73.1%
distribute-lft-out--76.9%
neg-sub076.9%
distribute-rgt-neg-out76.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 88.7%
neg-mul-188.7%
Simplified88.7%
if -1.45e175 < d2 Initial program 88.7%
associate--l+88.7%
sub-neg88.7%
associate-+l+88.7%
+-commutative88.7%
--rgt-identity88.7%
associate--r-88.7%
associate-+r-88.7%
+-commutative88.7%
*-commutative88.7%
sub-neg88.7%
distribute-lft-out--89.1%
distribute-lft-out--95.2%
neg-sub095.2%
distribute-rgt-neg-out95.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 81.8%
associate--r+81.8%
Simplified81.8%
Final simplification82.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.7e+134) (* d1 d2) (if (<= d2 -7.5e-295) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.7e+134) {
tmp = d1 * d2;
} else if (d2 <= -7.5e-295) {
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 <= (-3.7d+134)) then
tmp = d1 * d2
else if (d2 <= (-7.5d-295)) 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 <= -3.7e+134) {
tmp = d1 * d2;
} else if (d2 <= -7.5e-295) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.7e+134: tmp = d1 * d2 elif d2 <= -7.5e-295: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.7e+134) tmp = Float64(d1 * d2); elseif (d2 <= -7.5e-295) 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 <= -3.7e+134) tmp = d1 * d2; elseif (d2 <= -7.5e-295) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.7e+134], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -7.5e-295], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.7 \cdot 10^{+134}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -7.5 \cdot 10^{-295}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -3.70000000000000013e134Initial program 75.0%
associate--l+75.0%
sub-neg75.0%
associate-+l+75.0%
+-commutative75.0%
--rgt-identity75.0%
associate--r-75.0%
associate-+r-75.0%
+-commutative75.0%
*-commutative75.0%
sub-neg75.0%
distribute-lft-out--75.0%
distribute-lft-out--79.5%
neg-sub079.5%
distribute-rgt-neg-out79.5%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 61.2%
if -3.70000000000000013e134 < d2 < -7.4999999999999997e-295Initial program 88.1%
associate--l+88.1%
sub-neg88.1%
associate-+l+88.1%
+-commutative88.1%
--rgt-identity88.1%
associate--r-88.1%
associate-+r-88.1%
+-commutative88.1%
*-commutative88.1%
sub-neg88.1%
distribute-lft-out--89.3%
distribute-lft-out--97.6%
neg-sub097.6%
distribute-rgt-neg-out97.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 44.6%
unpow244.6%
mul-1-neg44.6%
distribute-rgt-neg-out44.6%
Simplified44.6%
if -7.4999999999999997e-295 < d2 Initial program 90.6%
associate--l+90.6%
sub-neg90.6%
associate-+l+90.6%
+-commutative90.6%
--rgt-identity90.6%
associate--r-90.6%
associate-+r-90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
distribute-lft-out--90.6%
distribute-lft-out--95.3%
neg-sub095.3%
distribute-rgt-neg-out95.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.3%
Final simplification42.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 9.2e+30) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 9.2e+30) {
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 <= 9.2d+30) 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 <= 9.2e+30) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 9.2e+30: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 9.2e+30) 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 <= 9.2e+30) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 9.2e+30], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 9.2 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 9.2e30Initial program 87.5%
associate--l+87.5%
sub-neg87.5%
associate-+l+87.5%
+-commutative87.5%
--rgt-identity87.5%
associate--r-87.5%
associate-+r-87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
distribute-lft-out--87.5%
distribute-lft-out--93.7%
neg-sub093.7%
distribute-rgt-neg-out93.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 38.1%
if 9.2e30 < d4 Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--87.5%
distribute-lft-out--92.2%
neg-sub092.2%
distribute-rgt-neg-out92.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 61.4%
Final simplification43.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.1%
associate--l+87.1%
sub-neg87.1%
associate-+l+87.1%
+-commutative87.1%
--rgt-identity87.1%
associate--r-87.1%
associate-+r-87.1%
+-commutative87.1%
*-commutative87.1%
sub-neg87.1%
distribute-lft-out--87.5%
distribute-lft-out--93.3%
neg-sub093.3%
distribute-rgt-neg-out93.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.5%
Final simplification32.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 2023271
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:herbie-target
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))