
(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 88.6%
+-commutative88.6%
*-commutative88.6%
distribute-lft-out--89.0%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d1 -420000.0)
(* d1 (- d2 d1))
(if (<= d1 -6.6e-31)
(* d1 (- d4 d3))
(if (<= d1 1.6e+57) (* d1 (- d2 d3)) (* d1 (- d4 d1))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -420000.0) {
tmp = d1 * (d2 - d1);
} else if (d1 <= -6.6e-31) {
tmp = d1 * (d4 - d3);
} else if (d1 <= 1.6e+57) {
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 (d1 <= (-420000.0d0)) then
tmp = d1 * (d2 - d1)
else if (d1 <= (-6.6d-31)) then
tmp = d1 * (d4 - d3)
else if (d1 <= 1.6d+57) 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 (d1 <= -420000.0) {
tmp = d1 * (d2 - d1);
} else if (d1 <= -6.6e-31) {
tmp = d1 * (d4 - d3);
} else if (d1 <= 1.6e+57) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -420000.0: tmp = d1 * (d2 - d1) elif d1 <= -6.6e-31: tmp = d1 * (d4 - d3) elif d1 <= 1.6e+57: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -420000.0) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= -6.6e-31) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d1 <= 1.6e+57) 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 (d1 <= -420000.0) tmp = d1 * (d2 - d1); elseif (d1 <= -6.6e-31) tmp = d1 * (d4 - d3); elseif (d1 <= 1.6e+57) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -420000.0], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, -6.6e-31], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.6e+57], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -420000:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq -6.6 \cdot 10^{-31}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d1 \leq 1.6 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -4.2e5Initial program 78.9%
sub-neg78.9%
associate-+l+78.9%
*-commutative78.9%
+-commutative78.9%
*-commutative78.9%
sub-neg78.9%
+-commutative78.9%
associate--l+78.9%
distribute-lft-out--83.1%
fma-define91.5%
distribute-rgt-out--97.2%
Simplified97.2%
Taylor expanded in d4 around 0 81.7%
mul-1-neg81.7%
distribute-rgt-neg-out81.7%
+-commutative81.7%
distribute-rgt-neg-out81.7%
unsub-neg81.7%
Simplified81.7%
Taylor expanded in d3 around 0 83.2%
if -4.2e5 < d1 < -6.5999999999999998e-31Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
distribute-lft-out--99.8%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.2%
Taylor expanded in d2 around 0 70.9%
if -6.5999999999999998e-31 < d1 < 1.60000000000000015e57Initial program 100.0%
sub-neg100.0%
associate-+l+100.0%
*-commutative100.0%
+-commutative100.0%
*-commutative100.0%
sub-neg100.0%
+-commutative100.0%
associate--l+100.0%
distribute-lft-out--100.0%
fma-define100.0%
distribute-rgt-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 81.7%
mul-1-neg81.7%
distribute-rgt-neg-out81.7%
+-commutative81.7%
distribute-rgt-neg-out81.7%
unsub-neg81.7%
Simplified81.7%
Taylor expanded in d1 around 0 78.3%
if 1.60000000000000015e57 < d1 Initial program 75.9%
+-commutative75.9%
*-commutative75.9%
distribute-lft-out--75.9%
distribute-lft-out77.6%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d3 around 0 92.8%
Taylor expanded in d2 around 0 83.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -9e+91) (not (<= d3 5.4e+14))) (* d1 (- (+ d4 d2) d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -9e+91) || !(d3 <= 5.4e+14)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - 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 <= (-9d+91)) .or. (.not. (d3 <= 5.4d+14))) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * ((d4 + d2) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -9e+91) || !(d3 <= 5.4e+14)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -9e+91) or not (d3 <= 5.4e+14): tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -9e+91) || !(d3 <= 5.4e+14)) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -9e+91) || ~((d3 <= 5.4e+14))) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * ((d4 + d2) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -9e+91], N[Not[LessEqual[d3, 5.4e+14]], $MachinePrecision]], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -9 \cdot 10^{+91} \lor \neg \left(d3 \leq 5.4 \cdot 10^{+14}\right):\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -9e91 or 5.4e14 < d3 Initial program 89.1%
+-commutative89.1%
*-commutative89.1%
distribute-lft-out--90.1%
distribute-lft-out94.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.6%
if -9e91 < d3 < 5.4e14Initial program 88.4%
+-commutative88.4%
*-commutative88.4%
distribute-lft-out--88.4%
distribute-lft-out90.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.3%
Final simplification95.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -3e+92) (* d1 (- d2 d3)) (if (<= d3 9e+111) (* d1 (- (+ d4 d2) d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -3e+92) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 9e+111) {
tmp = d1 * ((d4 + 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 (d3 <= (-3d+92)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 9d+111) then
tmp = d1 * ((d4 + 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 (d3 <= -3e+92) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 9e+111) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -3e+92: tmp = d1 * (d2 - d3) elif d3 <= 9e+111: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -3e+92) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 9e+111) tmp = Float64(d1 * Float64(Float64(d4 + 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 (d3 <= -3e+92) tmp = d1 * (d2 - d3); elseif (d3 <= 9e+111) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -3e+92], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 9e+111], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3 \cdot 10^{+92}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 9 \cdot 10^{+111}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -3.00000000000000013e92Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--93.6%
fma-define93.6%
distribute-rgt-out--93.6%
Simplified93.6%
Taylor expanded in d4 around 0 87.7%
mul-1-neg87.7%
distribute-rgt-neg-out87.7%
+-commutative87.7%
distribute-rgt-neg-out87.7%
unsub-neg87.7%
Simplified87.7%
Taylor expanded in d1 around 0 90.2%
if -3.00000000000000013e92 < d3 < 9.00000000000000001e111Initial program 88.7%
+-commutative88.7%
*-commutative88.7%
distribute-lft-out--88.7%
distribute-lft-out91.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.1%
if 9.00000000000000001e111 < d3 Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
distribute-lft-out--90.3%
distribute-lft-out93.4%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around 0 93.5%
Taylor expanded in d2 around 0 88.6%
Final simplification92.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.7e+91) (not (<= d3 7.2e+23))) (* d1 (- d2 d3)) (* d1 (- d2 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.7e+91) || !(d3 <= 7.2e+23)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 - 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 <= (-2.7d+91)) .or. (.not. (d3 <= 7.2d+23))) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d2 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.7e+91) || !(d3 <= 7.2e+23)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.7e+91) or not (d3 <= 7.2e+23): tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.7e+91) || !(d3 <= 7.2e+23)) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.7e+91) || ~((d3 <= 7.2e+23))) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.7e+91], N[Not[LessEqual[d3, 7.2e+23]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.7 \cdot 10^{+91} \lor \neg \left(d3 \leq 7.2 \cdot 10^{+23}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\end{array}
\end{array}
if d3 < -2.7e91 or 7.1999999999999997e23 < d3 Initial program 88.7%
sub-neg88.7%
associate-+l+88.7%
*-commutative88.7%
+-commutative88.7%
*-commutative88.7%
sub-neg88.7%
+-commutative88.7%
associate--l+88.7%
distribute-lft-out--91.8%
fma-define93.8%
distribute-rgt-out--95.9%
Simplified95.9%
Taylor expanded in d4 around 0 79.5%
mul-1-neg79.5%
distribute-rgt-neg-out79.5%
+-commutative79.5%
distribute-rgt-neg-out79.5%
unsub-neg79.5%
Simplified79.5%
Taylor expanded in d1 around 0 77.9%
if -2.7e91 < d3 < 7.1999999999999997e23Initial program 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--88.6%
fma-define93.0%
distribute-rgt-out--98.7%
Simplified98.7%
Taylor expanded in d4 around 0 80.6%
mul-1-neg80.6%
distribute-rgt-neg-out80.6%
+-commutative80.6%
distribute-rgt-neg-out80.6%
unsub-neg80.6%
Simplified80.6%
Taylor expanded in d3 around 0 77.9%
Final simplification77.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.45e+91) (not (<= d3 7.6e+195))) (* d1 (- d3)) (* d1 (- d2 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.45e+91) || !(d3 <= 7.6e+195)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 - 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 <= (-2.45d+91)) .or. (.not. (d3 <= 7.6d+195))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.45e+91) || !(d3 <= 7.6e+195)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.45e+91) or not (d3 <= 7.6e+195): tmp = d1 * -d3 else: tmp = d1 * (d2 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.45e+91) || !(d3 <= 7.6e+195)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.45e+91) || ~((d3 <= 7.6e+195))) tmp = d1 * -d3; else tmp = d1 * (d2 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.45e+91], N[Not[LessEqual[d3, 7.6e+195]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.45 \cdot 10^{+91} \lor \neg \left(d3 \leq 7.6 \cdot 10^{+195}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\end{array}
\end{array}
if d3 < -2.45000000000000015e91 or 7.6e195 < d3 Initial program 91.0%
+-commutative91.0%
*-commutative91.0%
distribute-lft-out--91.0%
distribute-lft-out95.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 82.5%
mul-1-neg82.5%
distribute-rgt-neg-out82.5%
Simplified82.5%
if -2.45000000000000015e91 < d3 < 7.6e195Initial program 87.8%
sub-neg87.8%
associate-+l+87.8%
*-commutative87.8%
+-commutative87.8%
*-commutative87.8%
sub-neg87.8%
+-commutative87.8%
associate--l+87.8%
distribute-lft-out--87.8%
fma-define92.6%
distribute-rgt-out--98.4%
Simplified98.4%
Taylor expanded in d4 around 0 77.6%
mul-1-neg77.6%
distribute-rgt-neg-out77.6%
+-commutative77.6%
distribute-rgt-neg-out77.6%
unsub-neg77.6%
Simplified77.6%
Taylor expanded in d3 around 0 72.8%
Final simplification75.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.6e+138) (not (<= d1 9.5e+185))) (* d1 (- d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.6e+138) || !(d1 <= 9.5e+185)) {
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.6d+138)) .or. (.not. (d1 <= 9.5d+185))) 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.6e+138) || !(d1 <= 9.5e+185)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.6e+138) or not (d1 <= 9.5e+185): tmp = d1 * -d1 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.6e+138) || !(d1 <= 9.5e+185)) 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.6e+138) || ~((d1 <= 9.5e+185))) tmp = d1 * -d1; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.6e+138], N[Not[LessEqual[d1, 9.5e+185]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.6 \cdot 10^{+138} \lor \neg \left(d1 \leq 9.5 \cdot 10^{+185}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d1 < -2.6000000000000001e138 or 9.4999999999999995e185 < d1 Initial program 64.8%
+-commutative64.8%
*-commutative64.8%
distribute-lft-out--66.2%
distribute-lft-out74.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 91.9%
neg-mul-191.9%
Simplified91.9%
if -2.6000000000000001e138 < d1 < 9.4999999999999995e185Initial program 97.8%
+-commutative97.8%
*-commutative97.8%
distribute-lft-out--97.8%
distribute-lft-out98.3%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d3 around 0 69.3%
Taylor expanded in d1 around 0 58.0%
Final simplification67.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.6e+17) (* d1 (- d2 d1)) (if (<= d1 2.8e+56) (* d1 (- d2 d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.6e+17) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 2.8e+56) {
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 (d1 <= (-1.6d+17)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 2.8d+56) 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 (d1 <= -1.6e+17) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 2.8e+56) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.6e+17: tmp = d1 * (d2 - d1) elif d1 <= 2.8e+56: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.6e+17) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 2.8e+56) 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 (d1 <= -1.6e+17) tmp = d1 * (d2 - d1); elseif (d1 <= 2.8e+56) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.6e+17], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 2.8e+56], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.6 \cdot 10^{+17}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 2.8 \cdot 10^{+56}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -1.6e17Initial program 78.5%
sub-neg78.5%
associate-+l+78.5%
*-commutative78.5%
+-commutative78.5%
*-commutative78.5%
sub-neg78.5%
+-commutative78.5%
associate--l+78.5%
distribute-lft-out--82.8%
fma-define91.4%
distribute-rgt-out--97.1%
Simplified97.1%
Taylor expanded in d4 around 0 82.7%
mul-1-neg82.7%
distribute-rgt-neg-out82.7%
+-commutative82.7%
distribute-rgt-neg-out82.7%
unsub-neg82.7%
Simplified82.7%
Taylor expanded in d3 around 0 84.3%
if -1.6e17 < d1 < 2.80000000000000008e56Initial program 100.0%
sub-neg100.0%
associate-+l+100.0%
*-commutative100.0%
+-commutative100.0%
*-commutative100.0%
sub-neg100.0%
+-commutative100.0%
associate--l+100.0%
distribute-lft-out--100.0%
fma-define100.0%
distribute-rgt-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 79.8%
mul-1-neg79.8%
distribute-rgt-neg-out79.8%
+-commutative79.8%
distribute-rgt-neg-out79.8%
unsub-neg79.8%
Simplified79.8%
Taylor expanded in d1 around 0 75.9%
if 2.80000000000000008e56 < d1 Initial program 75.9%
+-commutative75.9%
*-commutative75.9%
distribute-lft-out--75.9%
distribute-lft-out77.6%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d3 around 0 92.8%
Taylor expanded in d2 around 0 83.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 7.8e+107) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7.8e+107) {
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 <= 7.8d+107) 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 <= 7.8e+107) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 7.8e+107: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 7.8e+107) 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 <= 7.8e+107) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 7.8e+107], 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.8 \cdot 10^{+107}:\\
\;\;\;\;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 < 7.7999999999999997e107Initial program 92.0%
+-commutative92.0%
*-commutative92.0%
distribute-lft-out--92.5%
distribute-lft-out94.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.7%
+-commutative87.7%
associate--l-87.7%
Simplified87.7%
if 7.7999999999999997e107 < d4 Initial program 71.4%
+-commutative71.4%
*-commutative71.4%
distribute-lft-out--71.4%
distribute-lft-out76.1%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around 0 90.0%
Final simplification88.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -8.8e+60) (* d1 d2) (* d1 (- d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.8e+60) {
tmp = d1 * d2;
} else {
tmp = d1 * -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 <= (-8.8d+60)) then
tmp = d1 * d2
else
tmp = d1 * -d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.8e+60) {
tmp = d1 * d2;
} else {
tmp = d1 * -d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8.8e+60: tmp = d1 * d2 else: tmp = d1 * -d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8.8e+60) tmp = Float64(d1 * d2); else tmp = Float64(d1 * Float64(-d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -8.8e+60) tmp = d1 * d2; else tmp = d1 * -d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8.8e+60], N[(d1 * d2), $MachinePrecision], N[(d1 * (-d1)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8.8 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d2 < -8.79999999999999984e60Initial program 87.5%
+-commutative87.5%
*-commutative87.5%
distribute-lft-out--87.5%
distribute-lft-out89.2%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d2 around inf 74.1%
if -8.79999999999999984e60 < d2 Initial program 89.0%
+-commutative89.0%
*-commutative89.0%
distribute-lft-out--89.5%
distribute-lft-out92.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 41.7%
neg-mul-141.7%
Simplified41.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.8e+88) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.8e+88) {
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 <= (-2.8d+88)) 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 <= -2.8e+88) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.8e+88: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.8e+88) 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 <= -2.8e+88) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.8e+88], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.8 \cdot 10^{+88}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.79999999999999989e88Initial program 88.2%
+-commutative88.2%
*-commutative88.2%
distribute-lft-out--88.2%
distribute-lft-out90.1%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d2 around inf 77.1%
if -2.79999999999999989e88 < d2 Initial program 88.8%
+-commutative88.8%
*-commutative88.8%
distribute-lft-out--89.2%
distribute-lft-out92.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 25.0%
(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 88.6%
+-commutative88.6%
*-commutative88.6%
distribute-lft-out--89.0%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.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 2024169
(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)))