
(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 86.7%
associate--l+86.7%
sub-neg86.7%
associate-+l+86.7%
+-commutative86.7%
--rgt-identity86.7%
associate--r-86.7%
associate-+r-86.7%
+-commutative86.7%
*-commutative86.7%
sub-neg86.7%
distribute-lft-out--87.5%
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%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (- (* d1 d3))))
(if (<= d4 -1.15e-158)
(* d1 d2)
(if (<= d4 -1.5e-227)
t_0
(if (<= d4 1.6e-204)
(* d1 d2)
(if (<= d4 4.05e-116)
t_0
(if (<= d4 4.4e-101)
(* d1 d2)
(if (<= d4 4.6e+46) (* d1 (- d1)) (* d1 d4)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double tmp;
if (d4 <= -1.15e-158) {
tmp = d1 * d2;
} else if (d4 <= -1.5e-227) {
tmp = t_0;
} else if (d4 <= 1.6e-204) {
tmp = d1 * d2;
} else if (d4 <= 4.05e-116) {
tmp = t_0;
} else if (d4 <= 4.4e-101) {
tmp = d1 * d2;
} else if (d4 <= 4.6e+46) {
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) :: t_0
real(8) :: tmp
t_0 = -(d1 * d3)
if (d4 <= (-1.15d-158)) then
tmp = d1 * d2
else if (d4 <= (-1.5d-227)) then
tmp = t_0
else if (d4 <= 1.6d-204) then
tmp = d1 * d2
else if (d4 <= 4.05d-116) then
tmp = t_0
else if (d4 <= 4.4d-101) then
tmp = d1 * d2
else if (d4 <= 4.6d+46) 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 t_0 = -(d1 * d3);
double tmp;
if (d4 <= -1.15e-158) {
tmp = d1 * d2;
} else if (d4 <= -1.5e-227) {
tmp = t_0;
} else if (d4 <= 1.6e-204) {
tmp = d1 * d2;
} else if (d4 <= 4.05e-116) {
tmp = t_0;
} else if (d4 <= 4.4e-101) {
tmp = d1 * d2;
} else if (d4 <= 4.6e+46) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = -(d1 * d3) tmp = 0 if d4 <= -1.15e-158: tmp = d1 * d2 elif d4 <= -1.5e-227: tmp = t_0 elif d4 <= 1.6e-204: tmp = d1 * d2 elif d4 <= 4.05e-116: tmp = t_0 elif d4 <= 4.4e-101: tmp = d1 * d2 elif d4 <= 4.6e+46: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) tmp = 0.0 if (d4 <= -1.15e-158) tmp = Float64(d1 * d2); elseif (d4 <= -1.5e-227) tmp = t_0; elseif (d4 <= 1.6e-204) tmp = Float64(d1 * d2); elseif (d4 <= 4.05e-116) tmp = t_0; elseif (d4 <= 4.4e-101) tmp = Float64(d1 * d2); elseif (d4 <= 4.6e+46) tmp = Float64(d1 * Float64(-d1)); 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 (d4 <= -1.15e-158) tmp = d1 * d2; elseif (d4 <= -1.5e-227) tmp = t_0; elseif (d4 <= 1.6e-204) tmp = d1 * d2; elseif (d4 <= 4.05e-116) tmp = t_0; elseif (d4 <= 4.4e-101) tmp = d1 * d2; elseif (d4 <= 4.6e+46) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = (-N[(d1 * d3), $MachinePrecision])}, If[LessEqual[d4, -1.15e-158], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, -1.5e-227], t$95$0, If[LessEqual[d4, 1.6e-204], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.05e-116], t$95$0, If[LessEqual[d4, 4.4e-101], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.6e+46], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
\mathbf{if}\;d4 \leq -1.15 \cdot 10^{-158}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq -1.5 \cdot 10^{-227}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.6 \cdot 10^{-204}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.05 \cdot 10^{-116}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 4.4 \cdot 10^{-101}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.6 \cdot 10^{+46}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.1499999999999999e-158 or -1.5e-227 < d4 < 1.6e-204 or 4.05e-116 < d4 < 4.3999999999999998e-101Initial program 86.6%
associate--l+86.6%
sub-neg86.6%
associate-+l+86.6%
+-commutative86.6%
--rgt-identity86.6%
associate--r-86.6%
associate-+r-86.6%
+-commutative86.6%
*-commutative86.6%
sub-neg86.6%
distribute-lft-out--87.3%
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 d2 around inf 36.2%
if -1.1499999999999999e-158 < d4 < -1.5e-227 or 1.6e-204 < d4 < 4.05e-116Initial 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 58.2%
neg-mul-158.2%
distribute-lft-neg-in58.2%
*-commutative58.2%
Simplified58.2%
if 4.3999999999999998e-101 < d4 < 4.6000000000000001e46Initial program 86.6%
associate--l+86.6%
sub-neg86.6%
associate-+l+86.6%
+-commutative86.6%
--rgt-identity86.6%
associate--r-86.6%
associate-+r-86.6%
+-commutative86.6%
*-commutative86.6%
sub-neg86.6%
distribute-lft-out--86.6%
distribute-lft-out--93.3%
neg-sub093.3%
distribute-rgt-neg-out93.3%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d1 around inf 40.5%
neg-mul-140.5%
unpow240.5%
distribute-rgt-neg-in40.5%
Simplified40.5%
if 4.6000000000000001e46 < d4 Initial program 81.1%
associate--l+81.1%
sub-neg81.1%
associate-+l+81.1%
+-commutative81.1%
--rgt-identity81.1%
associate--r-81.1%
associate-+r-81.1%
+-commutative81.1%
*-commutative81.1%
sub-neg81.1%
distribute-lft-out--83.0%
distribute-lft-out--88.6%
neg-sub088.6%
distribute-rgt-neg-out88.6%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d4 around inf 64.4%
Final simplification44.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (+ d4 d2) d1))))
(if (<= d3 -7.6e+138)
(* d1 (- d2 d3))
(if (<= d3 170000.0)
t_0
(if (<= d3 1.08e+140)
(* (- d1) (+ d1 d3))
(if (<= d3 9.2e+167) t_0 (* d1 (- d4 d3))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * ((d4 + d2) - d1);
double tmp;
if (d3 <= -7.6e+138) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 170000.0) {
tmp = t_0;
} else if (d3 <= 1.08e+140) {
tmp = -d1 * (d1 + d3);
} else if (d3 <= 9.2e+167) {
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 * ((d4 + d2) - d1)
if (d3 <= (-7.6d+138)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 170000.0d0) then
tmp = t_0
else if (d3 <= 1.08d+140) then
tmp = -d1 * (d1 + d3)
else if (d3 <= 9.2d+167) 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 * ((d4 + d2) - d1);
double tmp;
if (d3 <= -7.6e+138) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 170000.0) {
tmp = t_0;
} else if (d3 <= 1.08e+140) {
tmp = -d1 * (d1 + d3);
} else if (d3 <= 9.2e+167) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * ((d4 + d2) - d1) tmp = 0 if d3 <= -7.6e+138: tmp = d1 * (d2 - d3) elif d3 <= 170000.0: tmp = t_0 elif d3 <= 1.08e+140: tmp = -d1 * (d1 + d3) elif d3 <= 9.2e+167: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(d4 + d2) - d1)) tmp = 0.0 if (d3 <= -7.6e+138) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 170000.0) tmp = t_0; elseif (d3 <= 1.08e+140) tmp = Float64(Float64(-d1) * Float64(d1 + d3)); elseif (d3 <= 9.2e+167) 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 * ((d4 + d2) - d1); tmp = 0.0; if (d3 <= -7.6e+138) tmp = d1 * (d2 - d3); elseif (d3 <= 170000.0) tmp = t_0; elseif (d3 <= 1.08e+140) tmp = -d1 * (d1 + d3); elseif (d3 <= 9.2e+167) 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[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -7.6e+138], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 170000.0], t$95$0, If[LessEqual[d3, 1.08e+140], N[((-d1) * N[(d1 + d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 9.2e+167], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{if}\;d3 \leq -7.6 \cdot 10^{+138}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 170000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.08 \cdot 10^{+140}:\\
\;\;\;\;\left(-d1\right) \cdot \left(d1 + d3\right)\\
\mathbf{elif}\;d3 \leq 9.2 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -7.60000000000000025e138Initial program 76.4%
associate--l+76.4%
sub-neg76.4%
associate-+l+76.4%
+-commutative76.4%
--rgt-identity76.4%
associate--r-76.4%
associate-+r-76.4%
+-commutative76.4%
*-commutative76.4%
sub-neg76.4%
distribute-lft-out--79.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 d1 around 0 97.0%
Taylor expanded in d4 around 0 89.9%
if -7.60000000000000025e138 < d3 < 1.7e5 or 1.0799999999999999e140 < d3 < 9.19999999999999952e167Initial program 89.4%
associate--l+89.4%
sub-neg89.4%
associate-+l+89.4%
+-commutative89.4%
--rgt-identity89.4%
associate--r-89.4%
associate-+r-89.4%
+-commutative89.4%
*-commutative89.4%
sub-neg89.4%
distribute-lft-out--89.4%
distribute-lft-out--93.8%
neg-sub093.8%
distribute-rgt-neg-out93.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.5%
if 1.7e5 < d3 < 1.0799999999999999e140Initial program 80.9%
associate--l+80.9%
sub-neg80.9%
associate-+l+80.9%
+-commutative80.9%
--rgt-identity80.9%
associate--r-80.9%
associate-+r-80.9%
+-commutative80.9%
*-commutative80.9%
sub-neg80.9%
distribute-lft-out--85.6%
distribute-lft-out--95.2%
neg-sub095.2%
distribute-rgt-neg-out95.2%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d2 around 0 96.0%
associate--r+96.0%
Simplified96.0%
Taylor expanded in d4 around 0 81.9%
associate-*r*81.9%
+-commutative81.9%
neg-mul-181.9%
*-commutative81.9%
distribute-neg-in81.9%
+-commutative81.9%
sub-neg81.9%
Simplified81.9%
if 9.19999999999999952e167 < d3 Initial program 86.4%
associate--l+86.4%
sub-neg86.4%
associate-+l+86.4%
+-commutative86.4%
--rgt-identity86.4%
associate--r-86.4%
associate-+r-86.4%
+-commutative86.4%
*-commutative86.4%
sub-neg86.4%
distribute-lft-out--86.4%
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 d2 around 0 91.2%
associate--r+91.2%
Simplified91.2%
Taylor expanded in d1 around 0 86.7%
Final simplification92.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (- (* d1 d3))) (t_1 (* d1 (+ d4 d2))))
(if (<= d3 -2.7e+119)
t_0
(if (<= d3 170000.0)
t_1
(if (<= d3 2.1e+85) (* d1 (- d1)) (if (<= d3 9.2e+167) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * (d4 + d2);
double tmp;
if (d3 <= -2.7e+119) {
tmp = t_0;
} else if (d3 <= 170000.0) {
tmp = t_1;
} else if (d3 <= 2.1e+85) {
tmp = d1 * -d1;
} else if (d3 <= 9.2e+167) {
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 * d3)
t_1 = d1 * (d4 + d2)
if (d3 <= (-2.7d+119)) then
tmp = t_0
else if (d3 <= 170000.0d0) then
tmp = t_1
else if (d3 <= 2.1d+85) then
tmp = d1 * -d1
else if (d3 <= 9.2d+167) 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 * d3);
double t_1 = d1 * (d4 + d2);
double tmp;
if (d3 <= -2.7e+119) {
tmp = t_0;
} else if (d3 <= 170000.0) {
tmp = t_1;
} else if (d3 <= 2.1e+85) {
tmp = d1 * -d1;
} else if (d3 <= 9.2e+167) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = -(d1 * d3) t_1 = d1 * (d4 + d2) tmp = 0 if d3 <= -2.7e+119: tmp = t_0 elif d3 <= 170000.0: tmp = t_1 elif d3 <= 2.1e+85: tmp = d1 * -d1 elif d3 <= 9.2e+167: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d3 <= -2.7e+119) tmp = t_0; elseif (d3 <= 170000.0) tmp = t_1; elseif (d3 <= 2.1e+85) tmp = Float64(d1 * Float64(-d1)); elseif (d3 <= 9.2e+167) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = -(d1 * d3); t_1 = d1 * (d4 + d2); tmp = 0.0; if (d3 <= -2.7e+119) tmp = t_0; elseif (d3 <= 170000.0) tmp = t_1; elseif (d3 <= 2.1e+85) tmp = d1 * -d1; elseif (d3 <= 9.2e+167) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = (-N[(d1 * d3), $MachinePrecision])}, Block[{t$95$1 = N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -2.7e+119], t$95$0, If[LessEqual[d3, 170000.0], t$95$1, If[LessEqual[d3, 2.1e+85], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d3, 9.2e+167], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -2.7 \cdot 10^{+119}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 170000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 2.1 \cdot 10^{+85}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d3 \leq 9.2 \cdot 10^{+167}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -2.6999999999999998e119 or 9.19999999999999952e167 < d3 Initial program 79.0%
associate--l+79.0%
sub-neg79.0%
associate-+l+79.0%
+-commutative79.0%
--rgt-identity79.0%
associate--r-79.0%
associate-+r-79.0%
+-commutative79.0%
*-commutative79.0%
sub-neg79.0%
distribute-lft-out--80.6%
distribute-lft-out--93.5%
neg-sub093.5%
distribute-rgt-neg-out93.5%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around inf 77.1%
neg-mul-177.1%
distribute-lft-neg-in77.1%
*-commutative77.1%
Simplified77.1%
if -2.6999999999999998e119 < d3 < 1.7e5 or 2.1000000000000001e85 < d3 < 9.19999999999999952e167Initial program 89.5%
associate--l+89.5%
sub-neg89.5%
associate-+l+89.5%
+-commutative89.5%
--rgt-identity89.5%
associate--r-89.5%
associate-+r-89.5%
+-commutative89.5%
*-commutative89.5%
sub-neg89.5%
distribute-lft-out--90.0%
distribute-lft-out--94.4%
neg-sub094.4%
distribute-rgt-neg-out94.4%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.5%
Taylor expanded in d1 around 0 73.0%
if 1.7e5 < d3 < 2.1000000000000001e85Initial program 84.6%
associate--l+84.6%
sub-neg84.6%
associate-+l+84.6%
+-commutative84.6%
--rgt-identity84.6%
associate--r-84.6%
associate-+r-84.6%
+-commutative84.6%
*-commutative84.6%
sub-neg84.6%
distribute-lft-out--84.6%
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 60.3%
neg-mul-160.3%
unpow260.3%
distribute-rgt-neg-in60.3%
Simplified60.3%
Final simplification73.4%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d4 d1))) (t_1 (* d1 (+ d4 d2))))
(if (<= d1 -5.2e+15)
t_0
(if (<= d1 1.05e-131)
t_1
(if (<= d1 1.35e-120) (- (* d1 d3)) (if (<= d1 2.1e+110) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d1);
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -5.2e+15) {
tmp = t_0;
} else if (d1 <= 1.05e-131) {
tmp = t_1;
} else if (d1 <= 1.35e-120) {
tmp = -(d1 * d3);
} else if (d1 <= 2.1e+110) {
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 * (d4 - d1)
t_1 = d1 * (d4 + d2)
if (d1 <= (-5.2d+15)) then
tmp = t_0
else if (d1 <= 1.05d-131) then
tmp = t_1
else if (d1 <= 1.35d-120) then
tmp = -(d1 * d3)
else if (d1 <= 2.1d+110) 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 * (d4 - d1);
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -5.2e+15) {
tmp = t_0;
} else if (d1 <= 1.05e-131) {
tmp = t_1;
} else if (d1 <= 1.35e-120) {
tmp = -(d1 * d3);
} else if (d1 <= 2.1e+110) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d4 - d1) t_1 = d1 * (d4 + d2) tmp = 0 if d1 <= -5.2e+15: tmp = t_0 elif d1 <= 1.05e-131: tmp = t_1 elif d1 <= 1.35e-120: tmp = -(d1 * d3) elif d1 <= 2.1e+110: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d4 - d1)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d1 <= -5.2e+15) tmp = t_0; elseif (d1 <= 1.05e-131) tmp = t_1; elseif (d1 <= 1.35e-120) tmp = Float64(-Float64(d1 * d3)); elseif (d1 <= 2.1e+110) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d4 - d1); t_1 = d1 * (d4 + d2); tmp = 0.0; if (d1 <= -5.2e+15) tmp = t_0; elseif (d1 <= 1.05e-131) tmp = t_1; elseif (d1 <= 1.35e-120) tmp = -(d1 * d3); elseif (d1 <= 2.1e+110) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -5.2e+15], t$95$0, If[LessEqual[d1, 1.05e-131], t$95$1, If[LessEqual[d1, 1.35e-120], (-N[(d1 * d3), $MachinePrecision]), If[LessEqual[d1, 2.1e+110], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d1\right)\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d1 \leq -5.2 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 1.05 \cdot 10^{-131}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{-120}:\\
\;\;\;\;-d1 \cdot d3\\
\mathbf{elif}\;d1 \leq 2.1 \cdot 10^{+110}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d1 < -5.2e15 or 2.10000000000000015e110 < d1 Initial program 67.3%
associate--l+67.3%
sub-neg67.3%
associate-+l+67.3%
+-commutative67.3%
--rgt-identity67.3%
associate--r-67.3%
associate-+r-67.3%
+-commutative67.3%
*-commutative67.3%
sub-neg67.3%
distribute-lft-out--69.2%
distribute-lft-out--85.6%
neg-sub085.6%
distribute-rgt-neg-out85.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.5%
Taylor expanded in d2 around 0 77.7%
if -5.2e15 < d1 < 1.04999999999999999e-131 or 1.3499999999999999e-120 < d1 < 2.10000000000000015e110Initial 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--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around 0 73.7%
Taylor expanded in d1 around 0 71.0%
if 1.04999999999999999e-131 < d1 < 1.3499999999999999e-120Initial 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 100.0%
neg-mul-1100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
Simplified100.0%
Final simplification74.4%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d4 -9.8e-161)
t_0
(if (<= d4 -9.5e-227)
(- (* d1 d3))
(if (<= d4 3.2e-11)
t_0
(if (<= d4 1e+111) (* d1 (- d4 d1)) (* d1 (+ d4 d2))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= -9.8e-161) {
tmp = t_0;
} else if (d4 <= -9.5e-227) {
tmp = -(d1 * d3);
} else if (d4 <= 3.2e-11) {
tmp = t_0;
} else if (d4 <= 1e+111) {
tmp = d1 * (d4 - 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d4 <= (-9.8d-161)) then
tmp = t_0
else if (d4 <= (-9.5d-227)) then
tmp = -(d1 * d3)
else if (d4 <= 3.2d-11) then
tmp = t_0
else if (d4 <= 1d+111) then
tmp = d1 * (d4 - 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 t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= -9.8e-161) {
tmp = t_0;
} else if (d4 <= -9.5e-227) {
tmp = -(d1 * d3);
} else if (d4 <= 3.2e-11) {
tmp = t_0;
} else if (d4 <= 1e+111) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= -9.8e-161: tmp = t_0 elif d4 <= -9.5e-227: tmp = -(d1 * d3) elif d4 <= 3.2e-11: tmp = t_0 elif d4 <= 1e+111: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= -9.8e-161) tmp = t_0; elseif (d4 <= -9.5e-227) tmp = Float64(-Float64(d1 * d3)); elseif (d4 <= 3.2e-11) tmp = t_0; elseif (d4 <= 1e+111) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d4 <= -9.8e-161) tmp = t_0; elseif (d4 <= -9.5e-227) tmp = -(d1 * d3); elseif (d4 <= 3.2e-11) tmp = t_0; elseif (d4 <= 1e+111) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -9.8e-161], t$95$0, If[LessEqual[d4, -9.5e-227], (-N[(d1 * d3), $MachinePrecision]), If[LessEqual[d4, 3.2e-11], t$95$0, If[LessEqual[d4, 1e+111], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq -9.8 \cdot 10^{-161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq -9.5 \cdot 10^{-227}:\\
\;\;\;\;-d1 \cdot d3\\
\mathbf{elif}\;d4 \leq 3.2 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 10^{+111}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < -9.80000000000000071e-161 or -9.49999999999999953e-227 < d4 < 3.19999999999999994e-11Initial program 86.6%
associate--l+86.6%
sub-neg86.6%
associate-+l+86.6%
+-commutative86.6%
--rgt-identity86.6%
associate--r-86.6%
associate-+r-86.6%
+-commutative86.6%
*-commutative86.6%
sub-neg86.6%
distribute-lft-out--87.1%
distribute-lft-out--94.9%
neg-sub094.9%
distribute-rgt-neg-out94.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 77.6%
Taylor expanded in d4 around 0 57.8%
if -9.80000000000000071e-161 < d4 < -9.49999999999999953e-227Initial 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 52.0%
neg-mul-152.0%
distribute-lft-neg-in52.0%
*-commutative52.0%
Simplified52.0%
if 3.19999999999999994e-11 < d4 < 9.99999999999999957e110Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
--rgt-identity99.8%
associate--r-99.8%
associate-+r-99.8%
+-commutative99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-out--99.8%
distribute-lft-out--99.9%
neg-sub099.9%
distribute-rgt-neg-out99.9%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around 0 86.4%
Taylor expanded in d2 around 0 54.4%
if 9.99999999999999957e110 < d4 Initial program 77.7%
associate--l+77.7%
sub-neg77.7%
associate-+l+77.7%
+-commutative77.7%
--rgt-identity77.7%
associate--r-77.7%
associate-+r-77.7%
+-commutative77.7%
*-commutative77.7%
sub-neg77.7%
distribute-lft-out--80.0%
distribute-lft-out--86.6%
neg-sub086.6%
distribute-rgt-neg-out86.6%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around 0 86.9%
Taylor expanded in d1 around 0 82.5%
Final simplification61.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.05e-15) (not (<= d3 1.45e+86))) (* d1 (- (+ d4 d2) d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.05e-15) || !(d3 <= 1.45e+86)) {
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 <= (-1.05d-15)) .or. (.not. (d3 <= 1.45d+86))) 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 <= -1.05e-15) || !(d3 <= 1.45e+86)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.05e-15) or not (d3 <= 1.45e+86): tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.05e-15) || !(d3 <= 1.45e+86)) 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 <= -1.05e-15) || ~((d3 <= 1.45e+86))) 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, -1.05e-15], N[Not[LessEqual[d3, 1.45e+86]], $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 -1.05 \cdot 10^{-15} \lor \neg \left(d3 \leq 1.45 \cdot 10^{+86}\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 < -1.0499999999999999e-15 or 1.44999999999999995e86 < d3 Initial program 80.9%
associate--l+80.9%
sub-neg80.9%
associate-+l+80.9%
+-commutative80.9%
--rgt-identity80.9%
associate--r-80.9%
associate-+r-80.9%
+-commutative80.9%
*-commutative80.9%
sub-neg80.9%
distribute-lft-out--82.7%
distribute-lft-out--94.5%
neg-sub094.5%
distribute-rgt-neg-out94.5%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d1 around 0 90.1%
if -1.0499999999999999e-15 < d3 < 1.44999999999999995e86Initial program 91.1%
associate--l+91.1%
sub-neg91.1%
associate-+l+91.1%
+-commutative91.1%
--rgt-identity91.1%
associate--r-91.1%
associate-+r-91.1%
+-commutative91.1%
*-commutative91.1%
sub-neg91.1%
distribute-lft-out--91.1%
distribute-lft-out--93.8%
neg-sub093.8%
distribute-rgt-neg-out93.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.6%
Final simplification94.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -5.4e-11) (* d1 (- (+ d4 d2) d3)) (if (<= d3 170000.0) (* d1 (- (+ d4 d2) d1)) (* d1 (- (- d4 d1) d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -5.4e-11) {
tmp = d1 * ((d4 + d2) - d3);
} else if (d3 <= 170000.0) {
tmp = d1 * ((d4 + 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 (d3 <= (-5.4d-11)) then
tmp = d1 * ((d4 + d2) - d3)
else if (d3 <= 170000.0d0) then
tmp = d1 * ((d4 + 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 (d3 <= -5.4e-11) {
tmp = d1 * ((d4 + d2) - d3);
} else if (d3 <= 170000.0) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -5.4e-11: tmp = d1 * ((d4 + d2) - d3) elif d3 <= 170000.0: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -5.4e-11) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); elseif (d3 <= 170000.0) tmp = Float64(d1 * Float64(Float64(d4 + 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 (d3 <= -5.4e-11) tmp = d1 * ((d4 + d2) - d3); elseif (d3 <= 170000.0) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -5.4e-11], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 170000.0], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -5.4 \cdot 10^{-11}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{elif}\;d3 \leq 170000:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d3 < -5.40000000000000009e-11Initial program 82.1%
associate--l+82.1%
sub-neg82.1%
associate-+l+82.1%
+-commutative82.1%
--rgt-identity82.1%
associate--r-82.1%
associate-+r-82.1%
+-commutative82.1%
*-commutative82.1%
sub-neg82.1%
distribute-lft-out--83.5%
distribute-lft-out--91.7%
neg-sub091.7%
distribute-rgt-neg-out91.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.0%
if -5.40000000000000009e-11 < d3 < 1.7e5Initial program 91.7%
associate--l+91.7%
sub-neg91.7%
associate-+l+91.7%
+-commutative91.7%
--rgt-identity91.7%
associate--r-91.7%
associate-+r-91.7%
+-commutative91.7%
*-commutative91.7%
sub-neg91.7%
distribute-lft-out--91.7%
distribute-lft-out--93.9%
neg-sub093.9%
distribute-rgt-neg-out93.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 99.8%
if 1.7e5 < d3 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--82.0%
distribute-lft-out--98.0%
neg-sub098.0%
distribute-rgt-neg-out98.0%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d2 around 0 90.5%
associate--r+90.5%
Simplified90.5%
Final simplification95.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 8.5e-101) (* d1 (- d2 d3)) (if (<= d4 1.7e+111) (* d1 (- d4 d1)) (* d1 (+ d4 d2)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 8.5e-101) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.7e+111) {
tmp = d1 * (d4 - 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 (d4 <= 8.5d-101) then
tmp = d1 * (d2 - d3)
else if (d4 <= 1.7d+111) then
tmp = d1 * (d4 - 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 (d4 <= 8.5e-101) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.7e+111) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 8.5e-101: tmp = d1 * (d2 - d3) elif d4 <= 1.7e+111: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 8.5e-101) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 1.7e+111) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 8.5e-101) tmp = d1 * (d2 - d3); elseif (d4 <= 1.7e+111) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.5e-101], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.7e+111], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 8.5 \cdot 10^{-101}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 1.7 \cdot 10^{+111}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 8.49999999999999941e-101Initial program 88.4%
associate--l+88.4%
sub-neg88.4%
associate-+l+88.4%
+-commutative88.4%
--rgt-identity88.4%
associate--r-88.4%
associate-+r-88.4%
+-commutative88.4%
*-commutative88.4%
sub-neg88.4%
distribute-lft-out--89.0%
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 d1 around 0 80.9%
Taylor expanded in d4 around 0 61.3%
if 8.49999999999999941e-101 < d4 < 1.7000000000000001e111Initial program 89.4%
associate--l+89.4%
sub-neg89.4%
associate-+l+89.4%
+-commutative89.4%
--rgt-identity89.4%
associate--r-89.4%
associate-+r-89.4%
+-commutative89.4%
*-commutative89.4%
sub-neg89.4%
distribute-lft-out--89.4%
distribute-lft-out--94.7%
neg-sub094.7%
distribute-rgt-neg-out94.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 82.5%
Taylor expanded in d2 around 0 52.3%
if 1.7000000000000001e111 < d4 Initial program 77.7%
associate--l+77.7%
sub-neg77.7%
associate-+l+77.7%
+-commutative77.7%
--rgt-identity77.7%
associate--r-77.7%
associate-+r-77.7%
+-commutative77.7%
*-commutative77.7%
sub-neg77.7%
distribute-lft-out--80.0%
distribute-lft-out--86.6%
neg-sub086.6%
distribute-rgt-neg-out86.6%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around 0 86.9%
Taylor expanded in d1 around 0 82.5%
Final simplification63.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.7e-101) (* d1 d2) (if (<= d4 1.45e+46) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.7e-101) {
tmp = d1 * d2;
} else if (d4 <= 1.45e+46) {
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 <= 4.7d-101) then
tmp = d1 * d2
else if (d4 <= 1.45d+46) 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 <= 4.7e-101) {
tmp = d1 * d2;
} else if (d4 <= 1.45e+46) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.7e-101: tmp = d1 * d2 elif d4 <= 1.45e+46: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.7e-101) tmp = Float64(d1 * d2); elseif (d4 <= 1.45e+46) 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 <= 4.7e-101) tmp = d1 * d2; elseif (d4 <= 1.45e+46) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.7e-101], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.45e+46], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.7 \cdot 10^{-101}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.45 \cdot 10^{+46}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 4.6999999999999999e-101Initial program 88.4%
associate--l+88.4%
sub-neg88.4%
associate-+l+88.4%
+-commutative88.4%
--rgt-identity88.4%
associate--r-88.4%
associate-+r-88.4%
+-commutative88.4%
*-commutative88.4%
sub-neg88.4%
distribute-lft-out--89.0%
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 inf 33.6%
if 4.6999999999999999e-101 < d4 < 1.4500000000000001e46Initial program 86.6%
associate--l+86.6%
sub-neg86.6%
associate-+l+86.6%
+-commutative86.6%
--rgt-identity86.6%
associate--r-86.6%
associate-+r-86.6%
+-commutative86.6%
*-commutative86.6%
sub-neg86.6%
distribute-lft-out--86.6%
distribute-lft-out--93.3%
neg-sub093.3%
distribute-rgt-neg-out93.3%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d1 around inf 40.5%
neg-mul-140.5%
unpow240.5%
distribute-rgt-neg-in40.5%
Simplified40.5%
if 1.4500000000000001e46 < d4 Initial program 81.1%
associate--l+81.1%
sub-neg81.1%
associate-+l+81.1%
+-commutative81.1%
--rgt-identity81.1%
associate--r-81.1%
associate-+r-81.1%
+-commutative81.1%
*-commutative81.1%
sub-neg81.1%
distribute-lft-out--83.0%
distribute-lft-out--88.6%
neg-sub088.6%
distribute-rgt-neg-out88.6%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d4 around inf 64.4%
Final simplification40.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 0.0027) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 0.0027) {
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 <= 0.0027d0) 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 <= 0.0027) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 0.0027: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 0.0027) 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 <= 0.0027) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 0.0027], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 0.0027:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 0.0027000000000000001Initial program 87.7%
associate--l+87.7%
sub-neg87.7%
associate-+l+87.7%
+-commutative87.7%
--rgt-identity87.7%
associate--r-87.7%
associate-+r-87.7%
+-commutative87.7%
*-commutative87.7%
sub-neg87.7%
distribute-lft-out--88.2%
distribute-lft-out--95.4%
neg-sub095.4%
distribute-rgt-neg-out95.4%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.1%
if 0.0027000000000000001 < d4 Initial 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.2%
distribute-lft-out--90.1%
neg-sub090.1%
distribute-rgt-neg-out90.1%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d4 around inf 59.0%
Final simplification39.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d4))
double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
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
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
def code(d1, d2, d3, d4): return d1 * d4
function code(d1, d2, d3, d4) return Float64(d1 * d4) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d4; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d4), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d4
\end{array}
Initial program 86.7%
associate--l+86.7%
sub-neg86.7%
associate-+l+86.7%
+-commutative86.7%
--rgt-identity86.7%
associate--r-86.7%
associate-+r-86.7%
+-commutative86.7%
*-commutative86.7%
sub-neg86.7%
distribute-lft-out--87.5%
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 d4 around inf 34.1%
Final simplification34.1%
(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 2023274
(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)))