
(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 87.9%
+-commutative87.9%
*-commutative87.9%
distribute-lft-out--89.4%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))) (t_1 (* d1 (+ d4 d2))))
(if (<= d1 -1.12e+90)
t_0
(if (<= d1 -5.2e-248)
t_1
(if (<= d1 7.5e-274) (* d1 (- d3)) (if (<= d1 2.2e+160) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.12e+90) {
tmp = t_0;
} else if (d1 <= -5.2e-248) {
tmp = t_1;
} else if (d1 <= 7.5e-274) {
tmp = d1 * -d3;
} else if (d1 <= 2.2e+160) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * -d1
t_1 = d1 * (d4 + d2)
if (d1 <= (-1.12d+90)) then
tmp = t_0
else if (d1 <= (-5.2d-248)) then
tmp = t_1
else if (d1 <= 7.5d-274) then
tmp = d1 * -d3
else if (d1 <= 2.2d+160) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * (d4 + d2);
double tmp;
if (d1 <= -1.12e+90) {
tmp = t_0;
} else if (d1 <= -5.2e-248) {
tmp = t_1;
} else if (d1 <= 7.5e-274) {
tmp = d1 * -d3;
} else if (d1 <= 2.2e+160) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 t_1 = d1 * (d4 + d2) tmp = 0 if d1 <= -1.12e+90: tmp = t_0 elif d1 <= -5.2e-248: tmp = t_1 elif d1 <= 7.5e-274: tmp = d1 * -d3 elif d1 <= 2.2e+160: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d1 <= -1.12e+90) tmp = t_0; elseif (d1 <= -5.2e-248) tmp = t_1; elseif (d1 <= 7.5e-274) tmp = Float64(d1 * Float64(-d3)); elseif (d1 <= 2.2e+160) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; t_1 = d1 * (d4 + d2); tmp = 0.0; if (d1 <= -1.12e+90) tmp = t_0; elseif (d1 <= -5.2e-248) tmp = t_1; elseif (d1 <= 7.5e-274) tmp = d1 * -d3; elseif (d1 <= 2.2e+160) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -1.12e+90], t$95$0, If[LessEqual[d1, -5.2e-248], t$95$1, If[LessEqual[d1, 7.5e-274], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d1, 2.2e+160], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d1 \leq -1.12 \cdot 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq -5.2 \cdot 10^{-248}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d1 \leq 7.5 \cdot 10^{-274}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d1 \leq 2.2 \cdot 10^{+160}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -1.1199999999999999e90 or 2.19999999999999992e160 < d1 Initial program 65.1%
+-commutative65.1%
*-commutative65.1%
distribute-lft-out--68.7%
distribute-lft-out75.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 80.7%
neg-mul-180.7%
Simplified80.7%
if -1.1199999999999999e90 < d1 < -5.20000000000000013e-248 or 7.49999999999999968e-274 < d1 < 2.19999999999999992e160Initial program 98.7%
+-commutative98.7%
*-commutative98.7%
distribute-lft-out--99.3%
distribute-lft-out99.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.5%
Taylor expanded in d3 around 0 66.6%
if -5.20000000000000013e-248 < d1 < 7.49999999999999968e-274Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 87.0%
mul-1-neg87.0%
distribute-rgt-neg-out87.0%
Simplified87.0%
Final simplification72.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -5.1e+120) (not (<= d1 4.2e+150))) (* d1 (- d4 d1)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -5.1e+120) || !(d1 <= 4.2e+150)) {
tmp = d1 * (d4 - 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 ((d1 <= (-5.1d+120)) .or. (.not. (d1 <= 4.2d+150))) then
tmp = d1 * (d4 - 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 ((d1 <= -5.1e+120) || !(d1 <= 4.2e+150)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -5.1e+120) or not (d1 <= 4.2e+150): tmp = d1 * (d4 - d1) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -5.1e+120) || !(d1 <= 4.2e+150)) tmp = Float64(d1 * Float64(d4 - 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 ((d1 <= -5.1e+120) || ~((d1 <= 4.2e+150))) tmp = d1 * (d4 - d1); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -5.1e+120], N[Not[LessEqual[d1, 4.2e+150]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -5.1 \cdot 10^{+120} \lor \neg \left(d1 \leq 4.2 \cdot 10^{+150}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -5.10000000000000027e120 or 4.19999999999999996e150 < d1 Initial program 60.5%
+-commutative60.5%
*-commutative60.5%
distribute-lft-out--64.5%
distribute-lft-out72.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 94.7%
Taylor expanded in d3 around 0 93.4%
if -5.10000000000000027e120 < d1 < 4.19999999999999996e150Initial program 99.4%
+-commutative99.4%
*-commutative99.4%
distribute-lft-out--99.9%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.6%
Final simplification93.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -48.0) (* d1 (- d2 d3)) (if (<= d2 -3.7e-144) (* d1 (- d4 d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -48.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -3.7e-144) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-48.0d0)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-3.7d-144)) then
tmp = d1 * (d4 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -48.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -3.7e-144) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -48.0: tmp = d1 * (d2 - d3) elif d2 <= -3.7e-144: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -48.0) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -3.7e-144) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -48.0) tmp = d1 * (d2 - d3); elseif (d2 <= -3.7e-144) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -48.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -3.7e-144], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -48:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -3.7 \cdot 10^{-144}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -48Initial program 75.7%
+-commutative75.7%
*-commutative75.7%
distribute-lft-out--77.2%
distribute-lft-out83.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.9%
Taylor expanded in d4 around 0 82.2%
if -48 < d2 < -3.7000000000000003e-144Initial program 96.2%
+-commutative96.2%
*-commutative96.2%
distribute-lft-out--96.2%
distribute-lft-out96.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 95.8%
Taylor expanded in d3 around 0 84.6%
if -3.7000000000000003e-144 < d2 Initial program 91.4%
+-commutative91.4%
*-commutative91.4%
distribute-lft-out--93.3%
distribute-lft-out94.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 82.3%
Taylor expanded in d2 around 0 60.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.9e+128) (* d1 d2) (if (<= d2 -3.4e-28) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.9e+128) {
tmp = d1 * d2;
} else if (d2 <= -3.4e-28) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.9d+128)) then
tmp = d1 * d2
else if (d2 <= (-3.4d-28)) then
tmp = d1 * -d3
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.9e+128) {
tmp = d1 * d2;
} else if (d2 <= -3.4e-28) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.9e+128: tmp = d1 * d2 elif d2 <= -3.4e-28: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.9e+128) tmp = Float64(d1 * d2); elseif (d2 <= -3.4e-28) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.9e+128) tmp = d1 * d2; elseif (d2 <= -3.4e-28) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.9e+128], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -3.4e-28], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.9 \cdot 10^{+128}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -3.4 \cdot 10^{-28}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.9e128Initial program 74.9%
+-commutative74.9%
*-commutative74.9%
distribute-lft-out--76.9%
distribute-lft-out82.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 79.4%
if -2.9e128 < d2 < -3.4000000000000001e-28Initial program 81.3%
+-commutative81.3%
*-commutative81.3%
distribute-lft-out--81.3%
distribute-lft-out87.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 57.5%
mul-1-neg57.5%
distribute-rgt-neg-out57.5%
Simplified57.5%
if -3.4000000000000001e-28 < d2 Initial program 92.0%
+-commutative92.0%
*-commutative92.0%
distribute-lft-out--93.6%
distribute-lft-out94.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 30.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.55e+104) (* d1 d2) (if (<= d2 -9e-148) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.55e+104) {
tmp = d1 * d2;
} else if (d2 <= -9e-148) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.55d+104)) then
tmp = d1 * d2
else if (d2 <= (-9d-148)) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.55e+104) {
tmp = d1 * d2;
} else if (d2 <= -9e-148) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.55e+104: tmp = d1 * d2 elif d2 <= -9e-148: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.55e+104) tmp = Float64(d1 * d2); elseif (d2 <= -9e-148) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.55e+104) tmp = d1 * d2; elseif (d2 <= -9e-148) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.55e+104], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -9e-148], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.55 \cdot 10^{+104}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -9 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.5500000000000001e104Initial program 72.2%
+-commutative72.2%
*-commutative72.2%
distribute-lft-out--74.0%
distribute-lft-out79.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 76.4%
if -2.5500000000000001e104 < d2 < -9.00000000000000029e-148Initial program 92.5%
+-commutative92.5%
*-commutative92.5%
distribute-lft-out--92.5%
distribute-lft-out97.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 36.6%
neg-mul-136.6%
Simplified36.6%
if -9.00000000000000029e-148 < d2 Initial program 91.9%
+-commutative91.9%
*-commutative91.9%
distribute-lft-out--93.8%
distribute-lft-out94.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 28.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.4e+127) (* d1 (- (+ d4 d2) d3)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+127) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((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 <= (-1.4d+127)) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * ((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 <= -1.4e+127) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.4e+127: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.4e+127) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.4e+127) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.4e+127], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+127}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -1.4000000000000001e127Initial program 74.9%
+-commutative74.9%
*-commutative74.9%
distribute-lft-out--76.9%
distribute-lft-out82.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.4%
if -1.4000000000000001e127 < d2 Initial program 91.2%
+-commutative91.2%
*-commutative91.2%
distribute-lft-out--92.6%
distribute-lft-out94.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 84.0%
Final simplification85.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -0.245) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -0.245) {
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 (d2 <= (-0.245d0)) 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 (d2 <= -0.245) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -0.245: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -0.245) 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 (d2 <= -0.245) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -0.245], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -0.245:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -0.245Initial program 75.7%
+-commutative75.7%
*-commutative75.7%
distribute-lft-out--77.2%
distribute-lft-out83.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.9%
Taylor expanded in d4 around 0 82.2%
if -0.245 < d2 Initial program 92.1%
+-commutative92.1%
*-commutative92.1%
distribute-lft-out--93.7%
distribute-lft-out94.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.8%
Taylor expanded in d3 around 0 57.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.6e+67) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+67) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 1.6d+67) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+67) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.6e+67: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.6e+67) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.6e+67) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.6e+67], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.6 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 1.59999999999999991e67Initial program 89.0%
+-commutative89.0%
*-commutative89.0%
distribute-lft-out--90.9%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.0%
Taylor expanded in d4 around 0 66.2%
if 1.59999999999999991e67 < d4 Initial program 82.9%
+-commutative82.9%
*-commutative82.9%
distribute-lft-out--82.9%
distribute-lft-out91.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.7%
Taylor expanded in d3 around 0 83.2%
Final simplification69.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.45e+103) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+103) {
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 <= (-1.45d+103)) 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 <= -1.45e+103) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.45e+103: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.45e+103) 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 <= -1.45e+103) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.45e+103], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+103}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.4499999999999999e103Initial program 72.2%
+-commutative72.2%
*-commutative72.2%
distribute-lft-out--74.0%
distribute-lft-out79.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 76.4%
if -1.4499999999999999e103 < d2 Initial program 92.1%
+-commutative92.1%
*-commutative92.1%
distribute-lft-out--93.5%
distribute-lft-out95.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 31.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 87.9%
+-commutative87.9%
*-commutative87.9%
distribute-lft-out--89.4%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
def code(d1, d2, d3, d4): return d1 * d1
function code(d1, d2, d3, d4) return Float64(d1 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d1
\end{array}
Initial program 87.9%
+-commutative87.9%
*-commutative87.9%
distribute-lft-out--89.4%
distribute-lft-out91.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 33.7%
neg-mul-133.7%
Simplified33.7%
neg-sub033.7%
sub-neg33.7%
add-sqr-sqrt17.4%
sqrt-unprod20.7%
sqr-neg20.7%
sqrt-unprod3.3%
add-sqr-sqrt7.6%
Applied egg-rr7.6%
+-lft-identity7.6%
Simplified7.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024180
(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)))