
(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 14 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--88.7%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d4 -8.1e-224)
(* d1 d2)
(if (<= d4 9.2e-125)
t_0
(if (<= d4 1.45e-80)
(* d1 d2)
(if (<= d4 2.6e-67)
t_0
(if (<= d4 1.95e+54)
(- (* d1 d1))
(if (<= d4 4e+110) t_0 (* d1 d4)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d4 <= -8.1e-224) {
tmp = d1 * d2;
} else if (d4 <= 9.2e-125) {
tmp = t_0;
} else if (d4 <= 1.45e-80) {
tmp = d1 * d2;
} else if (d4 <= 2.6e-67) {
tmp = t_0;
} else if (d4 <= 1.95e+54) {
tmp = -(d1 * d1);
} else if (d4 <= 4e+110) {
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 (d4 <= (-8.1d-224)) then
tmp = d1 * d2
else if (d4 <= 9.2d-125) then
tmp = t_0
else if (d4 <= 1.45d-80) then
tmp = d1 * d2
else if (d4 <= 2.6d-67) then
tmp = t_0
else if (d4 <= 1.95d+54) then
tmp = -(d1 * d1)
else if (d4 <= 4d+110) 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 (d4 <= -8.1e-224) {
tmp = d1 * d2;
} else if (d4 <= 9.2e-125) {
tmp = t_0;
} else if (d4 <= 1.45e-80) {
tmp = d1 * d2;
} else if (d4 <= 2.6e-67) {
tmp = t_0;
} else if (d4 <= 1.95e+54) {
tmp = -(d1 * d1);
} else if (d4 <= 4e+110) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d4 <= -8.1e-224: tmp = d1 * d2 elif d4 <= 9.2e-125: tmp = t_0 elif d4 <= 1.45e-80: tmp = d1 * d2 elif d4 <= 2.6e-67: tmp = t_0 elif d4 <= 1.95e+54: tmp = -(d1 * d1) elif d4 <= 4e+110: 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 (d4 <= -8.1e-224) tmp = Float64(d1 * d2); elseif (d4 <= 9.2e-125) tmp = t_0; elseif (d4 <= 1.45e-80) tmp = Float64(d1 * d2); elseif (d4 <= 2.6e-67) tmp = t_0; elseif (d4 <= 1.95e+54) tmp = Float64(-Float64(d1 * d1)); elseif (d4 <= 4e+110) 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 (d4 <= -8.1e-224) tmp = d1 * d2; elseif (d4 <= 9.2e-125) tmp = t_0; elseif (d4 <= 1.45e-80) tmp = d1 * d2; elseif (d4 <= 2.6e-67) tmp = t_0; elseif (d4 <= 1.95e+54) tmp = -(d1 * d1); elseif (d4 <= 4e+110) 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[d4, -8.1e-224], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 9.2e-125], t$95$0, If[LessEqual[d4, 1.45e-80], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.6e-67], t$95$0, If[LessEqual[d4, 1.95e+54], (-N[(d1 * d1), $MachinePrecision]), If[LessEqual[d4, 4e+110], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d4 \leq -8.1 \cdot 10^{-224}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 9.2 \cdot 10^{-125}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.45 \cdot 10^{-80}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.6 \cdot 10^{-67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.95 \cdot 10^{+54}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{elif}\;d4 \leq 4 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -8.1000000000000004e-224 or 9.1999999999999996e-125 < d4 < 1.44999999999999999e-80Initial program 85.0%
associate--l+85.0%
distribute-lft-out--88.3%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.8%
if -8.1000000000000004e-224 < d4 < 9.1999999999999996e-125 or 1.44999999999999999e-80 < d4 < 2.5999999999999999e-67 or 1.9500000000000001e54 < d4 < 4.0000000000000001e110Initial program 95.8%
associate--l+95.8%
distribute-lft-out--95.8%
distribute-rgt-out--95.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around inf 48.1%
mul-1-neg48.1%
distribute-rgt-neg-out48.1%
Simplified48.1%
if 2.5999999999999999e-67 < d4 < 1.9500000000000001e54Initial program 73.8%
associate--l+73.8%
distribute-lft-out--78.2%
distribute-rgt-out--86.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 76.4%
Taylor expanded in d1 around inf 54.2%
neg-mul-154.2%
Simplified54.2%
if 4.0000000000000001e110 < d4 Initial program 82.9%
associate--l+82.9%
distribute-lft-out--82.9%
distribute-rgt-out--95.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 64.4%
Final simplification43.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (- d3) d1))))
(if (<= d4 -1.05e-223)
(* d1 (- d2 d1))
(if (<= d4 3.3e-176)
t_0
(if (<= d4 5.1e-85)
(* d1 (- d2 d3))
(if (<= d4 3.7e+96) t_0 (* d1 (- d4 d3))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (-d3 - d1);
double tmp;
if (d4 <= -1.05e-223) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.3e-176) {
tmp = t_0;
} else if (d4 <= 5.1e-85) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 3.7e+96) {
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 * (-d3 - d1)
if (d4 <= (-1.05d-223)) then
tmp = d1 * (d2 - d1)
else if (d4 <= 3.3d-176) then
tmp = t_0
else if (d4 <= 5.1d-85) then
tmp = d1 * (d2 - d3)
else if (d4 <= 3.7d+96) 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 * (-d3 - d1);
double tmp;
if (d4 <= -1.05e-223) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.3e-176) {
tmp = t_0;
} else if (d4 <= 5.1e-85) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 3.7e+96) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (-d3 - d1) tmp = 0 if d4 <= -1.05e-223: tmp = d1 * (d2 - d1) elif d4 <= 3.3e-176: tmp = t_0 elif d4 <= 5.1e-85: tmp = d1 * (d2 - d3) elif d4 <= 3.7e+96: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(-d3) - d1)) tmp = 0.0 if (d4 <= -1.05e-223) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 3.3e-176) tmp = t_0; elseif (d4 <= 5.1e-85) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 3.7e+96) 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 * (-d3 - d1); tmp = 0.0; if (d4 <= -1.05e-223) tmp = d1 * (d2 - d1); elseif (d4 <= 3.3e-176) tmp = t_0; elseif (d4 <= 5.1e-85) tmp = d1 * (d2 - d3); elseif (d4 <= 3.7e+96) 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[((-d3) - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -1.05e-223], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 3.3e-176], t$95$0, If[LessEqual[d4, 5.1e-85], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 3.7e+96], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{if}\;d4 \leq -1.05 \cdot 10^{-223}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 3.3 \cdot 10^{-176}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 5.1 \cdot 10^{-85}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 3.7 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.04999999999999991e-223Initial program 85.3%
associate--l+85.3%
distribute-lft-out--87.2%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 73.9%
+-commutative73.9%
associate--r+73.9%
Simplified73.9%
Taylor expanded in d3 around 0 54.3%
if -1.04999999999999991e-223 < d4 < 3.30000000000000013e-176 or 5.1000000000000002e-85 < d4 < 3.69999999999999991e96Initial program 90.8%
associate--l+90.8%
distribute-lft-out--92.1%
distribute-rgt-out--94.7%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 97.5%
+-commutative97.5%
associate--r+97.5%
Simplified97.5%
Taylor expanded in d2 around 0 73.1%
associate-*r*73.1%
neg-mul-173.1%
Simplified73.1%
if 3.30000000000000013e-176 < d4 < 5.1000000000000002e-85Initial program 84.6%
associate--l+84.6%
distribute-lft-out--92.3%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d1 around 0 89.0%
if 3.69999999999999991e96 < d4 Initial program 84.1%
associate--l+84.1%
distribute-lft-out--84.1%
distribute-rgt-out--95.5%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in95.5%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in d1 around 0 95.5%
Taylor expanded in d2 around 0 75.6%
Final simplification67.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -8.4e-125)
(* d1 (- d2 d1))
(if (or (<= d4 6e-65) (and (not (<= d4 2.3e+52)) (<= d4 6.2e+143)))
(* d1 (- d2 d3))
(* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -8.4e-125) {
tmp = d1 * (d2 - d1);
} else if ((d4 <= 6e-65) || (!(d4 <= 2.3e+52) && (d4 <= 6.2e+143))) {
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 <= (-8.4d-125)) then
tmp = d1 * (d2 - d1)
else if ((d4 <= 6d-65) .or. (.not. (d4 <= 2.3d+52)) .and. (d4 <= 6.2d+143)) 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 <= -8.4e-125) {
tmp = d1 * (d2 - d1);
} else if ((d4 <= 6e-65) || (!(d4 <= 2.3e+52) && (d4 <= 6.2e+143))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -8.4e-125: tmp = d1 * (d2 - d1) elif (d4 <= 6e-65) or (not (d4 <= 2.3e+52) and (d4 <= 6.2e+143)): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -8.4e-125) tmp = Float64(d1 * Float64(d2 - d1)); elseif ((d4 <= 6e-65) || (!(d4 <= 2.3e+52) && (d4 <= 6.2e+143))) 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 <= -8.4e-125) tmp = d1 * (d2 - d1); elseif ((d4 <= 6e-65) || (~((d4 <= 2.3e+52)) && (d4 <= 6.2e+143))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -8.4e-125], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d4, 6e-65], And[N[Not[LessEqual[d4, 2.3e+52]], $MachinePrecision], LessEqual[d4, 6.2e+143]]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -8.4 \cdot 10^{-125}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 6 \cdot 10^{-65} \lor \neg \left(d4 \leq 2.3 \cdot 10^{+52}\right) \land d4 \leq 6.2 \cdot 10^{+143}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < -8.3999999999999999e-125Initial program 83.3%
associate--l+83.3%
distribute-lft-out--85.4%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 70.4%
+-commutative70.4%
associate--r+70.4%
Simplified70.4%
Taylor expanded in d3 around 0 56.2%
if -8.3999999999999999e-125 < d4 < 5.99999999999999996e-65 or 2.3e52 < d4 < 6.1999999999999998e143Initial program 93.4%
associate--l+93.4%
distribute-lft-out--95.3%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 96.4%
+-commutative96.4%
associate--r+96.4%
Simplified96.4%
Taylor expanded in d1 around 0 80.4%
if 5.99999999999999996e-65 < d4 < 2.3e52 or 6.1999999999999998e143 < d4 Initial program 79.2%
associate--l+79.2%
distribute-lft-out--81.1%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 88.1%
Taylor expanded in d2 around 0 74.4%
Final simplification70.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (+ d2 d4))))
(if (<= d1 -9e+51)
t_0
(if (<= d1 1.72e-103)
t_1
(if (<= d1 4.2e-78)
(* d1 (- d3))
(if (<= d1 3600000000000.0) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d1 <= -9e+51) {
tmp = t_0;
} else if (d1 <= 1.72e-103) {
tmp = t_1;
} else if (d1 <= 4.2e-78) {
tmp = d1 * -d3;
} else if (d1 <= 3600000000000.0) {
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 * (d2 - d1)
t_1 = d1 * (d2 + d4)
if (d1 <= (-9d+51)) then
tmp = t_0
else if (d1 <= 1.72d-103) then
tmp = t_1
else if (d1 <= 4.2d-78) then
tmp = d1 * -d3
else if (d1 <= 3600000000000.0d0) 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 * (d2 - d1);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d1 <= -9e+51) {
tmp = t_0;
} else if (d1 <= 1.72e-103) {
tmp = t_1;
} else if (d1 <= 4.2e-78) {
tmp = d1 * -d3;
} else if (d1 <= 3600000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (d2 + d4) tmp = 0 if d1 <= -9e+51: tmp = t_0 elif d1 <= 1.72e-103: tmp = t_1 elif d1 <= 4.2e-78: tmp = d1 * -d3 elif d1 <= 3600000000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d1 <= -9e+51) tmp = t_0; elseif (d1 <= 1.72e-103) tmp = t_1; elseif (d1 <= 4.2e-78) tmp = Float64(d1 * Float64(-d3)); elseif (d1 <= 3600000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (d2 + d4); tmp = 0.0; if (d1 <= -9e+51) tmp = t_0; elseif (d1 <= 1.72e-103) tmp = t_1; elseif (d1 <= 4.2e-78) tmp = d1 * -d3; elseif (d1 <= 3600000000000.0) tmp = t_1; else tmp = t_0; 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 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -9e+51], t$95$0, If[LessEqual[d1, 1.72e-103], t$95$1, If[LessEqual[d1, 4.2e-78], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d1, 3600000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d1 \leq -9 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 1.72 \cdot 10^{-103}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d1 \leq 4.2 \cdot 10^{-78}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d1 \leq 3600000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -8.9999999999999999e51 or 3.6e12 < d1 Initial program 67.3%
associate--l+67.3%
distribute-lft-out--72.1%
distribute-rgt-out--86.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.9%
+-commutative87.9%
associate--r+87.9%
Simplified87.9%
Taylor expanded in d3 around 0 75.8%
if -8.9999999999999999e51 < d1 < 1.72000000000000004e-103 or 4.2000000000000001e-78 < d1 < 3.6e12Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 71.0%
Taylor expanded in d1 around 0 67.9%
if 1.72000000000000004e-103 < d1 < 4.2000000000000001e-78Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 87.8%
mul-1-neg87.8%
distribute-rgt-neg-out87.8%
Simplified87.8%
Final simplification71.7%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- d2 d3))))
(if (<= d1 -3.5e+93)
t_0
(if (<= d1 -2.45e-197)
t_1
(if (<= d1 9.5e-104) (* d1 (+ d2 d4)) (if (<= d1 1.85e+36) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d1 <= -3.5e+93) {
tmp = t_0;
} else if (d1 <= -2.45e-197) {
tmp = t_1;
} else if (d1 <= 9.5e-104) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 1.85e+36) {
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 * (d2 - d1)
t_1 = d1 * (d2 - d3)
if (d1 <= (-3.5d+93)) then
tmp = t_0
else if (d1 <= (-2.45d-197)) then
tmp = t_1
else if (d1 <= 9.5d-104) then
tmp = d1 * (d2 + d4)
else if (d1 <= 1.85d+36) 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 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d1 <= -3.5e+93) {
tmp = t_0;
} else if (d1 <= -2.45e-197) {
tmp = t_1;
} else if (d1 <= 9.5e-104) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 1.85e+36) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (d2 - d3) tmp = 0 if d1 <= -3.5e+93: tmp = t_0 elif d1 <= -2.45e-197: tmp = t_1 elif d1 <= 9.5e-104: tmp = d1 * (d2 + d4) elif d1 <= 1.85e+36: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d1 <= -3.5e+93) tmp = t_0; elseif (d1 <= -2.45e-197) tmp = t_1; elseif (d1 <= 9.5e-104) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d1 <= 1.85e+36) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (d2 - d3); tmp = 0.0; if (d1 <= -3.5e+93) tmp = t_0; elseif (d1 <= -2.45e-197) tmp = t_1; elseif (d1 <= 9.5e-104) tmp = d1 * (d2 + d4); elseif (d1 <= 1.85e+36) tmp = t_1; else tmp = t_0; 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]}, If[LessEqual[d1, -3.5e+93], t$95$0, If[LessEqual[d1, -2.45e-197], t$95$1, If[LessEqual[d1, 9.5e-104], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.85e+36], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d1 \leq -3.5 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq -2.45 \cdot 10^{-197}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d1 \leq 9.5 \cdot 10^{-104}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d1 \leq 1.85 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -3.49999999999999998e93 or 1.85000000000000014e36 < d1 Initial program 63.8%
associate--l+63.8%
distribute-lft-out--69.1%
distribute-rgt-out--85.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 86.6%
+-commutative86.6%
associate--r+86.6%
Simplified86.6%
Taylor expanded in d3 around 0 80.3%
if -3.49999999999999998e93 < d1 < -2.4500000000000001e-197 or 9.5000000000000002e-104 < d1 < 1.85000000000000014e36Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 72.2%
+-commutative72.2%
associate--r+72.2%
Simplified72.2%
Taylor expanded in d1 around 0 64.1%
if -2.4500000000000001e-197 < d1 < 9.5000000000000002e-104Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 75.4%
Taylor expanded in d1 around 0 75.4%
Final simplification73.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (- (* d1 d1))))
(if (<= d4 -2e-269)
(* d1 d2)
(if (<= d4 2.4e-173)
t_0
(if (<= d4 2.45e-85) (* d1 d2) (if (<= d4 1.4e+100) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d1);
double tmp;
if (d4 <= -2e-269) {
tmp = d1 * d2;
} else if (d4 <= 2.4e-173) {
tmp = t_0;
} else if (d4 <= 2.45e-85) {
tmp = d1 * d2;
} else if (d4 <= 1.4e+100) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = -(d1 * d1)
if (d4 <= (-2d-269)) then
tmp = d1 * d2
else if (d4 <= 2.4d-173) then
tmp = t_0
else if (d4 <= 2.45d-85) then
tmp = d1 * d2
else if (d4 <= 1.4d+100) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d1);
double tmp;
if (d4 <= -2e-269) {
tmp = d1 * d2;
} else if (d4 <= 2.4e-173) {
tmp = t_0;
} else if (d4 <= 2.45e-85) {
tmp = d1 * d2;
} else if (d4 <= 1.4e+100) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = -(d1 * d1) tmp = 0 if d4 <= -2e-269: tmp = d1 * d2 elif d4 <= 2.4e-173: tmp = t_0 elif d4 <= 2.45e-85: tmp = d1 * d2 elif d4 <= 1.4e+100: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d1)) tmp = 0.0 if (d4 <= -2e-269) tmp = Float64(d1 * d2); elseif (d4 <= 2.4e-173) tmp = t_0; elseif (d4 <= 2.45e-85) tmp = Float64(d1 * d2); elseif (d4 <= 1.4e+100) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = -(d1 * d1); tmp = 0.0; if (d4 <= -2e-269) tmp = d1 * d2; elseif (d4 <= 2.4e-173) tmp = t_0; elseif (d4 <= 2.45e-85) tmp = d1 * d2; elseif (d4 <= 1.4e+100) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = (-N[(d1 * d1), $MachinePrecision])}, If[LessEqual[d4, -2e-269], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.4e-173], t$95$0, If[LessEqual[d4, 2.45e-85], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.4e+100], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -d1 \cdot d1\\
\mathbf{if}\;d4 \leq -2 \cdot 10^{-269}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.4 \cdot 10^{-173}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 2.45 \cdot 10^{-85}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.4 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.9999999999999999e-269 or 2.40000000000000017e-173 < d4 < 2.45000000000000007e-85Initial program 86.1%
associate--l+86.1%
distribute-lft-out--88.9%
distribute-rgt-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 34.4%
if -1.9999999999999999e-269 < d4 < 2.40000000000000017e-173 or 2.45000000000000007e-85 < d4 < 1.3999999999999999e100Initial program 89.6%
associate--l+89.6%
distribute-lft-out--91.1%
distribute-rgt-out--94.0%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 65.7%
Taylor expanded in d1 around inf 40.8%
neg-mul-140.8%
Simplified40.8%
if 1.3999999999999999e100 < d4 Initial program 84.1%
associate--l+84.1%
distribute-lft-out--84.1%
distribute-rgt-out--95.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 64.6%
Final simplification41.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -6e-126)
(* d1 (- d2 d1))
(if (<= d4 5.3e-65)
(* d1 (- d2 d3))
(if (<= d4 7.8e+53) (* d1 (- d4 d1)) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -6e-126) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5.3e-65) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 7.8e+53) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= (-6d-126)) then
tmp = d1 * (d2 - d1)
else if (d4 <= 5.3d-65) then
tmp = d1 * (d2 - d3)
else if (d4 <= 7.8d+53) then
tmp = d1 * (d4 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -6e-126) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 5.3e-65) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 7.8e+53) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -6e-126: tmp = d1 * (d2 - d1) elif d4 <= 5.3e-65: tmp = d1 * (d2 - d3) elif d4 <= 7.8e+53: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -6e-126) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 5.3e-65) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 7.8e+53) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -6e-126) tmp = d1 * (d2 - d1); elseif (d4 <= 5.3e-65) tmp = d1 * (d2 - d3); elseif (d4 <= 7.8e+53) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -6e-126], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 5.3e-65], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 7.8e+53], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -6 \cdot 10^{-126}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 5.3 \cdot 10^{-65}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 7.8 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -6.0000000000000003e-126Initial program 83.3%
associate--l+83.3%
distribute-lft-out--85.4%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 70.4%
+-commutative70.4%
associate--r+70.4%
Simplified70.4%
Taylor expanded in d3 around 0 56.2%
if -6.0000000000000003e-126 < d4 < 5.30000000000000037e-65Initial program 94.3%
associate--l+94.3%
distribute-lft-out--96.6%
distribute-rgt-out--96.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 99.9%
+-commutative99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in d1 around 0 81.5%
if 5.30000000000000037e-65 < d4 < 7.79999999999999952e53Initial program 73.8%
associate--l+73.8%
distribute-lft-out--78.2%
distribute-rgt-out--86.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 76.4%
Taylor expanded in d2 around 0 62.3%
if 7.79999999999999952e53 < d4 Initial program 85.7%
associate--l+85.7%
distribute-lft-out--85.7%
distribute-rgt-out--95.9%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in95.9%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in d1 around 0 94.1%
Taylor expanded in d2 around 0 72.2%
Final simplification68.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -0.02) (not (<= d3 5.7e+37))) (* d1 (- (+ d2 d4) d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -0.02) || !(d3 <= 5.7e+37)) {
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 <= (-0.02d0)) .or. (.not. (d3 <= 5.7d+37))) 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 <= -0.02) || !(d3 <= 5.7e+37)) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -0.02) or not (d3 <= 5.7e+37): tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -0.02) || !(d3 <= 5.7e+37)) 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 <= -0.02) || ~((d3 <= 5.7e+37))) 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, -0.02], N[Not[LessEqual[d3, 5.7e+37]], $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 -0.02 \lor \neg \left(d3 \leq 5.7 \cdot 10^{+37}\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 < -0.0200000000000000004 or 5.7000000000000001e37 < d3 Initial program 86.4%
associate--l+86.4%
distribute-lft-out--90.7%
distribute-rgt-out--95.7%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in95.7%
fma-define96.6%
Applied egg-rr96.6%
Taylor expanded in d1 around 0 95.1%
if -0.0200000000000000004 < d3 < 5.7000000000000001e37Initial program 86.9%
associate--l+86.9%
distribute-lft-out--86.9%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.9%
Final simplification96.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -2.45e+106) (* d1 (- d4 d3)) (if (<= d3 4e+122) (* d1 (- (+ d2 d4) d1)) (* d1 (- d2 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -2.45e+106) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 4e+122) {
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 <= (-2.45d+106)) then
tmp = d1 * (d4 - d3)
else if (d3 <= 4d+122) 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 <= -2.45e+106) {
tmp = d1 * (d4 - d3);
} else if (d3 <= 4e+122) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d2 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -2.45e+106: tmp = d1 * (d4 - d3) elif d3 <= 4e+122: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d2 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -2.45e+106) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d3 <= 4e+122) 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 <= -2.45e+106) tmp = d1 * (d4 - d3); elseif (d3 <= 4e+122) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * (d2 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -2.45e+106], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 4e+122], 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 -2.45 \cdot 10^{+106}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d3 \leq 4 \cdot 10^{+122}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\end{array}
\end{array}
if d3 < -2.44999999999999999e106Initial program 79.0%
associate--l+79.0%
distribute-lft-out--86.0%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in93.0%
fma-define95.3%
Applied egg-rr95.3%
Taylor expanded in d1 around 0 95.3%
Taylor expanded in d2 around 0 73.1%
if -2.44999999999999999e106 < d3 < 4.00000000000000006e122Initial program 86.5%
associate--l+86.5%
distribute-lft-out--87.1%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.6%
if 4.00000000000000006e122 < d3 Initial program 97.1%
associate--l+97.1%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 94.6%
+-commutative94.6%
associate--r+94.6%
Simplified94.6%
Taylor expanded in d1 around 0 94.6%
Final simplification90.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -3.8e+162) (not (<= d3 8e+132))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.8e+162) || !(d3 <= 8e+132)) {
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 <= (-3.8d+162)) .or. (.not. (d3 <= 8d+132))) 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 <= -3.8e+162) || !(d3 <= 8e+132)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3.8e+162) or not (d3 <= 8e+132): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3.8e+162) || !(d3 <= 8e+132)) 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 <= -3.8e+162) || ~((d3 <= 8e+132))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -3.8e+162], N[Not[LessEqual[d3, 8e+132]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3.8 \cdot 10^{+162} \lor \neg \left(d3 \leq 8 \cdot 10^{+132}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -3.80000000000000024e162 or 7.99999999999999993e132 < d3 Initial program 89.0%
associate--l+89.0%
distribute-lft-out--90.6%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 83.7%
mul-1-neg83.7%
distribute-rgt-neg-out83.7%
Simplified83.7%
if -3.80000000000000024e162 < d3 < 7.99999999999999993e132Initial program 85.9%
associate--l+85.9%
distribute-lft-out--88.0%
distribute-rgt-out--94.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.5%
Taylor expanded in d1 around 0 65.1%
Final simplification69.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.4e-37) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.4e-37) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 2.4d-37) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d4 - d3) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.4e-37) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.4e-37: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.4e-37) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 2.4e-37) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.4e-37], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.4 \cdot 10^{-37}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 2.39999999999999991e-37Initial program 88.9%
associate--l+88.9%
distribute-lft-out--91.0%
distribute-rgt-out--95.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.9%
+-commutative84.9%
associate--r+84.9%
Simplified84.9%
if 2.39999999999999991e-37 < d4 Initial program 80.6%
associate--l+80.6%
distribute-lft-out--82.1%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.9%
+-commutative79.9%
associate--r+79.9%
Simplified79.9%
Final simplification83.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.6e-10) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.6e-10) {
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.6d-10) 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.6e-10) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.6e-10: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.6e-10) 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.6e-10) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.6e-10], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.6 \cdot 10^{-10}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.59999999999999981e-10Initial program 88.6%
associate--l+88.6%
distribute-lft-out--90.7%
distribute-rgt-out--94.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.8%
if 2.59999999999999981e-10 < d4 Initial program 80.9%
associate--l+80.9%
distribute-lft-out--82.5%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 49.4%
Final simplification36.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 86.7%
associate--l+86.7%
distribute-lft-out--88.7%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 30.6%
Final simplification30.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 2024084
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))