
(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}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (fma d4 d1 (* (- (- d2 d3) d1) d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return fma(d4, d1, (((d2 - d3) - d1) * d1));
}
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return fma(d4, d1, Float64(Float64(Float64(d2 - d3) - d1) * d1)) end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d4 * d1 + N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\mathsf{fma}\left(d4, d1, \left(\left(d2 - d3\right) - d1\right) \cdot d1\right)
\end{array}
Initial program 85.5%
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.0
Applied rewrites98.0%
Final simplification98.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* (- d4 d3) d1)))
(if (<= d2 -8e+27)
(* (- d2 d1) d1)
(if (<= d2 -1.02e-97) t_0 (if (<= d2 1.42e-129) (* (- d4 d1) d1) t_0)))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = (d4 - d3) * d1;
double tmp;
if (d2 <= -8e+27) {
tmp = (d2 - d1) * d1;
} else if (d2 <= -1.02e-97) {
tmp = t_0;
} else if (d2 <= 1.42e-129) {
tmp = (d4 - d1) * d1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = (d4 - d3) * d1
if (d2 <= (-8d+27)) then
tmp = (d2 - d1) * d1
else if (d2 <= (-1.02d-97)) then
tmp = t_0
else if (d2 <= 1.42d-129) then
tmp = (d4 - d1) * d1
else
tmp = t_0
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (d4 - d3) * d1;
double tmp;
if (d2 <= -8e+27) {
tmp = (d2 - d1) * d1;
} else if (d2 <= -1.02e-97) {
tmp = t_0;
} else if (d2 <= 1.42e-129) {
tmp = (d4 - d1) * d1;
} else {
tmp = t_0;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = (d4 - d3) * d1 tmp = 0 if d2 <= -8e+27: tmp = (d2 - d1) * d1 elif d2 <= -1.02e-97: tmp = t_0 elif d2 <= 1.42e-129: tmp = (d4 - d1) * d1 else: tmp = t_0 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(Float64(d4 - d3) * d1) tmp = 0.0 if (d2 <= -8e+27) tmp = Float64(Float64(d2 - d1) * d1); elseif (d2 <= -1.02e-97) tmp = t_0; elseif (d2 <= 1.42e-129) tmp = Float64(Float64(d4 - d1) * d1); else tmp = t_0; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = (d4 - d3) * d1;
tmp = 0.0;
if (d2 <= -8e+27)
tmp = (d2 - d1) * d1;
elseif (d2 <= -1.02e-97)
tmp = t_0;
elseif (d2 <= 1.42e-129)
tmp = (d4 - d1) * d1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d2, -8e+27], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -1.02e-97], t$95$0, If[LessEqual[d2, 1.42e-129], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(d4 - d3\right) \cdot d1\\
\mathbf{if}\;d2 \leq -8 \cdot 10^{+27}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{elif}\;d2 \leq -1.02 \cdot 10^{-97}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d2 \leq 1.42 \cdot 10^{-129}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d2 < -8.0000000000000001e27Initial program 86.7%
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--.f6489.4
Applied rewrites89.4%
Taylor expanded in d3 around 0
Applied rewrites79.4%
if -8.0000000000000001e27 < d2 < -1.02000000000000004e-97 or 1.42e-129 < d2 Initial program 85.0%
Taylor expanded in d2 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--.f6478.1
Applied rewrites78.1%
Taylor expanded in d1 around 0
Applied rewrites60.9%
if -1.02000000000000004e-97 < d2 < 1.42e-129Initial program 85.5%
Taylor expanded in d2 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 d3 around 0
Applied rewrites84.5%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* (- d2 d1) d1)))
(if (<= d1 -8e+143)
t_0
(if (<= d1 7.2e-76)
(* (+ d2 d4) d1)
(if (<= d1 2.6e+102) (* (- d2 d3) d1) t_0)))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = (d2 - d1) * d1;
double tmp;
if (d1 <= -8e+143) {
tmp = t_0;
} else if (d1 <= 7.2e-76) {
tmp = (d2 + d4) * d1;
} else if (d1 <= 2.6e+102) {
tmp = (d2 - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = (d2 - d1) * d1
if (d1 <= (-8d+143)) then
tmp = t_0
else if (d1 <= 7.2d-76) then
tmp = (d2 + d4) * d1
else if (d1 <= 2.6d+102) then
tmp = (d2 - d3) * d1
else
tmp = t_0
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (d2 - d1) * d1;
double tmp;
if (d1 <= -8e+143) {
tmp = t_0;
} else if (d1 <= 7.2e-76) {
tmp = (d2 + d4) * d1;
} else if (d1 <= 2.6e+102) {
tmp = (d2 - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = (d2 - d1) * d1 tmp = 0 if d1 <= -8e+143: tmp = t_0 elif d1 <= 7.2e-76: tmp = (d2 + d4) * d1 elif d1 <= 2.6e+102: tmp = (d2 - d3) * d1 else: tmp = t_0 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(Float64(d2 - d1) * d1) tmp = 0.0 if (d1 <= -8e+143) tmp = t_0; elseif (d1 <= 7.2e-76) tmp = Float64(Float64(d2 + d4) * d1); elseif (d1 <= 2.6e+102) tmp = Float64(Float64(d2 - d3) * d1); else tmp = t_0; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = (d2 - d1) * d1;
tmp = 0.0;
if (d1 <= -8e+143)
tmp = t_0;
elseif (d1 <= 7.2e-76)
tmp = (d2 + d4) * d1;
elseif (d1 <= 2.6e+102)
tmp = (d2 - d3) * d1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d1, -8e+143], t$95$0, If[LessEqual[d1, 7.2e-76], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 2.6e+102], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(d2 - d1\right) \cdot d1\\
\mathbf{if}\;d1 \leq -8 \cdot 10^{+143}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 7.2 \cdot 10^{-76}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\mathbf{elif}\;d1 \leq 2.6 \cdot 10^{+102}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -8.0000000000000002e143 or 2.60000000000000006e102 < d1 Initial program 57.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--.f6493.6
Applied rewrites93.6%
Taylor expanded in d3 around 0
Applied rewrites87.8%
if -8.0000000000000002e143 < d1 < 7.2000000000000001e-76Initial program 99.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.3
Applied rewrites92.3%
Taylor expanded in d3 around 0
Applied rewrites72.1%
if 7.2000000000000001e-76 < d1 < 2.60000000000000006e102Initial program 100.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6483.7
Applied rewrites83.7%
Taylor expanded in d4 around 0
Applied rewrites61.1%
Final simplification75.9%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* (- d1) d1)))
(if (<= d1 -1.7e+144)
t_0
(if (<= d1 7.2e-76)
(* (+ d2 d4) d1)
(if (<= d1 2.3e+138) (* (- d2 d3) d1) t_0)))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = -d1 * d1;
double tmp;
if (d1 <= -1.7e+144) {
tmp = t_0;
} else if (d1 <= 7.2e-76) {
tmp = (d2 + d4) * d1;
} else if (d1 <= 2.3e+138) {
tmp = (d2 - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = -d1 * d1
if (d1 <= (-1.7d+144)) then
tmp = t_0
else if (d1 <= 7.2d-76) then
tmp = (d2 + d4) * d1
else if (d1 <= 2.3d+138) then
tmp = (d2 - d3) * d1
else
tmp = t_0
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = -d1 * d1;
double tmp;
if (d1 <= -1.7e+144) {
tmp = t_0;
} else if (d1 <= 7.2e-76) {
tmp = (d2 + d4) * d1;
} else if (d1 <= 2.3e+138) {
tmp = (d2 - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = -d1 * d1 tmp = 0 if d1 <= -1.7e+144: tmp = t_0 elif d1 <= 7.2e-76: tmp = (d2 + d4) * d1 elif d1 <= 2.3e+138: tmp = (d2 - d3) * d1 else: tmp = t_0 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(Float64(-d1) * d1) tmp = 0.0 if (d1 <= -1.7e+144) tmp = t_0; elseif (d1 <= 7.2e-76) tmp = Float64(Float64(d2 + d4) * d1); elseif (d1 <= 2.3e+138) tmp = Float64(Float64(d2 - d3) * d1); else tmp = t_0; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = -d1 * d1;
tmp = 0.0;
if (d1 <= -1.7e+144)
tmp = t_0;
elseif (d1 <= 7.2e-76)
tmp = (d2 + d4) * d1;
elseif (d1 <= 2.3e+138)
tmp = (d2 - d3) * d1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[((-d1) * d1), $MachinePrecision]}, If[LessEqual[d1, -1.7e+144], t$95$0, If[LessEqual[d1, 7.2e-76], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 2.3e+138], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(-d1\right) \cdot d1\\
\mathbf{if}\;d1 \leq -1.7 \cdot 10^{+144}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 7.2 \cdot 10^{-76}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\mathbf{elif}\;d1 \leq 2.3 \cdot 10^{+138}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -1.7e144 or 2.30000000000000008e138 < d1 Initial program 53.9%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6490.8
Applied rewrites90.8%
if -1.7e144 < d1 < 7.2000000000000001e-76Initial program 99.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.3
Applied rewrites92.3%
Taylor expanded in d3 around 0
Applied rewrites72.1%
if 7.2000000000000001e-76 < d1 < 2.30000000000000008e138Initial program 97.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6480.5
Applied rewrites80.5%
Taylor expanded in d4 around 0
Applied rewrites57.7%
Final simplification75.2%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.6e+144) (* (- d2 d1) d1) (if (<= d1 1.35e+138) (* (- (+ d2 d4) d3) d1) (* (- d4 d1) d1))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.6e+144) {
tmp = (d2 - d1) * d1;
} else if (d1 <= 1.35e+138) {
tmp = ((d2 + d4) - d3) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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+144)) then
tmp = (d2 - d1) * d1
else if (d1 <= 1.35d+138) then
tmp = ((d2 + d4) - d3) * d1
else
tmp = (d4 - d1) * d1
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.6e+144) {
tmp = (d2 - d1) * d1;
} else if (d1 <= 1.35e+138) {
tmp = ((d2 + d4) - d3) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.6e+144: tmp = (d2 - d1) * d1 elif d1 <= 1.35e+138: tmp = ((d2 + d4) - d3) * d1 else: tmp = (d4 - d1) * d1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.6e+144) tmp = Float64(Float64(d2 - d1) * d1); elseif (d1 <= 1.35e+138) tmp = Float64(Float64(Float64(d2 + d4) - d3) * d1); else tmp = Float64(Float64(d4 - d1) * d1); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d1 <= -1.6e+144)
tmp = (d2 - d1) * d1;
elseif (d1 <= 1.35e+138)
tmp = ((d2 + d4) - d3) * d1;
else
tmp = (d4 - d1) * d1;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.6e+144], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 1.35e+138], N[(N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.6 \cdot 10^{+144}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+138}:\\
\;\;\;\;\left(\left(d2 + d4\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -1.6e144Initial program 57.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--.f6497.4
Applied rewrites97.4%
Taylor expanded in d3 around 0
Applied rewrites92.1%
if -1.6e144 < d1 < 1.35000000000000004e138Initial program 98.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6489.5
Applied rewrites89.5%
if 1.35000000000000004e138 < d1 Initial program 50.0%
Taylor expanded in d2 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--.f6494.7
Applied rewrites94.7%
Taylor expanded in d3 around 0
Applied rewrites94.7%
Final simplification90.7%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (* (- d1) d1))) (if (<= d1 -1.7e+144) t_0 (if (<= d1 2.3e+138) (* (+ d2 d4) d1) t_0))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = -d1 * d1;
double tmp;
if (d1 <= -1.7e+144) {
tmp = t_0;
} else if (d1 <= 2.3e+138) {
tmp = (d2 + d4) * d1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = -d1 * d1
if (d1 <= (-1.7d+144)) then
tmp = t_0
else if (d1 <= 2.3d+138) then
tmp = (d2 + d4) * d1
else
tmp = t_0
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = -d1 * d1;
double tmp;
if (d1 <= -1.7e+144) {
tmp = t_0;
} else if (d1 <= 2.3e+138) {
tmp = (d2 + d4) * d1;
} else {
tmp = t_0;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = -d1 * d1 tmp = 0 if d1 <= -1.7e+144: tmp = t_0 elif d1 <= 2.3e+138: tmp = (d2 + d4) * d1 else: tmp = t_0 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(Float64(-d1) * d1) tmp = 0.0 if (d1 <= -1.7e+144) tmp = t_0; elseif (d1 <= 2.3e+138) tmp = Float64(Float64(d2 + d4) * d1); else tmp = t_0; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = -d1 * d1;
tmp = 0.0;
if (d1 <= -1.7e+144)
tmp = t_0;
elseif (d1 <= 2.3e+138)
tmp = (d2 + d4) * d1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[((-d1) * d1), $MachinePrecision]}, If[LessEqual[d1, -1.7e+144], t$95$0, If[LessEqual[d1, 2.3e+138], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(-d1\right) \cdot d1\\
\mathbf{if}\;d1 \leq -1.7 \cdot 10^{+144}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 2.3 \cdot 10^{+138}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -1.7e144 or 2.30000000000000008e138 < d1 Initial program 53.9%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6490.8
Applied rewrites90.8%
if -1.7e144 < d1 < 2.30000000000000008e138Initial program 98.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6489.5
Applied rewrites89.5%
Taylor expanded in d3 around 0
Applied rewrites66.7%
Final simplification73.8%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.6e-225) (* d2 d1) (if (<= d4 1.7e+20) (* (- d1) d1) (* d1 d4))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.6e-225) {
tmp = d2 * d1;
} else if (d4 <= 1.7e+20) {
tmp = -d1 * d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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.6d-225) then
tmp = d2 * d1
else if (d4 <= 1.7d+20) then
tmp = -d1 * d1
else
tmp = d1 * d4
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.6e-225) {
tmp = d2 * d1;
} else if (d4 <= 1.7e+20) {
tmp = -d1 * d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.6e-225: tmp = d2 * d1 elif d4 <= 1.7e+20: tmp = -d1 * d1 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.6e-225) tmp = Float64(d2 * d1); elseif (d4 <= 1.7e+20) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(d1 * d4); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d4 <= 4.6e-225)
tmp = d2 * d1;
elseif (d4 <= 1.7e+20)
tmp = -d1 * d1;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.6e-225], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 1.7e+20], N[((-d1) * d1), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.6 \cdot 10^{-225}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 1.7 \cdot 10^{+20}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 4.5999999999999998e-225Initial program 88.4%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6434.5
Applied rewrites34.5%
if 4.5999999999999998e-225 < d4 < 1.7e20Initial program 84.3%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6452.5
Applied rewrites52.5%
if 1.7e20 < d4 Initial program 80.6%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6459.6
Applied rewrites59.6%
Final simplification44.7%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.2e+28) (* (- (- d2 d3) d1) d1) (* (- (- d4 d3) d1) d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+28) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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.2d+28)) then
tmp = ((d2 - d3) - d1) * d1
else
tmp = ((d4 - d3) - d1) * d1
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+28) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.2e+28: tmp = ((d2 - d3) - d1) * d1 else: tmp = ((d4 - d3) - d1) * d1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.2e+28) tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -3.2e+28)
tmp = ((d2 - d3) - d1) * d1;
else
tmp = ((d4 - d3) - d1) * d1;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.2e+28], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.2 \cdot 10^{+28}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -3.2e28Initial program 86.7%
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--.f6489.4
Applied rewrites89.4%
if -3.2e28 < d2 Initial program 85.2%
Taylor expanded in d2 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--.f6487.0
Applied rewrites87.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1e+16) (* (- (- d2 d3) d1) d1) (* (- (+ d2 d4) d3) d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1e+16) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d2 + d4) - d3) * d1;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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 <= 1d+16) then
tmp = ((d2 - d3) - d1) * d1
else
tmp = ((d2 + d4) - d3) * d1
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1e+16) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d2 + d4) - d3) * d1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1e+16: tmp = ((d2 - d3) - d1) * d1 else: tmp = ((d2 + d4) - d3) * d1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1e+16) tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1); else tmp = Float64(Float64(Float64(d2 + d4) - d3) * d1); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d4 <= 1e+16)
tmp = ((d2 - d3) - d1) * d1;
else
tmp = ((d2 + d4) - d3) * d1;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1e+16], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 10^{+16}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d2 + d4\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 1e16Initial program 87.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--.f6483.2
Applied rewrites83.2%
if 1e16 < d4 Initial program 80.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6483.6
Applied rewrites83.6%
Final simplification83.3%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.2e+28) (* (- d2 d1) d1) (* (- d4 d1) d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+28) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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.2d+28)) then
tmp = (d2 - d1) * d1
else
tmp = (d4 - d1) * d1
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+28) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.2e+28: tmp = (d2 - d1) * d1 else: tmp = (d4 - d1) * d1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.2e+28) tmp = Float64(Float64(d2 - d1) * d1); else tmp = Float64(Float64(d4 - d1) * d1); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -3.2e+28)
tmp = (d2 - d1) * d1;
else
tmp = (d4 - d1) * d1;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.2e+28], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.2 \cdot 10^{+28}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -3.2e28Initial program 86.7%
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--.f6489.4
Applied rewrites89.4%
Taylor expanded in d3 around 0
Applied rewrites79.4%
if -3.2e28 < d2 Initial program 85.2%
Taylor expanded in d2 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--.f6487.0
Applied rewrites87.0%
Taylor expanded in d3 around 0
Applied rewrites67.4%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -9.8e+27) (* d2 d1) (* d1 d4)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9.8e+27) {
tmp = d2 * d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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 <= (-9.8d+27)) then
tmp = d2 * d1
else
tmp = d1 * d4
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9.8e+27) {
tmp = d2 * d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -9.8e+27: tmp = d2 * d1 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -9.8e+27) tmp = Float64(d2 * d1); else tmp = Float64(d1 * d4); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -9.8e+27)
tmp = d2 * d1;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.8e+27], N[(d2 * d1), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -9.8000000000000003e27Initial program 86.7%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6462.0
Applied rewrites62.0%
if -9.8000000000000003e27 < d2 Initial program 85.2%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6437.9
Applied rewrites37.9%
Final simplification42.8%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
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
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d2 * d1
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d2 * d1) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d2 * d1;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d2 \cdot d1
\end{array}
Initial program 85.5%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6430.3
Applied rewrites30.3%
(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 2024268
(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)))