
(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 82.8%
associate--l+82.8%
sub-neg82.8%
associate-+l+82.8%
+-commutative82.8%
--rgt-identity82.8%
associate--r-82.8%
associate-+r-82.8%
+-commutative82.8%
*-commutative82.8%
sub-neg82.8%
distribute-lft-out--83.6%
distribute-lft-out--92.6%
neg-sub092.6%
distribute-rgt-neg-out92.6%
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 (- d2 d3))) (t_1 (* d1 (- d1))) (t_2 (* d1 (+ d4 d2))))
(if (<= d1 -1.25e+122)
t_1
(if (<= d1 -9.2e-137)
t_2
(if (<= d1 -1.45e-281)
t_0
(if (<= d1 4e-103) t_2 (if (<= d1 1.4e+96) t_0 t_1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double t_1 = d1 * -d1;
double t_2 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.25e+122) {
tmp = t_1;
} else if (d1 <= -9.2e-137) {
tmp = t_2;
} else if (d1 <= -1.45e-281) {
tmp = t_0;
} else if (d1 <= 4e-103) {
tmp = t_2;
} else if (d1 <= 1.4e+96) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = d1 * (d2 - d3)
t_1 = d1 * -d1
t_2 = d1 * (d4 + d2)
if (d1 <= (-1.25d+122)) then
tmp = t_1
else if (d1 <= (-9.2d-137)) then
tmp = t_2
else if (d1 <= (-1.45d-281)) then
tmp = t_0
else if (d1 <= 4d-103) then
tmp = t_2
else if (d1 <= 1.4d+96) then
tmp = t_0
else
tmp = t_1
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 t_1 = d1 * -d1;
double t_2 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.25e+122) {
tmp = t_1;
} else if (d1 <= -9.2e-137) {
tmp = t_2;
} else if (d1 <= -1.45e-281) {
tmp = t_0;
} else if (d1 <= 4e-103) {
tmp = t_2;
} else if (d1 <= 1.4e+96) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) t_1 = d1 * -d1 t_2 = d1 * (d4 + d2) tmp = 0 if d1 <= -1.25e+122: tmp = t_1 elif d1 <= -9.2e-137: tmp = t_2 elif d1 <= -1.45e-281: tmp = t_0 elif d1 <= 4e-103: tmp = t_2 elif d1 <= 1.4e+96: tmp = t_0 else: tmp = t_1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) t_1 = Float64(d1 * Float64(-d1)) t_2 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d1 <= -1.25e+122) tmp = t_1; elseif (d1 <= -9.2e-137) tmp = t_2; elseif (d1 <= -1.45e-281) tmp = t_0; elseif (d1 <= 4e-103) tmp = t_2; elseif (d1 <= 1.4e+96) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); t_1 = d1 * -d1; t_2 = d1 * (d4 + d2); tmp = 0.0; if (d1 <= -1.25e+122) tmp = t_1; elseif (d1 <= -9.2e-137) tmp = t_2; elseif (d1 <= -1.45e-281) tmp = t_0; elseif (d1 <= 4e-103) tmp = t_2; elseif (d1 <= 1.4e+96) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -1.25e+122], t$95$1, If[LessEqual[d1, -9.2e-137], t$95$2, If[LessEqual[d1, -1.45e-281], t$95$0, If[LessEqual[d1, 4e-103], t$95$2, If[LessEqual[d1, 1.4e+96], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(-d1\right)\\
t_2 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d1 \leq -1.25 \cdot 10^{+122}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq -9.2 \cdot 10^{-137}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq -1.45 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 4 \cdot 10^{-103}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq 1.4 \cdot 10^{+96}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d1 < -1.24999999999999997e122 or 1.4e96 < d1 Initial program 57.1%
associate--l+57.1%
sub-neg57.1%
associate-+l+57.1%
+-commutative57.1%
--rgt-identity57.1%
associate--r-57.1%
associate-+r-57.1%
+-commutative57.1%
*-commutative57.1%
sub-neg57.1%
distribute-lft-out--58.2%
distribute-lft-out--81.6%
neg-sub081.6%
distribute-rgt-neg-out81.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 76.1%
unpow276.1%
mul-1-neg76.1%
distribute-rgt-neg-out76.1%
Simplified76.1%
if -1.24999999999999997e122 < d1 < -9.20000000000000032e-137 or -1.44999999999999995e-281 < d1 < 3.99999999999999983e-103Initial program 97.9%
associate--l+97.9%
sub-neg97.9%
associate-+l+97.9%
+-commutative97.9%
--rgt-identity97.9%
associate--r-97.9%
associate-+r-97.9%
+-commutative97.9%
*-commutative97.9%
sub-neg97.9%
distribute-lft-out--98.9%
distribute-lft-out--98.9%
neg-sub098.9%
distribute-rgt-neg-out98.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.6%
Taylor expanded in d3 around 0 71.8%
+-commutative71.8%
Simplified71.8%
if -9.20000000000000032e-137 < d1 < -1.44999999999999995e-281 or 3.99999999999999983e-103 < d1 < 1.4e96Initial 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 d1 around 0 92.3%
Taylor expanded in d4 around 0 66.7%
Final simplification72.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (- d1) d3))))
(if (<= d2 -4.5e+68)
(* d1 (- d2 d3))
(if (<= d2 -2.15e-275)
t_0
(if (<= d2 8.5e-223)
(* d1 (- d4 d3))
(if (<= d2 1e-158) t_0 (* d1 (- d4 d1))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (-d1 - d3);
double tmp;
if (d2 <= -4.5e+68) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.15e-275) {
tmp = t_0;
} else if (d2 <= 8.5e-223) {
tmp = d1 * (d4 - d3);
} else if (d2 <= 1e-158) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (-d1 - d3)
if (d2 <= (-4.5d+68)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-2.15d-275)) then
tmp = t_0
else if (d2 <= 8.5d-223) then
tmp = d1 * (d4 - d3)
else if (d2 <= 1d-158) then
tmp = t_0
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (-d1 - d3);
double tmp;
if (d2 <= -4.5e+68) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.15e-275) {
tmp = t_0;
} else if (d2 <= 8.5e-223) {
tmp = d1 * (d4 - d3);
} else if (d2 <= 1e-158) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (-d1 - d3) tmp = 0 if d2 <= -4.5e+68: tmp = d1 * (d2 - d3) elif d2 <= -2.15e-275: tmp = t_0 elif d2 <= 8.5e-223: tmp = d1 * (d4 - d3) elif d2 <= 1e-158: tmp = t_0 else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(-d1) - d3)) tmp = 0.0 if (d2 <= -4.5e+68) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -2.15e-275) tmp = t_0; elseif (d2 <= 8.5e-223) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d2 <= 1e-158) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (-d1 - d3); tmp = 0.0; if (d2 <= -4.5e+68) tmp = d1 * (d2 - d3); elseif (d2 <= -2.15e-275) tmp = t_0; elseif (d2 <= 8.5e-223) tmp = d1 * (d4 - d3); elseif (d2 <= 1e-158) tmp = t_0; else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d2, -4.5e+68], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -2.15e-275], t$95$0, If[LessEqual[d2, 8.5e-223], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 1e-158], t$95$0, N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{if}\;d2 \leq -4.5 \cdot 10^{+68}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.15 \cdot 10^{-275}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq 8.5 \cdot 10^{-223}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d2 \leq 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -4.5000000000000003e68Initial program 78.3%
associate--l+78.3%
sub-neg78.3%
associate-+l+78.3%
+-commutative78.3%
--rgt-identity78.3%
associate--r-78.3%
associate-+r-78.3%
+-commutative78.3%
*-commutative78.3%
sub-neg78.3%
distribute-lft-out--78.3%
distribute-lft-out--78.3%
neg-sub078.3%
distribute-rgt-neg-out78.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.3%
Taylor expanded in d4 around 0 80.7%
if -4.5000000000000003e68 < d2 < -2.14999999999999988e-275 or 8.5000000000000003e-223 < d2 < 1.00000000000000006e-158Initial program 85.4%
associate--l+85.4%
distribute-lft-out--85.4%
*-commutative85.4%
Simplified85.4%
distribute-lft-out--91.0%
*-commutative91.0%
Applied egg-rr91.0%
Taylor expanded in d2 around 0 88.9%
mul-1-neg88.9%
distribute-rgt-neg-in88.9%
distribute-lft-out96.8%
associate-+r-96.8%
+-commutative96.8%
sub-neg96.8%
Simplified96.8%
Taylor expanded in d4 around 0 73.1%
mul-1-neg73.1%
*-commutative73.1%
distribute-rgt-neg-in73.1%
Simplified73.1%
if -2.14999999999999988e-275 < d2 < 8.5000000000000003e-223Initial program 84.0%
associate--l+84.0%
sub-neg84.0%
associate-+l+84.0%
+-commutative84.0%
--rgt-identity84.0%
associate--r-84.0%
associate-+r-84.0%
+-commutative84.0%
*-commutative84.0%
sub-neg84.0%
distribute-lft-out--84.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 d1 around 0 61.0%
Taylor expanded in d2 around 0 61.0%
if 1.00000000000000006e-158 < d2 Initial program 82.3%
associate--l+82.3%
distribute-lft-out--86.4%
*-commutative86.4%
Simplified86.4%
distribute-lft-out--88.5%
*-commutative88.5%
Applied egg-rr88.5%
Taylor expanded in d2 around 0 65.5%
mul-1-neg65.5%
distribute-rgt-neg-in65.5%
distribute-lft-out72.8%
associate-+r-72.8%
+-commutative72.8%
sub-neg72.8%
Simplified72.8%
Taylor expanded in d3 around 0 56.0%
Final simplification66.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 2.7e-118)
(* d1 (- d2 d3))
(if (or (<= d4 2.6e+31) (and (not (<= d4 7e+79)) (<= d4 8e+122)))
(* d1 (- d4 d1))
(* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.7e-118) {
tmp = d1 * (d2 - d3);
} else if ((d4 <= 2.6e+31) || (!(d4 <= 7e+79) && (d4 <= 8e+122))) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 2.7d-118) then
tmp = d1 * (d2 - d3)
else if ((d4 <= 2.6d+31) .or. (.not. (d4 <= 7d+79)) .and. (d4 <= 8d+122)) then
tmp = d1 * (d4 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.7e-118) {
tmp = d1 * (d2 - d3);
} else if ((d4 <= 2.6e+31) || (!(d4 <= 7e+79) && (d4 <= 8e+122))) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.7e-118: tmp = d1 * (d2 - d3) elif (d4 <= 2.6e+31) or (not (d4 <= 7e+79) and (d4 <= 8e+122)): tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.7e-118) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d4 <= 2.6e+31) || (!(d4 <= 7e+79) && (d4 <= 8e+122))) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 2.7e-118) tmp = d1 * (d2 - d3); elseif ((d4 <= 2.6e+31) || (~((d4 <= 7e+79)) && (d4 <= 8e+122))) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.7e-118], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d4, 2.6e+31], And[N[Not[LessEqual[d4, 7e+79]], $MachinePrecision], LessEqual[d4, 8e+122]]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.7 \cdot 10^{-118}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 2.6 \cdot 10^{+31} \lor \neg \left(d4 \leq 7 \cdot 10^{+79}\right) \land d4 \leq 8 \cdot 10^{+122}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 2.69999999999999994e-118Initial program 82.0%
associate--l+82.0%
sub-neg82.0%
associate-+l+82.0%
+-commutative82.0%
--rgt-identity82.0%
associate--r-82.0%
associate-+r-82.0%
+-commutative82.0%
*-commutative82.0%
sub-neg82.0%
distribute-lft-out--82.0%
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 d1 around 0 74.7%
Taylor expanded in d4 around 0 59.1%
if 2.69999999999999994e-118 < d4 < 2.6e31 or 6.99999999999999961e79 < d4 < 8.00000000000000012e122Initial program 93.8%
associate--l+93.8%
distribute-lft-out--93.8%
*-commutative93.8%
Simplified93.8%
distribute-lft-out--93.8%
*-commutative93.8%
Applied egg-rr93.8%
Taylor expanded in d2 around 0 81.2%
mul-1-neg81.2%
distribute-rgt-neg-in81.2%
distribute-lft-out84.3%
associate-+r-84.3%
+-commutative84.3%
sub-neg84.3%
Simplified84.3%
Taylor expanded in d3 around 0 69.8%
if 2.6e31 < d4 < 6.99999999999999961e79 or 8.00000000000000012e122 < d4 Initial program 78.3%
associate--l+78.3%
sub-neg78.3%
associate-+l+78.3%
+-commutative78.3%
--rgt-identity78.3%
associate--r-78.3%
associate-+r-78.3%
+-commutative78.3%
*-commutative78.3%
sub-neg78.3%
distribute-lft-out--82.6%
distribute-lft-out--91.3%
neg-sub091.3%
distribute-rgt-neg-out91.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.6%
Taylor expanded in d2 around 0 78.0%
Final simplification63.8%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))) (t_1 (* d1 (+ d4 d2))))
(if (<= d1 -1.35e+122)
t_0
(if (<= d1 1.45e-8)
t_1
(if (<= d1 4.2e+55) (* d3 (- d1)) (if (<= d1 6.2e+93) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.35e+122) {
tmp = t_0;
} else if (d1 <= 1.45e-8) {
tmp = t_1;
} else if (d1 <= 4.2e+55) {
tmp = d3 * -d1;
} else if (d1 <= 6.2e+93) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = d1 * -d1
t_1 = d1 * (d4 + d2)
if (d1 <= (-1.35d+122)) then
tmp = t_0
else if (d1 <= 1.45d-8) then
tmp = t_1
else if (d1 <= 4.2d+55) then
tmp = d3 * -d1
else if (d1 <= 6.2d+93) then
tmp = t_1
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 * -d1;
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.35e+122) {
tmp = t_0;
} else if (d1 <= 1.45e-8) {
tmp = t_1;
} else if (d1 <= 4.2e+55) {
tmp = d3 * -d1;
} else if (d1 <= 6.2e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 t_1 = d1 * (d4 + d2) tmp = 0 if d1 <= -1.35e+122: tmp = t_0 elif d1 <= 1.45e-8: tmp = t_1 elif d1 <= 4.2e+55: tmp = d3 * -d1 elif d1 <= 6.2e+93: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d1 <= -1.35e+122) tmp = t_0; elseif (d1 <= 1.45e-8) tmp = t_1; elseif (d1 <= 4.2e+55) tmp = Float64(d3 * Float64(-d1)); elseif (d1 <= 6.2e+93) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; t_1 = d1 * (d4 + d2); tmp = 0.0; if (d1 <= -1.35e+122) tmp = t_0; elseif (d1 <= 1.45e-8) tmp = t_1; elseif (d1 <= 4.2e+55) tmp = d3 * -d1; elseif (d1 <= 6.2e+93) tmp = t_1; else tmp = t_0; 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[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -1.35e+122], t$95$0, If[LessEqual[d1, 1.45e-8], t$95$1, If[LessEqual[d1, 4.2e+55], N[(d3 * (-d1)), $MachinePrecision], If[LessEqual[d1, 6.2e+93], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d1 \leq -1.35 \cdot 10^{+122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq 4.2 \cdot 10^{+55}:\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{elif}\;d1 \leq 6.2 \cdot 10^{+93}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d1 < -1.3499999999999999e122 or 6.20000000000000038e93 < d1 Initial program 57.1%
associate--l+57.1%
sub-neg57.1%
associate-+l+57.1%
+-commutative57.1%
--rgt-identity57.1%
associate--r-57.1%
associate-+r-57.1%
+-commutative57.1%
*-commutative57.1%
sub-neg57.1%
distribute-lft-out--58.2%
distribute-lft-out--81.6%
neg-sub081.6%
distribute-rgt-neg-out81.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 76.1%
unpow276.1%
mul-1-neg76.1%
distribute-rgt-neg-out76.1%
Simplified76.1%
if -1.3499999999999999e122 < d1 < 1.4500000000000001e-8 or 4.2000000000000001e55 < d1 < 6.20000000000000038e93Initial program 98.6%
associate--l+98.6%
sub-neg98.6%
associate-+l+98.6%
+-commutative98.6%
--rgt-identity98.6%
associate--r-98.6%
associate-+r-98.6%
+-commutative98.6%
*-commutative98.6%
sub-neg98.6%
distribute-lft-out--99.3%
distribute-lft-out--99.3%
neg-sub099.3%
distribute-rgt-neg-out99.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.4%
Taylor expanded in d3 around 0 64.9%
+-commutative64.9%
Simplified64.9%
if 1.4500000000000001e-8 < d1 < 4.2000000000000001e55Initial 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 d3 around inf 74.1%
associate-*r*74.1%
neg-mul-174.1%
Simplified74.1%
Final simplification69.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d4 -1.8e-275)
(* d1 d2)
(if (<= d4 2.4e-223)
t_0
(if (<= d4 5.2e-148) (* d1 d2) (if (<= d4 5.2e+84) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d4 <= -1.8e-275) {
tmp = d1 * d2;
} else if (d4 <= 2.4e-223) {
tmp = t_0;
} else if (d4 <= 5.2e-148) {
tmp = d1 * d2;
} else if (d4 <= 5.2e+84) {
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 (d4 <= (-1.8d-275)) then
tmp = d1 * d2
else if (d4 <= 2.4d-223) then
tmp = t_0
else if (d4 <= 5.2d-148) then
tmp = d1 * d2
else if (d4 <= 5.2d+84) 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 (d4 <= -1.8e-275) {
tmp = d1 * d2;
} else if (d4 <= 2.4e-223) {
tmp = t_0;
} else if (d4 <= 5.2e-148) {
tmp = d1 * d2;
} else if (d4 <= 5.2e+84) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d4 <= -1.8e-275: tmp = d1 * d2 elif d4 <= 2.4e-223: tmp = t_0 elif d4 <= 5.2e-148: tmp = d1 * d2 elif d4 <= 5.2e+84: 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 (d4 <= -1.8e-275) tmp = Float64(d1 * d2); elseif (d4 <= 2.4e-223) tmp = t_0; elseif (d4 <= 5.2e-148) tmp = Float64(d1 * d2); elseif (d4 <= 5.2e+84) 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 (d4 <= -1.8e-275) tmp = d1 * d2; elseif (d4 <= 2.4e-223) tmp = t_0; elseif (d4 <= 5.2e-148) tmp = d1 * d2; elseif (d4 <= 5.2e+84) 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[d4, -1.8e-275], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.4e-223], t$95$0, If[LessEqual[d4, 5.2e-148], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 5.2e+84], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq -1.8 \cdot 10^{-275}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.4 \cdot 10^{-223}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.2 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5.2 \cdot 10^{+84}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.79999999999999985e-275 or 2.39999999999999985e-223 < d4 < 5.20000000000000015e-148Initial program 81.6%
associate--l+81.6%
sub-neg81.6%
associate-+l+81.6%
+-commutative81.6%
--rgt-identity81.6%
associate--r-81.6%
associate-+r-81.6%
+-commutative81.6%
*-commutative81.6%
sub-neg81.6%
distribute-lft-out--81.6%
distribute-lft-out--92.9%
neg-sub092.9%
distribute-rgt-neg-out92.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.5%
if -1.79999999999999985e-275 < d4 < 2.39999999999999985e-223 or 5.20000000000000015e-148 < d4 < 5.2000000000000002e84Initial 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.1%
distribute-lft-out--92.8%
neg-sub092.8%
distribute-rgt-neg-out92.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 39.7%
unpow239.7%
mul-1-neg39.7%
distribute-rgt-neg-out39.7%
Simplified39.7%
if 5.2000000000000002e84 < d4 Initial program 80.0%
associate--l+80.0%
sub-neg80.0%
associate-+l+80.0%
+-commutative80.0%
--rgt-identity80.0%
associate--r-80.0%
associate-+r-80.0%
+-commutative80.0%
*-commutative80.0%
sub-neg80.0%
distribute-lft-out--84.4%
distribute-lft-out--91.1%
neg-sub091.1%
distribute-rgt-neg-out91.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 59.4%
Final simplification39.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -3.9e-274)
(* d1 d2)
(if (<= d4 8e-221)
(* d3 (- d1))
(if (<= d4 5.2e-148)
(* d1 d2)
(if (<= d4 1.1e+84) (* d1 (- d1)) (* d1 d4))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -3.9e-274) {
tmp = d1 * d2;
} else if (d4 <= 8e-221) {
tmp = d3 * -d1;
} else if (d4 <= 5.2e-148) {
tmp = d1 * d2;
} else if (d4 <= 1.1e+84) {
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 <= (-3.9d-274)) then
tmp = d1 * d2
else if (d4 <= 8d-221) then
tmp = d3 * -d1
else if (d4 <= 5.2d-148) then
tmp = d1 * d2
else if (d4 <= 1.1d+84) 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 <= -3.9e-274) {
tmp = d1 * d2;
} else if (d4 <= 8e-221) {
tmp = d3 * -d1;
} else if (d4 <= 5.2e-148) {
tmp = d1 * d2;
} else if (d4 <= 1.1e+84) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -3.9e-274: tmp = d1 * d2 elif d4 <= 8e-221: tmp = d3 * -d1 elif d4 <= 5.2e-148: tmp = d1 * d2 elif d4 <= 1.1e+84: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -3.9e-274) tmp = Float64(d1 * d2); elseif (d4 <= 8e-221) tmp = Float64(d3 * Float64(-d1)); elseif (d4 <= 5.2e-148) tmp = Float64(d1 * d2); elseif (d4 <= 1.1e+84) 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 <= -3.9e-274) tmp = d1 * d2; elseif (d4 <= 8e-221) tmp = d3 * -d1; elseif (d4 <= 5.2e-148) tmp = d1 * d2; elseif (d4 <= 1.1e+84) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -3.9e-274], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 8e-221], N[(d3 * (-d1)), $MachinePrecision], If[LessEqual[d4, 5.2e-148], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.1e+84], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -3.9 \cdot 10^{-274}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 8 \cdot 10^{-221}:\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 5.2 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.1 \cdot 10^{+84}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -3.89999999999999985e-274 or 8.00000000000000014e-221 < d4 < 5.20000000000000015e-148Initial program 81.2%
associate--l+81.2%
sub-neg81.2%
associate-+l+81.2%
+-commutative81.2%
--rgt-identity81.2%
associate--r-81.2%
associate-+r-81.2%
+-commutative81.2%
*-commutative81.2%
sub-neg81.2%
distribute-lft-out--81.2%
distribute-lft-out--92.8%
neg-sub092.8%
distribute-rgt-neg-out92.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.5%
if -3.89999999999999985e-274 < d4 < 8.00000000000000014e-221Initial program 88.2%
associate--l+88.2%
sub-neg88.2%
associate-+l+88.2%
+-commutative88.2%
--rgt-identity88.2%
associate--r-88.2%
associate-+r-88.2%
+-commutative88.2%
*-commutative88.2%
sub-neg88.2%
distribute-lft-out--88.2%
distribute-lft-out--94.1%
neg-sub094.1%
distribute-rgt-neg-out94.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 57.7%
associate-*r*57.7%
neg-mul-157.7%
Simplified57.7%
if 5.20000000000000015e-148 < d4 < 1.0999999999999999e84Initial program 87.2%
associate--l+87.2%
sub-neg87.2%
associate-+l+87.2%
+-commutative87.2%
--rgt-identity87.2%
associate--r-87.2%
associate-+r-87.2%
+-commutative87.2%
*-commutative87.2%
sub-neg87.2%
distribute-lft-out--87.2%
distribute-lft-out--92.3%
neg-sub092.3%
distribute-rgt-neg-out92.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 50.5%
unpow250.5%
mul-1-neg50.5%
distribute-rgt-neg-out50.5%
Simplified50.5%
if 1.0999999999999999e84 < d4 Initial program 80.0%
associate--l+80.0%
sub-neg80.0%
associate-+l+80.0%
+-commutative80.0%
--rgt-identity80.0%
associate--r-80.0%
associate-+r-80.0%
+-commutative80.0%
*-commutative80.0%
sub-neg80.0%
distribute-lft-out--84.4%
distribute-lft-out--91.1%
neg-sub091.1%
distribute-rgt-neg-out91.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 59.4%
Final simplification43.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -6e+46)
(* d1 (- d2 d3))
(if (or (<= d2 6.4e-270) (not (<= d2 4e-238)))
(* d1 (- d4 d1))
(* d3 (- d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e+46) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= 6.4e-270) || !(d2 <= 4e-238)) {
tmp = d1 * (d4 - d1);
} else {
tmp = 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 <= (-6d+46)) then
tmp = d1 * (d2 - d3)
else if ((d2 <= 6.4d-270) .or. (.not. (d2 <= 4d-238))) then
tmp = d1 * (d4 - d1)
else
tmp = d3 * -d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e+46) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= 6.4e-270) || !(d2 <= 4e-238)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d3 * -d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6e+46: tmp = d1 * (d2 - d3) elif (d2 <= 6.4e-270) or not (d2 <= 4e-238): tmp = d1 * (d4 - d1) else: tmp = d3 * -d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6e+46) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d2 <= 6.4e-270) || !(d2 <= 4e-238)) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d3 * Float64(-d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -6e+46) tmp = d1 * (d2 - d3); elseif ((d2 <= 6.4e-270) || ~((d2 <= 4e-238))) tmp = d1 * (d4 - d1); else tmp = d3 * -d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6e+46], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, 6.4e-270], N[Not[LessEqual[d2, 4e-238]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d3 * (-d1)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6 \cdot 10^{+46}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq 6.4 \cdot 10^{-270} \lor \neg \left(d2 \leq 4 \cdot 10^{-238}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d2 < -6.00000000000000047e46Initial program 77.8%
associate--l+77.8%
sub-neg77.8%
associate-+l+77.8%
+-commutative77.8%
--rgt-identity77.8%
associate--r-77.8%
associate-+r-77.8%
+-commutative77.8%
*-commutative77.8%
sub-neg77.8%
distribute-lft-out--77.7%
distribute-lft-out--79.6%
neg-sub079.6%
distribute-rgt-neg-out79.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 85.3%
Taylor expanded in d4 around 0 76.2%
if -6.00000000000000047e46 < d2 < 6.39999999999999976e-270 or 4e-238 < d2 Initial program 85.0%
associate--l+85.0%
distribute-lft-out--87.1%
*-commutative87.1%
Simplified87.1%
distribute-lft-out--90.2%
*-commutative90.2%
Applied egg-rr90.2%
Taylor expanded in d2 around 0 77.8%
mul-1-neg77.8%
distribute-rgt-neg-in77.8%
distribute-lft-out85.5%
associate-+r-85.5%
+-commutative85.5%
sub-neg85.5%
Simplified85.5%
Taylor expanded in d3 around 0 59.6%
if 6.39999999999999976e-270 < d2 < 4e-238Initial 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--62.5%
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 d3 around inf 51.1%
associate-*r*51.1%
neg-mul-151.1%
Simplified51.1%
Final simplification62.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.45e+69) (* d1 (- d2 d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+69) {
tmp = d1 * (d2 - d3);
} 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+69)) then
tmp = d1 * (d2 - d3)
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+69) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.45e+69: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.45e+69) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.45e+69) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.45e+69], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -1.4499999999999999e69Initial program 78.3%
associate--l+78.3%
sub-neg78.3%
associate-+l+78.3%
+-commutative78.3%
--rgt-identity78.3%
associate--r-78.3%
associate-+r-78.3%
+-commutative78.3%
*-commutative78.3%
sub-neg78.3%
distribute-lft-out--78.3%
distribute-lft-out--78.3%
neg-sub078.3%
distribute-rgt-neg-out78.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.3%
Taylor expanded in d4 around 0 80.7%
if -1.4499999999999999e69 < d2 Initial program 83.8%
associate--l+83.8%
sub-neg83.8%
associate-+l+83.8%
+-commutative83.8%
--rgt-identity83.8%
associate--r-83.8%
associate-+r-83.8%
+-commutative83.8%
*-commutative83.8%
sub-neg83.8%
distribute-lft-out--84.7%
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 d2 around 0 86.2%
Final simplification85.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.1e+69) (* d1 (- (+ d4 d2) d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.1e+69) {
tmp = d1 * ((d4 + d2) - d3);
} 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.1d+69)) then
tmp = d1 * ((d4 + d2) - d3)
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.1e+69) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.1e+69: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.1e+69) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.1e+69) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.1e+69], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.1 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -1.1000000000000001e69Initial program 78.3%
associate--l+78.3%
sub-neg78.3%
associate-+l+78.3%
+-commutative78.3%
--rgt-identity78.3%
associate--r-78.3%
associate-+r-78.3%
+-commutative78.3%
*-commutative78.3%
sub-neg78.3%
distribute-lft-out--78.3%
distribute-lft-out--78.3%
neg-sub078.3%
distribute-rgt-neg-out78.3%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.3%
if -1.1000000000000001e69 < d2 Initial program 83.8%
associate--l+83.8%
sub-neg83.8%
associate-+l+83.8%
+-commutative83.8%
--rgt-identity83.8%
associate--r-83.8%
associate-+r-83.8%
+-commutative83.8%
*-commutative83.8%
sub-neg83.8%
distribute-lft-out--84.7%
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 d2 around 0 86.2%
Final simplification87.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6.5e+51) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6.5e+51) {
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 <= (-6.5d+51)) 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 <= -6.5e+51) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6.5e+51: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6.5e+51) 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 <= -6.5e+51) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6.5e+51], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6.5 \cdot 10^{+51}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -6.5e51Initial program 77.4%
associate--l+77.4%
sub-neg77.4%
associate-+l+77.4%
+-commutative77.4%
--rgt-identity77.4%
associate--r-77.4%
associate-+r-77.4%
+-commutative77.4%
*-commutative77.4%
sub-neg77.4%
distribute-lft-out--77.4%
distribute-lft-out--79.2%
neg-sub079.2%
distribute-rgt-neg-out79.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 57.5%
if -6.5e51 < d2 Initial program 84.2%
associate--l+84.2%
sub-neg84.2%
associate-+l+84.2%
+-commutative84.2%
--rgt-identity84.2%
associate--r-84.2%
associate-+r-84.2%
+-commutative84.2%
*-commutative84.2%
sub-neg84.2%
distribute-lft-out--85.2%
distribute-lft-out--96.0%
neg-sub096.0%
distribute-rgt-neg-out96.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 29.1%
Final simplification35.0%
(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 82.8%
associate--l+82.8%
sub-neg82.8%
associate-+l+82.8%
+-commutative82.8%
--rgt-identity82.8%
associate--r-82.8%
associate-+r-82.8%
+-commutative82.8%
*-commutative82.8%
sub-neg82.8%
distribute-lft-out--83.6%
distribute-lft-out--92.6%
neg-sub092.6%
distribute-rgt-neg-out92.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 28.2%
Final simplification28.2%
(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 2023283
(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)))