
(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 (- (+ d4 (- d2 d3)) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - 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 * ((d4 + (d2 - d3)) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - d1);
}
def code(d1, d2, d3, d4): return d1 * ((d4 + (d2 - d3)) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 + Float64(d2 - d3)) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 + (d2 - d3)) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 + \left(d2 - d3\right)\right) - d1\right)
\end{array}
Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--90.6%
distribute-lft-out91.4%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 2.4e-123)
(* d1 d2)
(if (<= d4 5.6e+39)
(* d1 (- d1))
(if (<= d4 9.2e+83) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.4e-123) {
tmp = d1 * d2;
} else if (d4 <= 5.6e+39) {
tmp = d1 * -d1;
} else if (d4 <= 9.2e+83) {
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 <= 2.4d-123) then
tmp = d1 * d2
else if (d4 <= 5.6d+39) then
tmp = d1 * -d1
else if (d4 <= 9.2d+83) 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 <= 2.4e-123) {
tmp = d1 * d2;
} else if (d4 <= 5.6e+39) {
tmp = d1 * -d1;
} else if (d4 <= 9.2e+83) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.4e-123: tmp = d1 * d2 elif d4 <= 5.6e+39: tmp = d1 * -d1 elif d4 <= 9.2e+83: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.4e-123) tmp = Float64(d1 * d2); elseif (d4 <= 5.6e+39) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 9.2e+83) 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 <= 2.4e-123) tmp = d1 * d2; elseif (d4 <= 5.6e+39) tmp = d1 * -d1; elseif (d4 <= 9.2e+83) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.4e-123], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 5.6e+39], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 9.2e+83], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.4 \cdot 10^{-123}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5.6 \cdot 10^{+39}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 9.2 \cdot 10^{+83}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.4e-123Initial program 90.3%
+-commutative90.3%
*-commutative90.3%
distribute-lft-out--90.9%
distribute-lft-out90.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 39.9%
if 2.4e-123 < d4 < 5.60000000000000003e39Initial program 90.6%
+-commutative90.6%
*-commutative90.6%
distribute-lft-out--90.6%
distribute-lft-out90.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 50.6%
neg-mul-150.6%
Simplified50.6%
if 5.60000000000000003e39 < d4 < 9.1999999999999998e83Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 34.3%
mul-1-neg34.3%
distribute-rgt-neg-out34.3%
Simplified34.3%
if 9.1999999999999998e83 < d4 Initial program 88.3%
+-commutative88.3%
*-commutative88.3%
distribute-lft-out--88.3%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 78.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -1.25e+159) (not (<= d1 2.1e+155))) (* d1 (- (- d1) d3)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -1.25e+159) || !(d1 <= 2.1e+155)) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * ((d4 + 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 ((d1 <= (-1.25d+159)) .or. (.not. (d1 <= 2.1d+155))) then
tmp = d1 * (-d1 - d3)
else
tmp = d1 * ((d4 + d2) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -1.25e+159) || !(d1 <= 2.1e+155)) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -1.25e+159) or not (d1 <= 2.1e+155): tmp = d1 * (-d1 - d3) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -1.25e+159) || !(d1 <= 2.1e+155)) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -1.25e+159) || ~((d1 <= 2.1e+155))) tmp = d1 * (-d1 - d3); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -1.25e+159], N[Not[LessEqual[d1, 2.1e+155]], $MachinePrecision]], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.25 \cdot 10^{+159} \lor \neg \left(d1 \leq 2.1 \cdot 10^{+155}\right):\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -1.25000000000000001e159 or 2.1e155 < d1 Initial program 62.5%
+-commutative62.5%
*-commutative62.5%
distribute-lft-out--66.1%
distribute-lft-out67.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
associate-*r*100.0%
mul-1-neg100.0%
Simplified100.0%
if -1.25000000000000001e159 < d1 < 2.1e155Initial program 97.5%
+-commutative97.5%
*-commutative97.5%
distribute-lft-out--97.5%
distribute-lft-out98.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 87.8%
Final simplification90.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.16e+207) (not (<= d1 3.1e+159))) (* d1 (- d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.16e+207) || !(d1 <= 3.1e+159)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d1 <= (-2.16d+207)) .or. (.not. (d1 <= 3.1d+159))) then
tmp = d1 * -d1
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.16e+207) || !(d1 <= 3.1e+159)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.16e+207) or not (d1 <= 3.1e+159): tmp = d1 * -d1 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.16e+207) || !(d1 <= 3.1e+159)) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -2.16e+207) || ~((d1 <= 3.1e+159))) tmp = d1 * -d1; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.16e+207], N[Not[LessEqual[d1, 3.1e+159]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.16 \cdot 10^{+207} \lor \neg \left(d1 \leq 3.1 \cdot 10^{+159}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d1 < -2.16000000000000003e207 or 3.0999999999999998e159 < d1 Initial program 62.0%
+-commutative62.0%
*-commutative62.0%
distribute-lft-out--66.0%
distribute-lft-out68.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 94.0%
neg-mul-194.0%
Simplified94.0%
if -2.16000000000000003e207 < d1 < 3.0999999999999998e159Initial program 96.6%
+-commutative96.6%
*-commutative96.6%
distribute-lft-out--96.6%
distribute-lft-out97.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 87.2%
Taylor expanded in d3 around 0 69.1%
+-commutative69.1%
Simplified69.1%
Final simplification74.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.8e+39) (* d1 (- d2 d1)) (if (<= d4 7.8e+83) (* d1 (- d2 d3)) (* d1 (+ d4 d2)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.8e+39) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 7.8e+83) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 4.8d+39) then
tmp = d1 * (d2 - d1)
else if (d4 <= 7.8d+83) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.8e+39) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 7.8e+83) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.8e+39: tmp = d1 * (d2 - d1) elif d4 <= 7.8e+83: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.8e+39) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 7.8e+83) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.8e+39) tmp = d1 * (d2 - d1); elseif (d4 <= 7.8e+83) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.8e+39], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 7.8e+83], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.8 \cdot 10^{+39}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 7.8 \cdot 10^{+83}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 4.8000000000000002e39Initial program 90.3%
+-commutative90.3%
*-commutative90.3%
distribute-lft-out--90.9%
distribute-lft-out90.9%
distribute-lft-out--100.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 66.1%
if 4.8000000000000002e39 < d4 < 7.8000000000000003e83Initial program 89.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.8%
Taylor expanded in d4 around 0 80.9%
if 7.8000000000000003e83 < d4 Initial program 88.3%
+-commutative88.3%
*-commutative88.3%
distribute-lft-out--88.3%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.0%
Taylor expanded in d3 around 0 83.8%
+-commutative83.8%
Simplified83.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.52e-124) (* d1 d2) (if (<= d4 1.8e+75) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.52e-124) {
tmp = d1 * d2;
} else if (d4 <= 1.8e+75) {
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 (d4 <= 1.52d-124) then
tmp = d1 * d2
else if (d4 <= 1.8d+75) 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 (d4 <= 1.52e-124) {
tmp = d1 * d2;
} else if (d4 <= 1.8e+75) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.52e-124: tmp = d1 * d2 elif d4 <= 1.8e+75: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.52e-124) tmp = Float64(d1 * d2); elseif (d4 <= 1.8e+75) 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 (d4 <= 1.52e-124) tmp = d1 * d2; elseif (d4 <= 1.8e+75) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.52e-124], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.8e+75], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.52 \cdot 10^{-124}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.8 \cdot 10^{+75}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.52e-124Initial program 90.3%
+-commutative90.3%
*-commutative90.3%
distribute-lft-out--90.9%
distribute-lft-out90.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 39.9%
if 1.52e-124 < d4 < 1.8e75Initial program 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--92.7%
distribute-lft-out92.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 49.7%
neg-mul-149.7%
Simplified49.7%
if 1.8e75 < d4 Initial program 88.5%
+-commutative88.5%
*-commutative88.5%
distribute-lft-out--88.5%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 76.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 7e+71) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7e+71) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 + 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 (d4 <= 7d+71) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d4 + d2) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7e+71) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 7e+71: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 7e+71) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 7e+71) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 7e+71], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 7 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 6.9999999999999998e71Initial program 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.2%
distribute-lft-out91.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.1%
+-commutative84.1%
associate--r+84.1%
Simplified84.1%
if 6.9999999999999998e71 < d4 Initial program 88.7%
+-commutative88.7%
*-commutative88.7%
distribute-lft-out--88.7%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.2%
Final simplification86.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.2e+75) (* d1 (- d2 d1)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.2e+75) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 4.2d+75) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.2e+75) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.2e+75: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.2e+75) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.2e+75) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.2e+75], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.2 \cdot 10^{+75}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 4.19999999999999997e75Initial program 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.3%
distribute-lft-out91.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.1%
+-commutative84.1%
associate--r+84.1%
Simplified84.1%
Taylor expanded in d3 around 0 66.4%
if 4.19999999999999997e75 < d4 Initial program 88.5%
+-commutative88.5%
*-commutative88.5%
distribute-lft-out--88.5%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.1%
Taylor expanded in d2 around 0 87.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.1e+72) (* d1 (- d2 d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.1e+72) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 1.1d+72) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.1e+72) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.1e+72: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.1e+72) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.1e+72) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.1e+72], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.1 \cdot 10^{+72}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 1.1e72Initial program 90.2%
+-commutative90.2%
*-commutative90.2%
distribute-lft-out--91.2%
distribute-lft-out91.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.1%
+-commutative84.1%
associate--r+84.1%
Simplified84.1%
Taylor expanded in d3 around 0 66.2%
if 1.1e72 < d4 Initial program 88.7%
+-commutative88.7%
*-commutative88.7%
distribute-lft-out--88.7%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.2%
Taylor expanded in d3 around 0 84.3%
+-commutative84.3%
Simplified84.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.32e+82) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.32e+82) {
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.32d+82) 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.32e+82) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.32e+82: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.32e+82) 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.32e+82) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.32e+82], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.32 \cdot 10^{+82}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.32e82Initial program 90.3%
+-commutative90.3%
*-commutative90.3%
distribute-lft-out--91.3%
distribute-lft-out91.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 38.0%
if 1.32e82 < d4 Initial program 88.3%
+-commutative88.3%
*-commutative88.3%
distribute-lft-out--88.3%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 78.1%
(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.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--90.6%
distribute-lft-out91.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.0%
(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.8%
+-commutative89.8%
*-commutative89.8%
distribute-lft-out--90.6%
distribute-lft-out91.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 33.4%
neg-mul-133.4%
Simplified33.4%
neg-sub033.4%
sub-neg33.4%
add-sqr-sqrt13.7%
sqrt-unprod17.0%
sqr-neg17.0%
sqrt-unprod3.3%
add-sqr-sqrt7.6%
Applied egg-rr7.6%
+-lft-identity7.6%
Simplified7.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 2024177
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))