
(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 13 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 d1) (- d2 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - d3));
}
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 - d1) + (d2 - d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - d3));
}
def code(d1, d2, d3, d4): return d1 * ((d4 - d1) + (d2 - d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - d1) + Float64(d2 - d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - d1) + (d2 - d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - d1), $MachinePrecision] + N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 - d1\right) + \left(d2 - d3\right)\right)
\end{array}
Initial program 91.0%
associate--l+91.0%
+-commutative91.0%
distribute-rgt-out--92.6%
distribute-lft-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (or (<= d4 3.75e-79)
(and (not (<= d4 4.6e-49))
(or (<= d4 2.2e-29)
(and (not (<= d4 5.8e+25)) (<= d4 3.2e+73)))))
(* d1 (- d2 d3))
(* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d4 <= 3.75e-79) || (!(d4 <= 4.6e-49) && ((d4 <= 2.2e-29) || (!(d4 <= 5.8e+25) && (d4 <= 3.2e+73))))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d4 <= 3.75d-79) .or. (.not. (d4 <= 4.6d-49)) .and. (d4 <= 2.2d-29) .or. (.not. (d4 <= 5.8d+25)) .and. (d4 <= 3.2d+73)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d4 <= 3.75e-79) || (!(d4 <= 4.6e-49) && ((d4 <= 2.2e-29) || (!(d4 <= 5.8e+25) && (d4 <= 3.2e+73))))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d4 <= 3.75e-79) or (not (d4 <= 4.6e-49) and ((d4 <= 2.2e-29) or (not (d4 <= 5.8e+25) and (d4 <= 3.2e+73)))): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d4 <= 3.75e-79) || (!(d4 <= 4.6e-49) && ((d4 <= 2.2e-29) || (!(d4 <= 5.8e+25) && (d4 <= 3.2e+73))))) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d4 <= 3.75e-79) || (~((d4 <= 4.6e-49)) && ((d4 <= 2.2e-29) || (~((d4 <= 5.8e+25)) && (d4 <= 3.2e+73))))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d4, 3.75e-79], And[N[Not[LessEqual[d4, 4.6e-49]], $MachinePrecision], Or[LessEqual[d4, 2.2e-29], And[N[Not[LessEqual[d4, 5.8e+25]], $MachinePrecision], LessEqual[d4, 3.2e+73]]]]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.75 \cdot 10^{-79} \lor \neg \left(d4 \leq 4.6 \cdot 10^{-49}\right) \land \left(d4 \leq 2.2 \cdot 10^{-29} \lor \neg \left(d4 \leq 5.8 \cdot 10^{+25}\right) \land d4 \leq 3.2 \cdot 10^{+73}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 3.74999999999999985e-79 or 4.5999999999999998e-49 < d4 < 2.1999999999999999e-29 or 5.7999999999999998e25 < d4 < 3.19999999999999982e73Initial program 90.6%
associate--l+90.6%
+-commutative90.6%
distribute-rgt-out--91.6%
distribute-lft-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.5%
Taylor expanded in d4 around 0 67.0%
if 3.74999999999999985e-79 < d4 < 4.5999999999999998e-49 or 2.1999999999999999e-29 < d4 < 5.7999999999999998e25 or 3.19999999999999982e73 < d4 Initial program 92.5%
associate--l+92.5%
+-commutative92.5%
distribute-rgt-out--96.2%
distribute-lft-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.1%
Taylor expanded in d2 around 0 74.7%
Final simplification68.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d4 d1))) (t_1 (* d1 (- d2 d3))))
(if (<= d4 3.75e-79)
t_1
(if (<= d4 5e-49)
t_0
(if (<= d4 2.2e-29)
t_1
(if (<= d4 1.18e+24)
t_0
(if (<= d4 3.9e+71) t_1 (* d1 (- d4 d3)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= 3.75e-79) {
tmp = t_1;
} else if (d4 <= 5e-49) {
tmp = t_0;
} else if (d4 <= 2.2e-29) {
tmp = t_1;
} else if (d4 <= 1.18e+24) {
tmp = t_0;
} else if (d4 <= 3.9e+71) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * (d4 - d1)
t_1 = d1 * (d2 - d3)
if (d4 <= 3.75d-79) then
tmp = t_1
else if (d4 <= 5d-49) then
tmp = t_0
else if (d4 <= 2.2d-29) then
tmp = t_1
else if (d4 <= 1.18d+24) then
tmp = t_0
else if (d4 <= 3.9d+71) then
tmp = t_1
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= 3.75e-79) {
tmp = t_1;
} else if (d4 <= 5e-49) {
tmp = t_0;
} else if (d4 <= 2.2e-29) {
tmp = t_1;
} else if (d4 <= 1.18e+24) {
tmp = t_0;
} else if (d4 <= 3.9e+71) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d4 - d1) t_1 = d1 * (d2 - d3) tmp = 0 if d4 <= 3.75e-79: tmp = t_1 elif d4 <= 5e-49: tmp = t_0 elif d4 <= 2.2e-29: tmp = t_1 elif d4 <= 1.18e+24: tmp = t_0 elif d4 <= 3.9e+71: tmp = t_1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d4 - d1)) t_1 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 3.75e-79) tmp = t_1; elseif (d4 <= 5e-49) tmp = t_0; elseif (d4 <= 2.2e-29) tmp = t_1; elseif (d4 <= 1.18e+24) tmp = t_0; elseif (d4 <= 3.9e+71) tmp = t_1; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d4 - d1); t_1 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 3.75e-79) tmp = t_1; elseif (d4 <= 5e-49) tmp = t_0; elseif (d4 <= 2.2e-29) tmp = t_1; elseif (d4 <= 1.18e+24) tmp = t_0; elseif (d4 <= 3.9e+71) tmp = t_1; else tmp = d1 * (d4 - d3); 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[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 3.75e-79], t$95$1, If[LessEqual[d4, 5e-49], t$95$0, If[LessEqual[d4, 2.2e-29], t$95$1, If[LessEqual[d4, 1.18e+24], t$95$0, If[LessEqual[d4, 3.9e+71], t$95$1, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 3.75 \cdot 10^{-79}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 5 \cdot 10^{-49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2.2 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 1.18 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 3.9 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 3.74999999999999985e-79 or 4.9999999999999999e-49 < d4 < 2.1999999999999999e-29 or 1.17999999999999997e24 < d4 < 3.9000000000000001e71Initial program 90.6%
associate--l+90.6%
+-commutative90.6%
distribute-rgt-out--91.6%
distribute-lft-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.5%
Taylor expanded in d4 around 0 67.0%
if 3.74999999999999985e-79 < d4 < 4.9999999999999999e-49 or 2.1999999999999999e-29 < d4 < 1.17999999999999997e24Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
distribute-rgt-out--100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.9%
Taylor expanded in d2 around 0 74.9%
if 3.9000000000000001e71 < d4 Initial program 89.5%
associate--l+89.5%
+-commutative89.5%
distribute-rgt-out--94.7%
distribute-lft-out--94.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.0%
Taylor expanded in d2 around 0 84.2%
Final simplification70.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))) (t_1 (* d1 (+ d4 d2))))
(if (<= d3 -4.6e+136)
t_0
(if (<= d3 1.75e-214)
t_1
(if (<= d3 2.35e-166) (* d1 (- d2 d1)) (if (<= d3 1.8e+94) 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 <= -4.6e+136) {
tmp = t_0;
} else if (d3 <= 1.75e-214) {
tmp = t_1;
} else if (d3 <= 2.35e-166) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.8e+94) {
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 <= (-4.6d+136)) then
tmp = t_0
else if (d3 <= 1.75d-214) then
tmp = t_1
else if (d3 <= 2.35d-166) then
tmp = d1 * (d2 - d1)
else if (d3 <= 1.8d+94) 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 <= -4.6e+136) {
tmp = t_0;
} else if (d3 <= 1.75e-214) {
tmp = t_1;
} else if (d3 <= 2.35e-166) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.8e+94) {
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 <= -4.6e+136: tmp = t_0 elif d3 <= 1.75e-214: tmp = t_1 elif d3 <= 2.35e-166: tmp = d1 * (d2 - d1) elif d3 <= 1.8e+94: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d3 <= -4.6e+136) tmp = t_0; elseif (d3 <= 1.75e-214) tmp = t_1; elseif (d3 <= 2.35e-166) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 1.8e+94) 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 <= -4.6e+136) tmp = t_0; elseif (d3 <= 1.75e-214) tmp = t_1; elseif (d3 <= 2.35e-166) tmp = d1 * (d2 - d1); elseif (d3 <= 1.8e+94) 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, -4.6e+136], t$95$0, If[LessEqual[d3, 1.75e-214], t$95$1, If[LessEqual[d3, 2.35e-166], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.8e+94], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -4.6 \cdot 10^{+136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.75 \cdot 10^{-214}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 2.35 \cdot 10^{-166}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 1.8 \cdot 10^{+94}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -4.6e136 or 1.79999999999999996e94 < d3 Initial program 88.7%
associate--l+88.7%
+-commutative88.7%
distribute-rgt-out--89.9%
distribute-lft-out--92.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 83.5%
mul-1-neg83.5%
distribute-lft-neg-in83.5%
*-commutative83.5%
Simplified83.5%
if -4.6e136 < d3 < 1.75e-214 or 2.35000000000000007e-166 < d3 < 1.79999999999999996e94Initial program 92.1%
associate--l+92.1%
+-commutative92.1%
distribute-rgt-out--94.0%
distribute-lft-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.7%
Taylor expanded in d1 around 0 74.0%
if 1.75e-214 < d3 < 2.35000000000000007e-166Initial program 93.3%
associate--l+93.3%
+-commutative93.3%
distribute-rgt-out--93.3%
distribute-lft-out--93.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 99.9%
Taylor expanded in d4 around 0 80.6%
Final simplification77.7%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d2 -8.5e+101)
(* d1 d2)
(if (<= d2 -3.2e+74)
t_0
(if (<= d2 -4.1e+43) (* d1 d2) (if (<= d2 2.3e-242) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d2 <= -8.5e+101) {
tmp = d1 * d2;
} else if (d2 <= -3.2e+74) {
tmp = t_0;
} else if (d2 <= -4.1e+43) {
tmp = d1 * d2;
} else if (d2 <= 2.3e-242) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * -d3
if (d2 <= (-8.5d+101)) then
tmp = d1 * d2
else if (d2 <= (-3.2d+74)) then
tmp = t_0
else if (d2 <= (-4.1d+43)) then
tmp = d1 * d2
else if (d2 <= 2.3d-242) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d2 <= -8.5e+101) {
tmp = d1 * d2;
} else if (d2 <= -3.2e+74) {
tmp = t_0;
} else if (d2 <= -4.1e+43) {
tmp = d1 * d2;
} else if (d2 <= 2.3e-242) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d2 <= -8.5e+101: tmp = d1 * d2 elif d2 <= -3.2e+74: tmp = t_0 elif d2 <= -4.1e+43: tmp = d1 * d2 elif d2 <= 2.3e-242: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d2 <= -8.5e+101) tmp = Float64(d1 * d2); elseif (d2 <= -3.2e+74) tmp = t_0; elseif (d2 <= -4.1e+43) tmp = Float64(d1 * d2); elseif (d2 <= 2.3e-242) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d2 <= -8.5e+101) tmp = d1 * d2; elseif (d2 <= -3.2e+74) tmp = t_0; elseif (d2 <= -4.1e+43) tmp = d1 * d2; elseif (d2 <= 2.3e-242) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d2, -8.5e+101], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -3.2e+74], t$95$0, If[LessEqual[d2, -4.1e+43], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 2.3e-242], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d2 \leq -8.5 \cdot 10^{+101}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -3.2 \cdot 10^{+74}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -4.1 \cdot 10^{+43}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 2.3 \cdot 10^{-242}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -8.5000000000000001e101 or -3.19999999999999995e74 < d2 < -4.1e43Initial program 80.4%
associate--l+80.4%
+-commutative80.4%
distribute-rgt-out--82.6%
distribute-lft-out--84.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 68.5%
if -8.5000000000000001e101 < d2 < -3.19999999999999995e74 or -4.1e43 < d2 < 2.29999999999999985e-242Initial program 95.8%
associate--l+95.8%
+-commutative95.8%
distribute-rgt-out--97.9%
distribute-lft-out--97.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 43.9%
mul-1-neg43.9%
distribute-lft-neg-in43.9%
*-commutative43.9%
Simplified43.9%
if 2.29999999999999985e-242 < d2 Initial program 91.2%
associate--l+91.2%
+-commutative91.2%
distribute-rgt-out--92.1%
distribute-lft-out--92.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 28.6%
Final simplification41.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 3.8e-87)
t_0
(if (<= d4 1.22e-48)
(* d1 (- d2 d1))
(if (<= d4 3.3e+73) t_0 (* d1 (+ d4 d2)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= 3.8e-87) {
tmp = t_0;
} else if (d4 <= 1.22e-48) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.3e+73) {
tmp = t_0;
} 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 - d3)
if (d4 <= 3.8d-87) then
tmp = t_0
else if (d4 <= 1.22d-48) then
tmp = d1 * (d2 - d1)
else if (d4 <= 3.3d+73) then
tmp = t_0
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 - d3);
double tmp;
if (d4 <= 3.8e-87) {
tmp = t_0;
} else if (d4 <= 1.22e-48) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.3e+73) {
tmp = t_0;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= 3.8e-87: tmp = t_0 elif d4 <= 1.22e-48: tmp = d1 * (d2 - d1) elif d4 <= 3.3e+73: tmp = t_0 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 3.8e-87) tmp = t_0; elseif (d4 <= 1.22e-48) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 3.3e+73) tmp = t_0; else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 3.8e-87) tmp = t_0; elseif (d4 <= 1.22e-48) tmp = d1 * (d2 - d1); elseif (d4 <= 3.3e+73) tmp = t_0; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 3.8e-87], t$95$0, If[LessEqual[d4, 1.22e-48], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 3.3e+73], t$95$0, N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 3.8 \cdot 10^{-87}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.22 \cdot 10^{-48}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 3.3 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 3.8e-87 or 1.21999999999999993e-48 < d4 < 3.3000000000000003e73Initial program 90.9%
associate--l+90.9%
+-commutative90.9%
distribute-rgt-out--91.8%
distribute-lft-out--92.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 81.1%
Taylor expanded in d4 around 0 65.7%
if 3.8e-87 < d4 < 1.21999999999999993e-48Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
distribute-rgt-out--100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 100.0%
Taylor expanded in d4 around 0 89.6%
if 3.3000000000000003e73 < d4 Initial program 89.5%
associate--l+89.5%
+-commutative89.5%
distribute-rgt-out--94.7%
distribute-lft-out--94.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.2%
Taylor expanded in d1 around 0 82.2%
Final simplification69.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -3.1e+136) (* d1 (- d4 d3)) (if (<= d3 5.5e+62) (* d1 (- (+ d4 d2) d1)) (* d1 (- d4 (+ d1 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -3.1e+136) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 5.5e+62) {
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 <= (-3.1d+136)) then
tmp = d1 * (d4 - d3)
else if (d3 <= 5.5d+62) 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 <= -3.1e+136) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 5.5e+62) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -3.1e+136: tmp = d1 * (d4 - d3) elif d3 <= 5.5e+62: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -3.1e+136) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d3 <= 5.5e+62) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); 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 (d3 <= -3.1e+136) tmp = d1 * (d4 - d3); elseif (d3 <= 5.5e+62) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -3.1e+136], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 5.5e+62], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3.1 \cdot 10^{+136}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d3 \leq 5.5 \cdot 10^{+62}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d3 < -3.09999999999999983e136Initial program 90.2%
associate--l+90.2%
+-commutative90.2%
distribute-rgt-out--92.7%
distribute-lft-out--95.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 97.6%
Taylor expanded in d2 around 0 90.4%
if -3.09999999999999983e136 < d3 < 5.4999999999999997e62Initial program 92.5%
associate--l+92.5%
+-commutative92.5%
distribute-rgt-out--94.4%
distribute-lft-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.2%
if 5.4999999999999997e62 < d3 Initial program 87.0%
associate--l+87.0%
+-commutative87.0%
distribute-rgt-out--87.0%
distribute-lft-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 89.3%
Final simplification93.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6.4e+78) (* d1 (- d2 d3)) (if (<= d2 -1.52e-261) (* d1 (- (- d1) d3)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6.4e+78) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.52e-261) {
tmp = d1 * (-d1 - d3);
} 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 (d2 <= (-6.4d+78)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-1.52d-261)) then
tmp = d1 * (-d1 - d3)
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 (d2 <= -6.4e+78) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.52e-261) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6.4e+78: tmp = d1 * (d2 - d3) elif d2 <= -1.52e-261: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6.4e+78) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -1.52e-261) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -6.4e+78) tmp = d1 * (d2 - d3); elseif (d2 <= -1.52e-261) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6.4e+78], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -1.52e-261], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6.4 \cdot 10^{+78}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.52 \cdot 10^{-261}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -6.39999999999999989e78Initial program 82.9%
associate--l+82.9%
+-commutative82.9%
distribute-rgt-out--85.1%
distribute-lft-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.9%
Taylor expanded in d4 around 0 79.5%
if -6.39999999999999989e78 < d2 < -1.5200000000000001e-261Initial program 92.6%
associate--l+92.6%
+-commutative92.6%
distribute-rgt-out--95.6%
distribute-lft-out--95.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 93.0%
Taylor expanded in d4 around 0 71.9%
mul-1-neg71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
Simplified71.9%
if -1.5200000000000001e-261 < d2 Initial program 92.9%
associate--l+92.9%
+-commutative92.9%
distribute-rgt-out--93.6%
distribute-lft-out--94.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 84.3%
Taylor expanded in d2 around 0 61.9%
Final simplification67.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.4e+136) (not (<= d3 7.8e+96))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.4e+136) || !(d3 <= 7.8e+96)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-2.4d+136)) .or. (.not. (d3 <= 7.8d+96))) then
tmp = d1 * -d3
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.4e+136) || !(d3 <= 7.8e+96)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.4e+136) or not (d3 <= 7.8e+96): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.4e+136) || !(d3 <= 7.8e+96)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.4e+136) || ~((d3 <= 7.8e+96))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.4e+136], N[Not[LessEqual[d3, 7.8e+96]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.4 \cdot 10^{+136} \lor \neg \left(d3 \leq 7.8 \cdot 10^{+96}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -2.4e136 or 7.8e96 < d3 Initial program 88.7%
associate--l+88.7%
+-commutative88.7%
distribute-rgt-out--89.9%
distribute-lft-out--92.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 83.5%
mul-1-neg83.5%
distribute-lft-neg-in83.5%
*-commutative83.5%
Simplified83.5%
if -2.4e136 < d3 < 7.8e96Initial program 92.2%
associate--l+92.2%
+-commutative92.2%
distribute-rgt-out--94.0%
distribute-lft-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.2%
Taylor expanded in d1 around 0 70.8%
Final simplification75.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.55e+87) (* d1 (- d2 d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.55e+87) {
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.55d+87)) 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.55e+87) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.55e+87: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.55e+87) 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.55e+87) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.55e+87], 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.55 \cdot 10^{+87}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -1.55e87Initial program 81.8%
associate--l+81.8%
+-commutative81.8%
distribute-rgt-out--84.1%
distribute-lft-out--86.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.5%
Taylor expanded in d4 around 0 82.6%
if -1.55e87 < d2 Initial program 92.9%
associate--l+92.9%
+-commutative92.9%
distribute-rgt-out--94.3%
distribute-lft-out--94.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.8%
Final simplification82.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.1e+56) (* d1 (- (+ d4 d2) d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.1e+56) {
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 <= (-3.1d+56)) 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 <= -3.1e+56) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.1e+56: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.1e+56) 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 <= -3.1e+56) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.1e+56], 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 -3.1 \cdot 10^{+56}:\\
\;\;\;\;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 < -3.10000000000000005e56Initial program 82.7%
associate--l+82.7%
+-commutative82.7%
distribute-rgt-out--84.5%
distribute-lft-out--86.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.7%
if -3.10000000000000005e56 < d2 Initial program 93.4%
associate--l+93.4%
+-commutative93.4%
distribute-rgt-out--94.9%
distribute-lft-out--95.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.4%
Final simplification85.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.6e-26) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.6e-26) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-4.6d-26)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.6e-26) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.6e-26: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.6e-26) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -4.6e-26) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4.6e-26], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.6 \cdot 10^{-26}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -4.60000000000000018e-26Initial program 85.3%
associate--l+85.3%
+-commutative85.3%
distribute-rgt-out--86.7%
distribute-lft-out--88.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 53.5%
if -4.60000000000000018e-26 < d2 Initial program 93.1%
associate--l+93.1%
+-commutative93.1%
distribute-rgt-out--94.7%
distribute-lft-out--95.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 30.4%
Final simplification36.5%
(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 91.0%
associate--l+91.0%
+-commutative91.0%
distribute-rgt-out--92.6%
distribute-lft-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 30.7%
Final simplification30.7%
(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 2023334
(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)))