
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d3) (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d2 - d3) + (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d3) + (d4 - d1)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 86.7%
associate--l+86.7%
distribute-lft-out--87.5%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- d2 d3))) (t_2 (* d1 (+ d2 d4))))
(if (<= d3 -4.8e+78)
t_1
(if (<= d3 -14000000.0)
t_2
(if (<= d3 -1.05e-301)
t_0
(if (<= d3 9.4e-203) t_2 (if (<= d3 1.12e+85) t_0 t_1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double t_2 = d1 * (d2 + d4);
double tmp;
if (d3 <= -4.8e+78) {
tmp = t_1;
} else if (d3 <= -14000000.0) {
tmp = t_2;
} else if (d3 <= -1.05e-301) {
tmp = t_0;
} else if (d3 <= 9.4e-203) {
tmp = t_2;
} else if (d3 <= 1.12e+85) {
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 - d1)
t_1 = d1 * (d2 - d3)
t_2 = d1 * (d2 + d4)
if (d3 <= (-4.8d+78)) then
tmp = t_1
else if (d3 <= (-14000000.0d0)) then
tmp = t_2
else if (d3 <= (-1.05d-301)) then
tmp = t_0
else if (d3 <= 9.4d-203) then
tmp = t_2
else if (d3 <= 1.12d+85) 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 - d1);
double t_1 = d1 * (d2 - d3);
double t_2 = d1 * (d2 + d4);
double tmp;
if (d3 <= -4.8e+78) {
tmp = t_1;
} else if (d3 <= -14000000.0) {
tmp = t_2;
} else if (d3 <= -1.05e-301) {
tmp = t_0;
} else if (d3 <= 9.4e-203) {
tmp = t_2;
} else if (d3 <= 1.12e+85) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (d2 - d3) t_2 = d1 * (d2 + d4) tmp = 0 if d3 <= -4.8e+78: tmp = t_1 elif d3 <= -14000000.0: tmp = t_2 elif d3 <= -1.05e-301: tmp = t_0 elif d3 <= 9.4e-203: tmp = t_2 elif d3 <= 1.12e+85: tmp = t_0 else: tmp = t_1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(d2 - d3)) t_2 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d3 <= -4.8e+78) tmp = t_1; elseif (d3 <= -14000000.0) tmp = t_2; elseif (d3 <= -1.05e-301) tmp = t_0; elseif (d3 <= 9.4e-203) tmp = t_2; elseif (d3 <= 1.12e+85) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (d2 - d3); t_2 = d1 * (d2 + d4); tmp = 0.0; if (d3 <= -4.8e+78) tmp = t_1; elseif (d3 <= -14000000.0) tmp = t_2; elseif (d3 <= -1.05e-301) tmp = t_0; elseif (d3 <= 9.4e-203) tmp = t_2; elseif (d3 <= 1.12e+85) 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 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -4.8e+78], t$95$1, If[LessEqual[d3, -14000000.0], t$95$2, If[LessEqual[d3, -1.05e-301], t$95$0, If[LessEqual[d3, 9.4e-203], t$95$2, If[LessEqual[d3, 1.12e+85], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
t_2 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d3 \leq -4.8 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq -14000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq -1.05 \cdot 10^{-301}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 9.4 \cdot 10^{-203}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq 1.12 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d3 < -4.7999999999999997e78 or 1.11999999999999993e85 < d3 Initial program 80.8%
associate--l+80.8%
distribute-lft-out--82.8%
distribute-rgt-out--85.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 88.1%
+-commutative88.1%
associate--r+88.1%
Simplified88.1%
Taylor expanded in d1 around 0 80.1%
if -4.7999999999999997e78 < d3 < -1.4e7 or -1.0499999999999999e-301 < d3 < 9.40000000000000012e-203Initial program 93.5%
associate--l+93.5%
distribute-lft-out--93.5%
distribute-rgt-out--96.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d1 around 0 93.7%
Taylor expanded in d3 around 0 87.5%
+-commutative87.5%
Simplified87.5%
if -1.4e7 < d3 < -1.0499999999999999e-301 or 9.40000000000000012e-203 < d3 < 1.11999999999999993e85Initial program 89.7%
associate--l+89.7%
distribute-lft-out--89.7%
distribute-rgt-out--95.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 81.8%
+-commutative81.8%
associate--r+81.8%
Simplified81.8%
Taylor expanded in d3 around 0 79.6%
Final simplification80.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.25e+18) (not (<= d3 8.5e+108))) (* d1 (- (+ d2 d4) d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.25e+18) || !(d3 <= 8.5e+108)) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d2 + 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 ((d3 <= (-2.25d+18)) .or. (.not. (d3 <= 8.5d+108))) then
tmp = d1 * ((d2 + d4) - d3)
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.25e+18) || !(d3 <= 8.5e+108)) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.25e+18) or not (d3 <= 8.5e+108): tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.25e+18) || !(d3 <= 8.5e+108)) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.25e+18) || ~((d3 <= 8.5e+108))) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.25e+18], N[Not[LessEqual[d3, 8.5e+108]], $MachinePrecision]], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.25 \cdot 10^{+18} \lor \neg \left(d3 \leq 8.5 \cdot 10^{+108}\right):\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -2.25e18 or 8.50000000000000016e108 < d3 Initial program 81.7%
associate--l+81.7%
distribute-lft-out--83.7%
distribute-rgt-out--85.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 98.0%
Taylor expanded in d1 around 0 93.2%
if -2.25e18 < d3 < 8.50000000000000016e108Initial program 90.1%
associate--l+90.1%
distribute-lft-out--90.1%
distribute-rgt-out--96.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 98.1%
Final simplification96.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -8.8e+156) (* d1 (- d4 d3)) (if (<= d3 1.75e+95) (* d1 (- (+ d2 d4) d1)) (* d1 (- d2 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -8.8e+156) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 1.75e+95) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d2 - 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 <= (-8.8d+156)) then
tmp = d1 * (d4 - d3)
else if (d3 <= 1.75d+95) then
tmp = d1 * ((d2 + d4) - d1)
else
tmp = d1 * (d2 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -8.8e+156) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 1.75e+95) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d2 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -8.8e+156: tmp = d1 * (d4 - d3) elif d3 <= 1.75e+95: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d2 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -8.8e+156) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d3 <= 1.75e+95) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); else tmp = Float64(d1 * Float64(d2 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -8.8e+156) tmp = d1 * (d4 - d3); elseif (d3 <= 1.75e+95) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * (d2 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -8.8e+156], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.75e+95], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -8.8 \cdot 10^{+156}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d3 \leq 1.75 \cdot 10^{+95}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\end{array}
\end{array}
if d3 < -8.80000000000000016e156Initial program 77.7%
associate--l+77.7%
distribute-lft-out--77.8%
distribute-rgt-out--80.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 94.3%
Taylor expanded in d1 around 0 97.1%
Taylor expanded in d2 around 0 89.4%
if -8.80000000000000016e156 < d3 < 1.75e95Initial program 87.9%
associate--l+87.9%
distribute-lft-out--89.1%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.0%
if 1.75e95 < d3 Initial program 89.1%
associate--l+89.1%
distribute-lft-out--89.1%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 89.0%
+-commutative89.0%
associate--r+89.0%
Simplified89.0%
Taylor expanded in d1 around 0 86.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.2e+156) (not (<= d3 8.5e+107))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.2e+156) || !(d3 <= 8.5e+107)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-2.2d+156)) .or. (.not. (d3 <= 8.5d+107))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.2e+156) || !(d3 <= 8.5e+107)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.2e+156) or not (d3 <= 8.5e+107): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.2e+156) || !(d3 <= 8.5e+107)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.2e+156) || ~((d3 <= 8.5e+107))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.2e+156], N[Not[LessEqual[d3, 8.5e+107]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.2 \cdot 10^{+156} \lor \neg \left(d3 \leq 8.5 \cdot 10^{+107}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -2.20000000000000004e156 or 8.4999999999999999e107 < d3 Initial program 83.7%
associate--l+83.7%
distribute-lft-out--83.8%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 77.9%
associate-*r*77.9%
neg-mul-177.9%
Simplified77.9%
if -2.20000000000000004e156 < d3 < 8.4999999999999999e107Initial program 88.1%
associate--l+88.1%
distribute-lft-out--89.2%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 97.2%
Taylor expanded in d1 around 0 69.2%
Taylor expanded in d3 around 0 63.2%
+-commutative63.2%
Simplified63.2%
Final simplification67.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -4.3e-135) (* d1 (- d2 d3)) (if (<= d4 1.5e+57) (* d1 (- d2 d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -4.3e-135) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.5e+57) {
tmp = d1 * (d2 - 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 <= (-4.3d-135)) then
tmp = d1 * (d2 - d3)
else if (d4 <= 1.5d+57) then
tmp = d1 * (d2 - 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 <= -4.3e-135) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.5e+57) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -4.3e-135: tmp = d1 * (d2 - d3) elif d4 <= 1.5e+57: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -4.3e-135) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 1.5e+57) tmp = Float64(d1 * Float64(d2 - 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 <= -4.3e-135) tmp = d1 * (d2 - d3); elseif (d4 <= 1.5e+57) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -4.3e-135], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.5e+57], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -4.3 \cdot 10^{-135}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 1.5 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -4.29999999999999999e-135Initial program 85.6%
associate--l+85.6%
distribute-lft-out--87.6%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 73.5%
+-commutative73.5%
associate--r+73.5%
Simplified73.5%
Taylor expanded in d1 around 0 50.3%
if -4.29999999999999999e-135 < d4 < 1.5e57Initial program 90.1%
associate--l+90.1%
distribute-lft-out--90.1%
distribute-rgt-out--90.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 99.1%
+-commutative99.1%
associate--r+99.1%
Simplified99.1%
Taylor expanded in d3 around 0 77.8%
if 1.5e57 < d4 Initial program 81.3%
associate--l+81.3%
distribute-lft-out--81.3%
distribute-rgt-out--95.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d1 around 0 85.4%
Taylor expanded in d2 around 0 75.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.55e+53) (* d1 (- d2 d1)) (if (<= d4 9.95e+77) (* d1 (- d3)) (* d1 (+ d2 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.55e+53) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 9.95e+77) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 1.55d+53) then
tmp = d1 * (d2 - d1)
else if (d4 <= 9.95d+77) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.55e+53) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 9.95e+77) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.55e+53: tmp = d1 * (d2 - d1) elif d4 <= 9.95e+77: tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.55e+53) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 9.95e+77) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.55e+53) tmp = d1 * (d2 - d1); elseif (d4 <= 9.95e+77) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.55e+53], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 9.95e+77], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.55 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 9.95 \cdot 10^{+77}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.5500000000000001e53Initial program 87.9%
associate--l+87.9%
distribute-lft-out--88.8%
distribute-rgt-out--90.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.1%
+-commutative87.1%
associate--r+87.1%
Simplified87.1%
Taylor expanded in d3 around 0 65.7%
if 1.5500000000000001e53 < d4 < 9.95e77Initial program 87.5%
associate--l+87.5%
distribute-lft-out--87.5%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 88.0%
associate-*r*88.0%
neg-mul-188.0%
Simplified88.0%
if 9.95e77 < d4 Initial program 81.0%
associate--l+81.0%
distribute-lft-out--81.0%
distribute-rgt-out--97.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d1 around 0 83.3%
Taylor expanded in d3 around 0 71.2%
+-commutative71.2%
Simplified71.2%
Final simplification67.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5e+121) (* d1 d2) (if (<= d2 -4.2e-178) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+121) {
tmp = d1 * d2;
} else if (d2 <= -4.2e-178) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5d+121)) then
tmp = d1 * d2
else if (d2 <= (-4.2d-178)) then
tmp = d1 * -d3
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+121) {
tmp = d1 * d2;
} else if (d2 <= -4.2e-178) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5e+121: tmp = d1 * d2 elif d2 <= -4.2e-178: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5e+121) tmp = Float64(d1 * d2); elseif (d2 <= -4.2e-178) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5e+121) tmp = d1 * d2; elseif (d2 <= -4.2e-178) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5e+121], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -4.2e-178], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5 \cdot 10^{+121}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4.2 \cdot 10^{-178}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.00000000000000007e121Initial program 88.1%
associate--l+88.1%
distribute-lft-out--92.9%
distribute-rgt-out--92.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around inf 70.1%
if -5.00000000000000007e121 < d2 < -4.2e-178Initial program 85.1%
associate--l+85.1%
distribute-lft-out--85.1%
distribute-rgt-out--90.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 45.1%
associate-*r*45.1%
neg-mul-145.1%
Simplified45.1%
if -4.2e-178 < d2 Initial program 87.1%
associate--l+87.1%
distribute-lft-out--87.1%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 31.3%
Final simplification41.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 5.8e+14) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d1) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 5.8e+14) {
tmp = d1 * ((d2 - d3) - 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 (d4 <= 5.8d+14) then
tmp = d1 * ((d2 - d3) - 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 (d4 <= 5.8e+14) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 5.8e+14: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 5.8e+14) tmp = Float64(d1 * Float64(Float64(d2 - d3) - 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 (d4 <= 5.8e+14) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 5.8e+14], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 5.8 \cdot 10^{+14}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 5.8e14Initial program 87.4%
associate--l+87.4%
distribute-lft-out--88.4%
distribute-rgt-out--90.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.0%
+-commutative87.0%
associate--r+87.0%
Simplified87.0%
if 5.8e14 < d4 Initial program 84.5%
associate--l+84.5%
distribute-lft-out--84.5%
distribute-rgt-out--96.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 91.5%
associate--r+91.5%
Simplified91.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.2e+117) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.2e+117) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + 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 <= 3.2d+117) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.2e+117) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.2e+117: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.2e+117) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.2e+117) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.2e+117], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.2 \cdot 10^{+117}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 3.20000000000000005e117Initial program 87.7%
associate--l+87.7%
distribute-lft-out--88.6%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.4%
+-commutative87.4%
associate--r+87.4%
Simplified87.4%
if 3.20000000000000005e117 < d4 Initial program 81.1%
associate--l+81.1%
distribute-lft-out--81.1%
distribute-rgt-out--97.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d1 around 0 86.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.2e+21) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.2e+21) {
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 <= 2.2d+21) 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 <= 2.2e+21) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.2e+21: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.2e+21) 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 <= 2.2e+21) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.2e+21], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.2 \cdot 10^{+21}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.2e21Initial program 87.5%
associate--l+87.5%
distribute-lft-out--88.5%
distribute-rgt-out--90.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.0%
if 2.2e21 < d4 Initial program 83.9%
associate--l+83.9%
distribute-lft-out--83.9%
distribute-rgt-out--96.4%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around inf 48.8%
(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 86.7%
associate--l+86.7%
distribute-lft-out--87.5%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 30.6%
(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 2024101
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))