
(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 11 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 (if (<= d4 1.3e+179) (fma d4 d1 (* d1 (- (- d2 d3) d1))) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.3e+179) {
tmp = fma(d4, d1, (d1 * ((d2 - d3) - d1)));
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.3e+179) tmp = fma(d4, d1, Float64(d1 * Float64(Float64(d2 - d3) - d1))); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.3e+179], N[(d4 * d1 + N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.3 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(d4, d1, d1 \cdot \left(\left(d2 - d3\right) - d1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 1.3000000000000001e179Initial program 87.1%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f64100.0
Applied rewrites100.0%
if 1.3000000000000001e179 < d4 Initial program 78.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -1.7e-265)
(* (- d2 d1) d1)
(if (<= d4 1.5e+68)
(* (- d2 d3) d1)
(if (<= d4 2.9e+143) (* (- d4 d3) d1) (* (+ d2 d4) d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.7e-265) {
tmp = (d2 - d1) * d1;
} else if (d4 <= 1.5e+68) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 2.9e+143) {
tmp = (d4 - d3) * d1;
} else {
tmp = (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 (d4 <= (-1.7d-265)) then
tmp = (d2 - d1) * d1
else if (d4 <= 1.5d+68) then
tmp = (d2 - d3) * d1
else if (d4 <= 2.9d+143) then
tmp = (d4 - d3) * d1
else
tmp = (d2 + d4) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.7e-265) {
tmp = (d2 - d1) * d1;
} else if (d4 <= 1.5e+68) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 2.9e+143) {
tmp = (d4 - d3) * d1;
} else {
tmp = (d2 + d4) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.7e-265: tmp = (d2 - d1) * d1 elif d4 <= 1.5e+68: tmp = (d2 - d3) * d1 elif d4 <= 2.9e+143: tmp = (d4 - d3) * d1 else: tmp = (d2 + d4) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.7e-265) tmp = Float64(Float64(d2 - d1) * d1); elseif (d4 <= 1.5e+68) tmp = Float64(Float64(d2 - d3) * d1); elseif (d4 <= 2.9e+143) tmp = Float64(Float64(d4 - d3) * d1); else tmp = Float64(Float64(d2 + d4) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -1.7e-265) tmp = (d2 - d1) * d1; elseif (d4 <= 1.5e+68) tmp = (d2 - d3) * d1; elseif (d4 <= 2.9e+143) tmp = (d4 - d3) * d1; else tmp = (d2 + d4) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.7e-265], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 1.5e+68], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 2.9e+143], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.7 \cdot 10^{-265}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 1.5 \cdot 10^{+68}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 2.9 \cdot 10^{+143}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\end{array}
\end{array}
if d4 < -1.7e-265Initial program 84.9%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6472.4
Applied rewrites72.4%
Taylor expanded in d3 around 0
Applied rewrites46.6%
if -1.7e-265 < d4 < 1.5000000000000001e68Initial program 91.6%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6497.7
Applied rewrites97.7%
Taylor expanded in d1 around 0
Applied rewrites80.0%
if 1.5000000000000001e68 < d4 < 2.8999999999999998e143Initial program 85.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.7
Applied rewrites92.7%
Taylor expanded in d2 around 0
Applied rewrites58.4%
if 2.8999999999999998e143 < d4 Initial program 76.9%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in d3 around 0
Applied rewrites97.8%
Final simplification63.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -7.4e+61)
(* d2 d1)
(if (<= d2 -70000000000.0)
(* (- d1) d1)
(if (<= d2 4e-128) (* (- d3) d1) (* d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.4e+61) {
tmp = d2 * d1;
} else if (d2 <= -70000000000.0) {
tmp = -d1 * d1;
} else if (d2 <= 4e-128) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-7.4d+61)) then
tmp = d2 * d1
else if (d2 <= (-70000000000.0d0)) then
tmp = -d1 * d1
else if (d2 <= 4d-128) then
tmp = -d3 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.4e+61) {
tmp = d2 * d1;
} else if (d2 <= -70000000000.0) {
tmp = -d1 * d1;
} else if (d2 <= 4e-128) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.4e+61: tmp = d2 * d1 elif d2 <= -70000000000.0: tmp = -d1 * d1 elif d2 <= 4e-128: tmp = -d3 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.4e+61) tmp = Float64(d2 * d1); elseif (d2 <= -70000000000.0) tmp = Float64(Float64(-d1) * d1); elseif (d2 <= 4e-128) tmp = Float64(Float64(-d3) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -7.4e+61) tmp = d2 * d1; elseif (d2 <= -70000000000.0) tmp = -d1 * d1; elseif (d2 <= 4e-128) tmp = -d3 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.4e+61], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, -70000000000.0], N[((-d1) * d1), $MachinePrecision], If[LessEqual[d2, 4e-128], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.4 \cdot 10^{+61}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d2 \leq -70000000000:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{elif}\;d2 \leq 4 \cdot 10^{-128}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -7.40000000000000005e61Initial program 72.7%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6496.4
Applied rewrites96.4%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6456.8
Applied rewrites56.8%
if -7.40000000000000005e61 < d2 < -7e10Initial program 93.3%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6442.7
Applied rewrites42.7%
if -7e10 < d2 < 4.00000000000000022e-128Initial program 90.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in d3 around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.9
Applied rewrites53.9%
if 4.00000000000000022e-128 < d2 Initial program 89.5%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6435.4
Applied rewrites35.4%
Final simplification46.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -2.6e+159) (* (- (- d3) d1) d1) (if (<= d1 5.5e+118) (* (- (+ d4 d2) d3) d1) (* (- d2 d1) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.6e+159) {
tmp = (-d3 - d1) * d1;
} else if (d1 <= 5.5e+118) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = (d2 - 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 (d1 <= (-2.6d+159)) then
tmp = (-d3 - d1) * d1
else if (d1 <= 5.5d+118) then
tmp = ((d4 + d2) - d3) * d1
else
tmp = (d2 - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.6e+159) {
tmp = (-d3 - d1) * d1;
} else if (d1 <= 5.5e+118) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = (d2 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -2.6e+159: tmp = (-d3 - d1) * d1 elif d1 <= 5.5e+118: tmp = ((d4 + d2) - d3) * d1 else: tmp = (d2 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -2.6e+159) tmp = Float64(Float64(Float64(-d3) - d1) * d1); elseif (d1 <= 5.5e+118) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = Float64(Float64(d2 - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -2.6e+159) tmp = (-d3 - d1) * d1; elseif (d1 <= 5.5e+118) tmp = ((d4 + d2) - d3) * d1; else tmp = (d2 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -2.6e+159], N[(N[((-d3) - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 5.5e+118], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.6 \cdot 10^{+159}:\\
\;\;\;\;\left(\left(-d3\right) - d1\right) \cdot d1\\
\mathbf{elif}\;d1 \leq 5.5 \cdot 10^{+118}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -2.6e159Initial program 42.9%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites100.0%
if -2.6e159 < d1 < 5.5000000000000003e118Initial program 98.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6494.7
Applied rewrites94.7%
if 5.5000000000000003e118 < d1 Initial program 57.1%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6496.4
Applied rewrites96.4%
Taylor expanded in d3 around 0
Applied rewrites89.3%
Final simplification94.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.05e+100) (not (<= d3 2.4e+115))) (* (- d3) d1) (* (+ d2 d4) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.05e+100) || !(d3 <= 2.4e+115)) {
tmp = -d3 * d1;
} else {
tmp = (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 <= (-2.05d+100)) .or. (.not. (d3 <= 2.4d+115))) then
tmp = -d3 * d1
else
tmp = (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 <= -2.05e+100) || !(d3 <= 2.4e+115)) {
tmp = -d3 * d1;
} else {
tmp = (d2 + d4) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.05e+100) or not (d3 <= 2.4e+115): tmp = -d3 * d1 else: tmp = (d2 + d4) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.05e+100) || !(d3 <= 2.4e+115)) tmp = Float64(Float64(-d3) * d1); else tmp = Float64(Float64(d2 + d4) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.05e+100) || ~((d3 <= 2.4e+115))) tmp = -d3 * d1; else tmp = (d2 + d4) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.05e+100], N[Not[LessEqual[d3, 2.4e+115]], $MachinePrecision]], N[((-d3) * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.05 \cdot 10^{+100} \lor \neg \left(d3 \leq 2.4 \cdot 10^{+115}\right):\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -2.0500000000000001e100 or 2.4e115 < d3 Initial program 84.8%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6499.0
Applied rewrites99.0%
Taylor expanded in d3 around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6470.0
Applied rewrites70.0%
if -2.0500000000000001e100 < d3 < 2.4e115Initial program 87.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6477.2
Applied rewrites77.2%
Taylor expanded in d3 around 0
Applied rewrites70.5%
Final simplification70.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.25e+32) (* d2 d1) (if (<= d2 4e-128) (* (- d3) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.25e+32) {
tmp = d2 * d1;
} else if (d2 <= 4e-128) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.25d+32)) then
tmp = d2 * d1
else if (d2 <= 4d-128) then
tmp = -d3 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.25e+32) {
tmp = d2 * d1;
} else if (d2 <= 4e-128) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.25e+32: tmp = d2 * d1 elif d2 <= 4e-128: tmp = -d3 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.25e+32) tmp = Float64(d2 * d1); elseif (d2 <= 4e-128) tmp = Float64(Float64(-d3) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.25e+32) tmp = d2 * d1; elseif (d2 <= 4e-128) tmp = -d3 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.25e+32], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, 4e-128], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.25 \cdot 10^{+32}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d2 \leq 4 \cdot 10^{-128}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -3.2499999999999997e32Initial program 77.3%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6452.4
Applied rewrites52.4%
if -3.2499999999999997e32 < d2 < 4.00000000000000022e-128Initial program 89.4%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6498.9
Applied rewrites98.9%
Taylor expanded in d3 around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6451.7
Applied rewrites51.7%
if 4.00000000000000022e-128 < d2 Initial program 89.5%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6435.4
Applied rewrites35.4%
Final simplification45.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.1e+34) (* (- (- d2 d3) d1) d1) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.1e+34) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 3.1d+34) then
tmp = ((d2 - d3) - d1) * d1
else
tmp = ((d4 + d2) - d3) * 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+34) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.1e+34: tmp = ((d2 - d3) - d1) * d1 else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.1e+34) tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.1e+34) tmp = ((d2 - d3) - d1) * d1; else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.1e+34], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.1 \cdot 10^{+34}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 3.09999999999999977e34Initial program 86.9%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6481.8
Applied rewrites81.8%
if 3.09999999999999977e34 < d4 Initial program 83.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6496.0
Applied rewrites96.0%
Final simplification84.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.25e+32) (* (- d2 d1) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.25e+32) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.25d+32)) then
tmp = (d2 - d1) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.25e+32) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.25e+32: tmp = (d2 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.25e+32) tmp = Float64(Float64(d2 - d1) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.25e+32) tmp = (d2 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.25e+32], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.25 \cdot 10^{+32}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -3.2499999999999997e32Initial program 77.3%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6480.7
Applied rewrites80.7%
Taylor expanded in d3 around 0
Applied rewrites70.6%
if -3.2499999999999997e32 < d2 Initial program 89.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6483.2
Applied rewrites83.2%
Taylor expanded in d2 around 0
Applied rewrites66.9%
Final simplification67.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3e+32) (* (+ d2 d4) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3e+32) {
tmp = (d2 + d4) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3d+32)) then
tmp = (d2 + d4) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3e+32) {
tmp = (d2 + d4) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3e+32: tmp = (d2 + d4) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3e+32) tmp = Float64(Float64(d2 + d4) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3e+32) tmp = (d2 + d4) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3e+32], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3 \cdot 10^{+32}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -3e32Initial program 77.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6483.4
Applied rewrites83.4%
Taylor expanded in d3 around 0
Applied rewrites72.9%
if -3e32 < d2 Initial program 89.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6483.2
Applied rewrites83.2%
Taylor expanded in d2 around 0
Applied rewrites66.9%
Final simplification68.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.7e+51) (* d2 d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.7e+51) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5.7d+51)) then
tmp = d2 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.7e+51) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.7e+51: tmp = d2 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.7e+51) tmp = Float64(d2 * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5.7e+51) tmp = d2 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.7e+51], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.7 \cdot 10^{+51}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -5.7000000000000002e51Initial program 75.4%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6496.7
Applied rewrites96.7%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6454.8
Applied rewrites54.8%
if -5.7000000000000002e51 < d2 Initial program 89.7%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6434.6
Applied rewrites34.6%
Final simplification39.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
double code(double d1, double d2, double d3, double d4) {
return d2 * 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 = d2 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
def code(d1, d2, d3, d4): return d2 * d1
function code(d1, d2, d3, d4) return Float64(d2 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d2 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
\begin{array}{l}
\\
d2 \cdot d1
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6430.4
Applied rewrites30.4%
(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 2024298
(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)))