
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d3) (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d2 - d3) + (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d3) + (d4 - d1)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 89.1%
associate--l+89.1%
distribute-lft-out--90.2%
distribute-rgt-out--94.1%
distribute-lft-out100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))) (t_1 (* d1 (- d2 d1))))
(if (<= d3 -3.8e+135)
t_0
(if (<= d3 -6e-282)
t_1
(if (<= d3 -9.6e-303) (* d1 d4) (if (<= d3 4.5e+74) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double t_1 = d1 * (d2 - d1);
double tmp;
if (d3 <= -3.8e+135) {
tmp = t_0;
} else if (d3 <= -6e-282) {
tmp = t_1;
} else if (d3 <= -9.6e-303) {
tmp = d1 * d4;
} else if (d3 <= 4.5e+74) {
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 - d3)
t_1 = d1 * (d2 - d1)
if (d3 <= (-3.8d+135)) then
tmp = t_0
else if (d3 <= (-6d-282)) then
tmp = t_1
else if (d3 <= (-9.6d-303)) then
tmp = d1 * d4
else if (d3 <= 4.5d+74) 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 - d3);
double t_1 = d1 * (d2 - d1);
double tmp;
if (d3 <= -3.8e+135) {
tmp = t_0;
} else if (d3 <= -6e-282) {
tmp = t_1;
} else if (d3 <= -9.6e-303) {
tmp = d1 * d4;
} else if (d3 <= 4.5e+74) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) t_1 = d1 * (d2 - d1) tmp = 0 if d3 <= -3.8e+135: tmp = t_0 elif d3 <= -6e-282: tmp = t_1 elif d3 <= -9.6e-303: tmp = d1 * d4 elif d3 <= 4.5e+74: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) t_1 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -3.8e+135) tmp = t_0; elseif (d3 <= -6e-282) tmp = t_1; elseif (d3 <= -9.6e-303) tmp = Float64(d1 * d4); elseif (d3 <= 4.5e+74) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); t_1 = d1 * (d2 - d1); tmp = 0.0; if (d3 <= -3.8e+135) tmp = t_0; elseif (d3 <= -6e-282) tmp = t_1; elseif (d3 <= -9.6e-303) tmp = d1 * d4; elseif (d3 <= 4.5e+74) 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 - d3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -3.8e+135], t$95$0, If[LessEqual[d3, -6e-282], t$95$1, If[LessEqual[d3, -9.6e-303], N[(d1 * d4), $MachinePrecision], If[LessEqual[d3, 4.5e+74], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -3.8 \cdot 10^{+135}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -6 \cdot 10^{-282}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq -9.6 \cdot 10^{-303}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{elif}\;d3 \leq 4.5 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -3.8000000000000001e135 or 4.5e74 < d3 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--93.8%
*-commutative93.8%
Simplified93.8%
Taylor expanded in d1 around 0 97.3%
Taylor expanded in d4 around 0 92.6%
if -3.8000000000000001e135 < d3 < -6.0000000000000001e-282 or -9.6000000000000004e-303 < d3 < 4.5e74Initial program 88.2%
associate--l+88.2%
distribute-lft-out--88.2%
distribute-rgt-out--94.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.6%
Taylor expanded in d4 around 0 68.1%
if -6.0000000000000001e-282 < d3 < -9.6000000000000004e-303Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 67.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))) (t_1 (* d1 (- d2 d1))))
(if (<= d3 -3e+136)
t_0
(if (<= d3 -1.8e-291)
t_1
(if (<= d3 -9.6e-303) (* d1 d4) (if (<= d3 3.9e+131) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double t_1 = d1 * (d2 - d1);
double tmp;
if (d3 <= -3e+136) {
tmp = t_0;
} else if (d3 <= -1.8e-291) {
tmp = t_1;
} else if (d3 <= -9.6e-303) {
tmp = d1 * d4;
} else if (d3 <= 3.9e+131) {
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 * (d2 - d1)
if (d3 <= (-3d+136)) then
tmp = t_0
else if (d3 <= (-1.8d-291)) then
tmp = t_1
else if (d3 <= (-9.6d-303)) then
tmp = d1 * d4
else if (d3 <= 3.9d+131) 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 * (d2 - d1);
double tmp;
if (d3 <= -3e+136) {
tmp = t_0;
} else if (d3 <= -1.8e-291) {
tmp = t_1;
} else if (d3 <= -9.6e-303) {
tmp = d1 * d4;
} else if (d3 <= 3.9e+131) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 t_1 = d1 * (d2 - d1) tmp = 0 if d3 <= -3e+136: tmp = t_0 elif d3 <= -1.8e-291: tmp = t_1 elif d3 <= -9.6e-303: tmp = d1 * d4 elif d3 <= 3.9e+131: 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(d2 - d1)) tmp = 0.0 if (d3 <= -3e+136) tmp = t_0; elseif (d3 <= -1.8e-291) tmp = t_1; elseif (d3 <= -9.6e-303) tmp = Float64(d1 * d4); elseif (d3 <= 3.9e+131) 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 * (d2 - d1); tmp = 0.0; if (d3 <= -3e+136) tmp = t_0; elseif (d3 <= -1.8e-291) tmp = t_1; elseif (d3 <= -9.6e-303) tmp = d1 * d4; elseif (d3 <= 3.9e+131) 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[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -3e+136], t$95$0, If[LessEqual[d3, -1.8e-291], t$95$1, If[LessEqual[d3, -9.6e-303], N[(d1 * d4), $MachinePrecision], If[LessEqual[d3, 3.9e+131], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
t_1 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -3 \cdot 10^{+136}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -1.8 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq -9.6 \cdot 10^{-303}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{elif}\;d3 \leq 3.9 \cdot 10^{+131}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -2.99999999999999979e136 or 3.9e131 < d3 Initial program 89.2%
associate--l+89.2%
distribute-lft-out--93.2%
*-commutative93.2%
Simplified93.2%
Taylor expanded in d3 around inf 85.0%
associate-*r*85.0%
neg-mul-185.0%
Simplified85.0%
if -2.99999999999999979e136 < d3 < -1.79999999999999983e-291 or -9.6000000000000004e-303 < d3 < 3.9e131Initial program 88.6%
associate--l+88.6%
distribute-lft-out--88.6%
distribute-rgt-out--94.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.6%
Taylor expanded in d4 around 0 66.4%
if -1.79999999999999983e-291 < d3 < -9.6000000000000004e-303Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 67.5%
Final simplification71.8%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 3.1e-133)
(* d1 (- d2 d1))
(if (<= d4 4e+69)
(* d1 (- d2 d3))
(if (<= d4 9.6e+148) (* d1 (- d4 d1)) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.1e-133) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 4e+69) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 9.6e+148) {
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 <= 3.1d-133) then
tmp = d1 * (d2 - d1)
else if (d4 <= 4d+69) then
tmp = d1 * (d2 - d3)
else if (d4 <= 9.6d+148) 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 <= 3.1e-133) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 4e+69) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 9.6e+148) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.1e-133: tmp = d1 * (d2 - d1) elif d4 <= 4e+69: tmp = d1 * (d2 - d3) elif d4 <= 9.6e+148: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.1e-133) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 4e+69) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 9.6e+148) 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 <= 3.1e-133) tmp = d1 * (d2 - d1); elseif (d4 <= 4e+69) tmp = d1 * (d2 - d3); elseif (d4 <= 9.6e+148) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.1e-133], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 4e+69], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 9.6e+148], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.1 \cdot 10^{-133}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 4 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 9.6 \cdot 10^{+148}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 3.10000000000000016e-133Initial program 89.2%
associate--l+89.2%
distribute-lft-out--90.4%
distribute-rgt-out--94.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.4%
Taylor expanded in d4 around 0 60.3%
if 3.10000000000000016e-133 < d4 < 4.0000000000000003e69Initial program 90.2%
associate--l+90.2%
distribute-lft-out--90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in d1 around 0 84.9%
Taylor expanded in d4 around 0 75.7%
if 4.0000000000000003e69 < d4 < 9.59999999999999979e148Initial program 81.3%
associate--l+81.3%
distribute-lft-out--81.3%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.9%
Taylor expanded in d2 around 0 69.1%
if 9.59999999999999979e148 < d4 Initial program 90.6%
associate--l+90.6%
distribute-lft-out--93.8%
*-commutative93.8%
Simplified93.8%
Taylor expanded in d1 around 0 96.8%
Taylor expanded in d2 around 0 91.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -7.6e-109)
(* d1 d2)
(if (<= d4 1e-132)
(* d1 (- d1))
(if (<= d4 2.35e+64) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -7.6e-109) {
tmp = d1 * d2;
} else if (d4 <= 1e-132) {
tmp = d1 * -d1;
} else if (d4 <= 2.35e+64) {
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 (d4 <= (-7.6d-109)) then
tmp = d1 * d2
else if (d4 <= 1d-132) then
tmp = d1 * -d1
else if (d4 <= 2.35d+64) 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 (d4 <= -7.6e-109) {
tmp = d1 * d2;
} else if (d4 <= 1e-132) {
tmp = d1 * -d1;
} else if (d4 <= 2.35e+64) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -7.6e-109: tmp = d1 * d2 elif d4 <= 1e-132: tmp = d1 * -d1 elif d4 <= 2.35e+64: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -7.6e-109) tmp = Float64(d1 * d2); elseif (d4 <= 1e-132) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 2.35e+64) 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 (d4 <= -7.6e-109) tmp = d1 * d2; elseif (d4 <= 1e-132) tmp = d1 * -d1; elseif (d4 <= 2.35e+64) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -7.6e-109], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1e-132], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 2.35e+64], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -7.6 \cdot 10^{-109}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 10^{-132}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 2.35 \cdot 10^{+64}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -7.60000000000000003e-109Initial program 85.9%
associate--l+85.9%
distribute-lft-out--87.0%
*-commutative87.0%
Simplified87.0%
Taylor expanded in d2 around inf 24.4%
if -7.60000000000000003e-109 < d4 < 9.9999999999999999e-133Initial program 93.0%
associate--l+93.0%
distribute-lft-out--94.4%
distribute-rgt-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 47.5%
neg-mul-147.5%
Simplified47.5%
if 9.9999999999999999e-133 < d4 < 2.35000000000000015e64Initial program 91.8%
associate--l+91.8%
distribute-lft-out--91.8%
*-commutative91.8%
Simplified91.8%
Taylor expanded in d3 around inf 37.7%
associate-*r*37.7%
neg-mul-137.7%
Simplified37.7%
if 2.35000000000000015e64 < d4 Initial program 86.0%
associate--l+86.0%
distribute-lft-out--88.0%
*-commutative88.0%
Simplified88.0%
Taylor expanded in d4 around inf 61.9%
Final simplification40.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -3e+134) (not (<= d3 2.1e+68))) (* d1 (- (+ d2 d4) d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3e+134) || !(d3 <= 2.1e+68)) {
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 <= (-3d+134)) .or. (.not. (d3 <= 2.1d+68))) 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 <= -3e+134) || !(d3 <= 2.1e+68)) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3e+134) or not (d3 <= 2.1e+68): tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3e+134) || !(d3 <= 2.1e+68)) 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 <= -3e+134) || ~((d3 <= 2.1e+68))) 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, -3e+134], N[Not[LessEqual[d3, 2.1e+68]], $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 -3 \cdot 10^{+134} \lor \neg \left(d3 \leq 2.1 \cdot 10^{+68}\right):\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -2.99999999999999997e134 or 2.10000000000000001e68 < d3 Initial program 88.9%
associate--l+88.9%
distribute-lft-out--92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in d1 around 0 97.3%
if -2.99999999999999997e134 < d3 < 2.10000000000000001e68Initial program 89.1%
associate--l+89.1%
distribute-lft-out--89.1%
distribute-rgt-out--94.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.7%
Final simplification97.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -5e+140) (* d1 (- d2 d3)) (if (<= d3 7.2e+126) (* d1 (- (+ d2 d4) d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -5e+140) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 7.2e+126) {
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 <= (-5d+140)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 7.2d+126) 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 <= -5e+140) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 7.2e+126) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -5e+140: tmp = d1 * (d2 - d3) elif d3 <= 7.2e+126: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -5e+140) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 7.2e+126) 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 <= -5e+140) tmp = d1 * (d2 - d3); elseif (d3 <= 7.2e+126) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -5e+140], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 7.2e+126], 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 -5 \cdot 10^{+140}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 7.2 \cdot 10^{+126}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -5.00000000000000008e140Initial program 85.0%
associate--l+85.0%
distribute-lft-out--92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in d1 around 0 95.0%
Taylor expanded in d4 around 0 95.0%
if -5.00000000000000008e140 < d3 < 7.2000000000000001e126Initial program 88.9%
associate--l+88.9%
distribute-lft-out--88.9%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.7%
if 7.2000000000000001e126 < d3 Initial program 94.3%
associate--l+94.3%
distribute-lft-out--94.3%
*-commutative94.3%
Simplified94.3%
Taylor expanded in d1 around 0 100.0%
Taylor expanded in d2 around 0 94.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.1e-133) (* d1 (- d2 d1)) (if (<= d4 3.6e+69) (* d1 (- d2 d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.1e-133) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.6e+69) {
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.1d-133) then
tmp = d1 * (d2 - d1)
else if (d4 <= 3.6d+69) 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.1e-133) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 3.6e+69) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.1e-133: tmp = d1 * (d2 - d1) elif d4 <= 3.6e+69: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.1e-133) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 3.6e+69) 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.1e-133) tmp = d1 * (d2 - d1); elseif (d4 <= 3.6e+69) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.1e-133], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 3.6e+69], 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.1 \cdot 10^{-133}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 3.6 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 3.10000000000000016e-133Initial program 89.2%
associate--l+89.2%
distribute-lft-out--90.4%
distribute-rgt-out--94.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.4%
Taylor expanded in d4 around 0 60.3%
if 3.10000000000000016e-133 < d4 < 3.6000000000000003e69Initial program 90.2%
associate--l+90.2%
distribute-lft-out--90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in d1 around 0 84.9%
Taylor expanded in d4 around 0 75.7%
if 3.6000000000000003e69 < d4 Initial program 87.5%
associate--l+87.5%
distribute-lft-out--89.6%
distribute-rgt-out--97.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.9%
Taylor expanded in d2 around 0 79.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -8.2e+100) (* d1 d2) (if (<= d2 5.1e-84) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.2e+100) {
tmp = d1 * d2;
} else if (d2 <= 5.1e-84) {
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 <= (-8.2d+100)) then
tmp = d1 * d2
else if (d2 <= 5.1d-84) 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 <= -8.2e+100) {
tmp = d1 * d2;
} else if (d2 <= 5.1e-84) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8.2e+100: tmp = d1 * d2 elif d2 <= 5.1e-84: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8.2e+100) tmp = Float64(d1 * d2); elseif (d2 <= 5.1e-84) 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 <= -8.2e+100) tmp = d1 * d2; elseif (d2 <= 5.1e-84) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8.2e+100], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 5.1e-84], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8.2 \cdot 10^{+100}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 5.1 \cdot 10^{-84}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -8.2000000000000006e100Initial program 88.9%
associate--l+88.9%
distribute-lft-out--93.3%
*-commutative93.3%
Simplified93.3%
Taylor expanded in d2 around inf 67.2%
if -8.2000000000000006e100 < d2 < 5.0999999999999996e-84Initial program 89.3%
associate--l+89.3%
distribute-lft-out--90.1%
distribute-rgt-out--94.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 47.3%
neg-mul-147.3%
Simplified47.3%
if 5.0999999999999996e-84 < d2 Initial program 88.8%
associate--l+88.8%
distribute-lft-out--88.8%
*-commutative88.8%
Simplified88.8%
Taylor expanded in d4 around inf 32.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.26e+69) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.26e+69) {
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 <= 1.26d+69) 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 <= 1.26e+69) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.26e+69: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.26e+69) 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 <= 1.26e+69) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.26e+69], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.26 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.26000000000000005e69Initial program 89.4%
associate--l+89.4%
distribute-lft-out--90.4%
*-commutative90.4%
Simplified90.4%
Taylor expanded in d2 around inf 30.7%
if 1.26000000000000005e69 < d4 Initial program 87.5%
associate--l+87.5%
distribute-lft-out--89.6%
*-commutative89.6%
Simplified89.6%
Taylor expanded in d4 around inf 64.4%
(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 89.1%
associate--l+89.1%
distribute-lft-out--90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in d2 around inf 27.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
double code(double d1, double d2, double d3, double d4) {
return 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 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
def code(d1, d2, d3, d4): return d1 * d1
function code(d1, d2, d3, d4) return Float64(d1 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d1
\end{array}
Initial program 89.1%
associate--l+89.1%
distribute-lft-out--90.2%
distribute-rgt-out--94.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 34.3%
neg-mul-134.3%
Simplified34.3%
neg-sub034.3%
sub-neg34.3%
add-sqr-sqrt17.2%
sqrt-unprod20.4%
sqr-neg20.4%
sqrt-unprod3.1%
add-sqr-sqrt5.8%
Applied egg-rr5.8%
+-lft-identity5.8%
Simplified5.8%
(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 2024111
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))