
(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 15 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.3%
associate--l+86.3%
distribute-lft-out--89.0%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d4 2.7e-27)
t_0
(if (<= d4 10000000000000.0)
(* d1 (- d3))
(if (<= d4 2.05e+40) t_0 (* d1 (+ d2 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= 2.7e-27) {
tmp = t_0;
} else if (d4 <= 10000000000000.0) {
tmp = d1 * -d3;
} else if (d4 <= 2.05e+40) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d4 <= 2.7d-27) then
tmp = t_0
else if (d4 <= 10000000000000.0d0) then
tmp = d1 * -d3
else if (d4 <= 2.05d+40) then
tmp = t_0
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= 2.7e-27) {
tmp = t_0;
} else if (d4 <= 10000000000000.0) {
tmp = d1 * -d3;
} else if (d4 <= 2.05e+40) {
tmp = t_0;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= 2.7e-27: tmp = t_0 elif d4 <= 10000000000000.0: tmp = d1 * -d3 elif d4 <= 2.05e+40: tmp = t_0 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= 2.7e-27) tmp = t_0; elseif (d4 <= 10000000000000.0) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 2.05e+40) tmp = t_0; else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d4 <= 2.7e-27) tmp = t_0; elseif (d4 <= 10000000000000.0) tmp = d1 * -d3; elseif (d4 <= 2.05e+40) tmp = t_0; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 2.7e-27], t$95$0, If[LessEqual[d4, 10000000000000.0], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 2.05e+40], t$95$0, N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq 2.7 \cdot 10^{-27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 10000000000000:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 2.05 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 2.69999999999999989e-27 or 1e13 < d4 < 2.0500000000000001e40Initial program 88.7%
associate--l+88.7%
distribute-lft-out--91.4%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 83.4%
+-commutative83.4%
associate--r+83.4%
Simplified83.4%
Taylor expanded in d3 around 0 57.5%
if 2.69999999999999989e-27 < d4 < 1e13Initial program 73.3%
associate--l+73.3%
distribute-lft-out--80.0%
distribute-rgt-out--80.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 41.4%
mul-1-neg41.4%
distribute-rgt-neg-out41.4%
Simplified41.4%
if 2.0500000000000001e40 < d4 Initial program 81.8%
associate--l+81.8%
distribute-lft-out--83.6%
distribute-rgt-out--92.7%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in92.7%
fma-define96.4%
*-commutative96.4%
Applied egg-rr96.4%
Taylor expanded in d1 around 0 90.9%
Taylor expanded in d3 around 0 83.8%
+-commutative83.8%
Simplified83.8%
Final simplification62.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 1.12e-218)
t_0
(if (<= d4 1.55e-160)
(* d1 (- d2 d1))
(if (<= d4 1.12e+30) t_0 (* d1 (+ d2 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= 1.12e-218) {
tmp = t_0;
} else if (d4 <= 1.55e-160) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.12e+30) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d4 <= 1.12d-218) then
tmp = t_0
else if (d4 <= 1.55d-160) then
tmp = d1 * (d2 - d1)
else if (d4 <= 1.12d+30) then
tmp = t_0
else
tmp = d1 * (d2 + d4)
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 <= 1.12e-218) {
tmp = t_0;
} else if (d4 <= 1.55e-160) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.12e+30) {
tmp = t_0;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= 1.12e-218: tmp = t_0 elif d4 <= 1.55e-160: tmp = d1 * (d2 - d1) elif d4 <= 1.12e+30: tmp = t_0 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 1.12e-218) tmp = t_0; elseif (d4 <= 1.55e-160) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 1.12e+30) tmp = t_0; else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 1.12e-218) tmp = t_0; elseif (d4 <= 1.55e-160) tmp = d1 * (d2 - d1); elseif (d4 <= 1.12e+30) tmp = t_0; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 1.12e-218], t$95$0, If[LessEqual[d4, 1.55e-160], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.12e+30], t$95$0, N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 1.12 \cdot 10^{-218}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.55 \cdot 10^{-160}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 1.12 \cdot 10^{+30}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.11999999999999996e-218 or 1.55e-160 < d4 < 1.12e30Initial program 87.4%
associate--l+87.4%
distribute-lft-out--90.5%
distribute-rgt-out--91.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.4%
+-commutative82.4%
associate--r+82.4%
Simplified82.4%
Taylor expanded in d1 around 0 61.7%
if 1.11999999999999996e-218 < d4 < 1.55e-160Initial program 88.9%
associate--l+88.9%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
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 d3 around 0 78.6%
if 1.12e30 < d4 Initial program 82.1%
associate--l+82.1%
distribute-lft-out--83.9%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in92.9%
fma-define96.4%
*-commutative96.4%
Applied egg-rr96.4%
Taylor expanded in d1 around 0 91.1%
Taylor expanded in d3 around 0 82.4%
+-commutative82.4%
Simplified82.4%
Final simplification66.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -8.2e+99)
(* d1 d2)
(if (<= d2 -7e-69)
(* d1 (- d1))
(if (<= d2 -5.8e-245) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.2e+99) {
tmp = d1 * d2;
} else if (d2 <= -7e-69) {
tmp = d1 * -d1;
} else if (d2 <= -5.8e-245) {
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 <= (-8.2d+99)) then
tmp = d1 * d2
else if (d2 <= (-7d-69)) then
tmp = d1 * -d1
else if (d2 <= (-5.8d-245)) 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 <= -8.2e+99) {
tmp = d1 * d2;
} else if (d2 <= -7e-69) {
tmp = d1 * -d1;
} else if (d2 <= -5.8e-245) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8.2e+99: tmp = d1 * d2 elif d2 <= -7e-69: tmp = d1 * -d1 elif d2 <= -5.8e-245: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8.2e+99) tmp = Float64(d1 * d2); elseif (d2 <= -7e-69) tmp = Float64(d1 * Float64(-d1)); elseif (d2 <= -5.8e-245) 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 <= -8.2e+99) tmp = d1 * d2; elseif (d2 <= -7e-69) tmp = d1 * -d1; elseif (d2 <= -5.8e-245) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8.2e+99], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -7e-69], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d2, -5.8e-245], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8.2 \cdot 10^{+99}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -7 \cdot 10^{-69}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d2 \leq -5.8 \cdot 10^{-245}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -8.19999999999999959e99Initial program 80.8%
associate--l+80.8%
distribute-lft-out--88.0%
distribute-rgt-out--90.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 73.7%
if -8.19999999999999959e99 < d2 < -7.0000000000000003e-69Initial program 86.6%
associate--l+86.6%
distribute-lft-out--88.8%
distribute-rgt-out--91.0%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 76.4%
+-commutative76.4%
associate--r+76.4%
Simplified76.4%
Taylor expanded in d1 around inf 42.0%
neg-mul-142.0%
Simplified42.0%
if -7.0000000000000003e-69 < d2 < -5.7999999999999999e-245Initial program 97.2%
associate--l+97.2%
distribute-lft-out--97.2%
distribute-rgt-out--97.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 43.2%
mul-1-neg43.2%
distribute-rgt-neg-out43.2%
Simplified43.2%
if -5.7999999999999999e-245 < d2 Initial program 85.0%
associate--l+85.0%
distribute-lft-out--87.2%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 39.9%
Final simplification46.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.35e+17) (not (<= d3 7.8e+32))) (* d1 (- (+ d2 d4) d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.35e+17) || !(d3 <= 7.8e+32)) {
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 <= (-1.35d+17)) .or. (.not. (d3 <= 7.8d+32))) 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 <= -1.35e+17) || !(d3 <= 7.8e+32)) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.35e+17) or not (d3 <= 7.8e+32): tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.35e+17) || !(d3 <= 7.8e+32)) 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 <= -1.35e+17) || ~((d3 <= 7.8e+32))) 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, -1.35e+17], N[Not[LessEqual[d3, 7.8e+32]], $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 -1.35 \cdot 10^{+17} \lor \neg \left(d3 \leq 7.8 \cdot 10^{+32}\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 < -1.35e17 or 7.7999999999999998e32 < d3 Initial program 79.6%
associate--l+79.6%
distribute-lft-out--84.7%
distribute-rgt-out--87.3%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in87.3%
fma-define93.2%
*-commutative93.2%
Applied egg-rr93.2%
Taylor expanded in d1 around 0 91.9%
if -1.35e17 < d3 < 7.7999999999999998e32Initial program 92.0%
associate--l+92.0%
distribute-lft-out--92.7%
distribute-rgt-out--95.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 98.6%
Final simplification95.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -2.1e+91) (* d1 (- d2 d3)) (if (<= d3 4.8e+53) (* d1 (- (+ d2 d4) d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -2.1e+91) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 4.8e+53) {
tmp = d1 * ((d2 + 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 (d3 <= (-2.1d+91)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 4.8d+53) then
tmp = d1 * ((d2 + 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 (d3 <= -2.1e+91) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 4.8e+53) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -2.1e+91: tmp = d1 * (d2 - d3) elif d3 <= 4.8e+53: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -2.1e+91) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 4.8e+53) tmp = Float64(d1 * Float64(Float64(d2 + 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 (d3 <= -2.1e+91) tmp = d1 * (d2 - d3); elseif (d3 <= 4.8e+53) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -2.1e+91], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 4.8e+53], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.1 \cdot 10^{+91}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 4.8 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -2.10000000000000008e91Initial program 74.1%
associate--l+74.1%
distribute-lft-out--81.0%
distribute-rgt-out--82.7%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 88.6%
+-commutative88.6%
associate--r+88.6%
Simplified88.6%
Taylor expanded in d1 around 0 80.1%
if -2.10000000000000008e91 < d3 < 4.8e53Initial program 90.8%
associate--l+90.8%
distribute-lft-out--91.5%
distribute-rgt-out--95.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.5%
if 4.8e53 < d3 Initial program 86.7%
associate--l+86.7%
distribute-lft-out--91.1%
distribute-rgt-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in91.1%
fma-define97.8%
*-commutative97.8%
Applied egg-rr97.8%
Taylor expanded in d1 around 0 92.0%
Taylor expanded in d2 around 0 75.1%
Final simplification89.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -1.45e+90) (* d1 (- (- d2 d3) d1)) (if (<= d3 2.5e+34) (* d1 (- (+ d2 d4) d1)) (* d1 (- (+ d2 d4) d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -1.45e+90) {
tmp = d1 * ((d2 - d3) - d1);
} else if (d3 <= 2.5e+34) {
tmp = d1 * ((d2 + d4) - 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 (d3 <= (-1.45d+90)) then
tmp = d1 * ((d2 - d3) - d1)
else if (d3 <= 2.5d+34) then
tmp = d1 * ((d2 + d4) - 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 (d3 <= -1.45e+90) {
tmp = d1 * ((d2 - d3) - d1);
} else if (d3 <= 2.5e+34) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -1.45e+90: tmp = d1 * ((d2 - d3) - d1) elif d3 <= 2.5e+34: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -1.45e+90) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); elseif (d3 <= 2.5e+34) tmp = Float64(d1 * Float64(Float64(d2 + d4) - 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 (d3 <= -1.45e+90) tmp = d1 * ((d2 - d3) - d1); elseif (d3 <= 2.5e+34) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -1.45e+90], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 2.5e+34], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.45 \cdot 10^{+90}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{elif}\;d3 \leq 2.5 \cdot 10^{+34}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d3 < -1.4500000000000001e90Initial program 74.1%
associate--l+74.1%
distribute-lft-out--81.0%
distribute-rgt-out--82.7%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 88.6%
+-commutative88.6%
associate--r+88.6%
Simplified88.6%
if -1.4500000000000001e90 < d3 < 2.4999999999999999e34Initial program 91.9%
associate--l+91.9%
distribute-lft-out--92.6%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.4%
if 2.4999999999999999e34 < d3 Initial program 83.6%
associate--l+83.6%
distribute-lft-out--87.7%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in91.8%
fma-define98.0%
*-commutative98.0%
Applied egg-rr98.0%
Taylor expanded in d1 around 0 92.7%
Final simplification94.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.5e+61) (* d1 (- d2 d3)) (if (<= d2 -5e-163) (* d1 (- (- d1) d3)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.5e+61) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -5e-163) {
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 <= (-1.5d+61)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-5d-163)) 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 <= -1.5e+61) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -5e-163) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.5e+61: tmp = d1 * (d2 - d3) elif d2 <= -5e-163: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.5e+61) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -5e-163) 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 <= -1.5e+61) tmp = d1 * (d2 - d3); elseif (d2 <= -5e-163) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.5e+61], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -5e-163], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -5 \cdot 10^{-163}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.5e61Initial program 78.5%
associate--l+78.5%
distribute-lft-out--85.6%
distribute-rgt-out--89.2%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 87.5%
+-commutative87.5%
associate--r+87.5%
Simplified87.5%
Taylor expanded in d1 around 0 84.5%
if -1.5e61 < d2 < -4.99999999999999977e-163Initial program 94.3%
associate--l+94.3%
distribute-lft-out--94.3%
distribute-rgt-out--94.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 78.1%
+-commutative78.1%
associate--r+78.1%
Simplified78.1%
Taylor expanded in d2 around 0 72.7%
associate-*r*72.7%
neg-mul-172.7%
+-commutative72.7%
*-commutative72.7%
+-commutative72.7%
Simplified72.7%
if -4.99999999999999977e-163 < d2 Initial program 86.4%
associate--l+86.4%
distribute-lft-out--88.4%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in91.8%
fma-define95.9%
*-commutative95.9%
Applied egg-rr95.9%
Taylor expanded in d1 around 0 83.0%
Taylor expanded in d2 around 0 65.9%
Final simplification71.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.8e+136) (not (<= d3 6.5e+147))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+136) || !(d3 <= 6.5e+147)) {
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 <= (-1.8d+136)) .or. (.not. (d3 <= 6.5d+147))) 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 <= -1.8e+136) || !(d3 <= 6.5e+147)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.8e+136) or not (d3 <= 6.5e+147): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.8e+136) || !(d3 <= 6.5e+147)) 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 <= -1.8e+136) || ~((d3 <= 6.5e+147))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.8e+136], N[Not[LessEqual[d3, 6.5e+147]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.8 \cdot 10^{+136} \lor \neg \left(d3 \leq 6.5 \cdot 10^{+147}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.80000000000000003e136 or 6.5e147 < d3 Initial program 81.1%
associate--l+81.1%
distribute-lft-out--86.5%
distribute-rgt-out--87.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 74.3%
mul-1-neg74.3%
distribute-rgt-neg-out74.3%
Simplified74.3%
if -1.80000000000000003e136 < d3 < 6.5e147Initial program 88.4%
associate--l+88.4%
distribute-lft-out--90.1%
distribute-rgt-out--93.4%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in93.4%
fma-define96.1%
*-commutative96.1%
Applied egg-rr96.1%
Taylor expanded in d1 around 0 77.5%
Taylor expanded in d3 around 0 70.5%
+-commutative70.5%
Simplified70.5%
Final simplification71.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.76e+65) (* d1 (- d2 d3)) (if (<= d2 -9.5e-15) (* d1 (- d2 d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.76e+65) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -9.5e-15) {
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 (d2 <= (-1.76d+65)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-9.5d-15)) 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 (d2 <= -1.76e+65) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -9.5e-15) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.76e+65: tmp = d1 * (d2 - d3) elif d2 <= -9.5e-15: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.76e+65) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -9.5e-15) 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 (d2 <= -1.76e+65) tmp = d1 * (d2 - d3); elseif (d2 <= -9.5e-15) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.76e+65], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -9.5e-15], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.76 \cdot 10^{+65}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -9.5 \cdot 10^{-15}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.76000000000000001e65Initial program 76.8%
associate--l+76.8%
distribute-lft-out--84.6%
distribute-rgt-out--88.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 88.4%
+-commutative88.4%
associate--r+88.4%
Simplified88.4%
Taylor expanded in d1 around 0 86.5%
if -1.76000000000000001e65 < d2 < -9.5000000000000005e-15Initial program 94.7%
associate--l+94.7%
distribute-lft-out--94.7%
distribute-rgt-out--94.7%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 84.7%
+-commutative84.7%
associate--r+84.7%
Simplified84.7%
Taylor expanded in d3 around 0 69.1%
if -9.5000000000000005e-15 < d2 Initial program 88.1%
associate--l+88.1%
distribute-lft-out--89.7%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
distribute-rgt-in92.4%
fma-define96.8%
*-commutative96.8%
Applied egg-rr96.8%
Taylor expanded in d1 around 0 80.8%
Taylor expanded in d2 around 0 66.7%
Final simplification70.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.36e+100) (* d1 d2) (if (<= d2 -4.3e-163) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.36e+100) {
tmp = d1 * d2;
} else if (d2 <= -4.3e-163) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.36d+100)) then
tmp = d1 * d2
else if (d2 <= (-4.3d-163)) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.36e+100) {
tmp = d1 * d2;
} else if (d2 <= -4.3e-163) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.36e+100: tmp = d1 * d2 elif d2 <= -4.3e-163: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.36e+100) tmp = Float64(d1 * d2); elseif (d2 <= -4.3e-163) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.36e+100) tmp = d1 * d2; elseif (d2 <= -4.3e-163) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.36e+100], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -4.3e-163], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.36 \cdot 10^{+100}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4.3 \cdot 10^{-163}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.35999999999999994e100Initial program 80.8%
associate--l+80.8%
distribute-lft-out--88.0%
distribute-rgt-out--90.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 73.7%
if -1.35999999999999994e100 < d2 < -4.30000000000000009e-163Initial program 89.5%
associate--l+89.5%
distribute-lft-out--91.0%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 78.3%
+-commutative78.3%
associate--r+78.3%
Simplified78.3%
Taylor expanded in d1 around inf 42.3%
neg-mul-142.3%
Simplified42.3%
if -4.30000000000000009e-163 < d2 Initial program 86.4%
associate--l+86.4%
distribute-lft-out--88.4%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 40.3%
Final simplification46.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.4e-12) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.4e-12) {
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 (d2 <= (-5.4d-12)) 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 (d2 <= -5.4e-12) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.4e-12: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.4e-12) 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 (d2 <= -5.4e-12) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.4e-12], 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}\;d2 \leq -5.4 \cdot 10^{-12}:\\
\;\;\;\;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 d2 < -5.39999999999999961e-12Initial program 81.3%
associate--l+81.3%
distribute-lft-out--87.1%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.2%
+-commutative87.2%
associate--r+87.2%
Simplified87.2%
if -5.39999999999999961e-12 < d2 Initial program 88.2%
associate--l+88.2%
distribute-lft-out--89.8%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 84.9%
+-commutative84.9%
associate--r+84.9%
Simplified84.9%
Final simplification85.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6e+62) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e+62) {
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 (d2 <= (-6d+62)) 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 (d2 <= -6e+62) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6e+62: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6e+62) 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 (d2 <= -6e+62) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6e+62], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6 \cdot 10^{+62}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -6e62Initial program 77.7%
associate--l+77.7%
distribute-lft-out--85.1%
distribute-rgt-out--88.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 88.8%
+-commutative88.8%
associate--r+88.8%
Simplified88.8%
Taylor expanded in d1 around 0 85.7%
if -6e62 < d2 Initial program 88.6%
associate--l+88.6%
distribute-lft-out--90.1%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.3%
Taylor expanded in d2 around 0 61.9%
Final simplification66.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.4e-12) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.4e-12) {
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 <= (-5.4d-12)) 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 <= -5.4e-12) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.4e-12: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.4e-12) 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 <= -5.4e-12) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.4e-12], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.4 \cdot 10^{-12}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.39999999999999961e-12Initial program 81.3%
associate--l+81.3%
distribute-lft-out--87.1%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 55.5%
if -5.39999999999999961e-12 < d2 Initial program 88.2%
associate--l+88.2%
distribute-lft-out--89.8%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 40.0%
Final simplification44.2%
(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.3%
associate--l+86.3%
distribute-lft-out--89.0%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.1%
Final simplification31.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024039
(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)))