| Alternative 1 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 7568 |
(FPCore (x y z t a) :precision binary64 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* x (* y (/ z (sqrt (- (* z z) (* a t))))))))
(if (<= z -5e+140)
(* x (- y))
(if (<= z -4e-188)
t_1
(if (<= z 6.8e-198)
(/ y (/ (sqrt (* a (- t))) (* z x)))
(if (<= z 4.3e+135)
t_1
(* (/ y (+ -1.0 (* (/ a z) (/ 0.5 (/ z t))))) (- x))))))))double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / sqrt(((z * z) - (t * a)));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x * (y * (z / sqrt(((z * z) - (a * t)))));
double tmp;
if (z <= -5e+140) {
tmp = x * -y;
} else if (z <= -4e-188) {
tmp = t_1;
} else if (z <= 6.8e-198) {
tmp = y / (sqrt((a * -t)) / (z * x));
} else if (z <= 4.3e+135) {
tmp = t_1;
} else {
tmp = (y / (-1.0 + ((a / z) * (0.5 / (z / t))))) * -x;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) * z) / sqrt(((z * z) - (t * a)))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = x * (y * (z / sqrt(((z * z) - (a * t)))))
if (z <= (-5d+140)) then
tmp = x * -y
else if (z <= (-4d-188)) then
tmp = t_1
else if (z <= 6.8d-198) then
tmp = y / (sqrt((a * -t)) / (z * x))
else if (z <= 4.3d+135) then
tmp = t_1
else
tmp = (y / ((-1.0d0) + ((a / z) * (0.5d0 / (z / t))))) * -x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / Math.sqrt(((z * z) - (t * a)));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x * (y * (z / Math.sqrt(((z * z) - (a * t)))));
double tmp;
if (z <= -5e+140) {
tmp = x * -y;
} else if (z <= -4e-188) {
tmp = t_1;
} else if (z <= 6.8e-198) {
tmp = y / (Math.sqrt((a * -t)) / (z * x));
} else if (z <= 4.3e+135) {
tmp = t_1;
} else {
tmp = (y / (-1.0 + ((a / z) * (0.5 / (z / t))))) * -x;
}
return tmp;
}
def code(x, y, z, t, a): return ((x * y) * z) / math.sqrt(((z * z) - (t * a)))
def code(x, y, z, t, a): t_1 = x * (y * (z / math.sqrt(((z * z) - (a * t))))) tmp = 0 if z <= -5e+140: tmp = x * -y elif z <= -4e-188: tmp = t_1 elif z <= 6.8e-198: tmp = y / (math.sqrt((a * -t)) / (z * x)) elif z <= 4.3e+135: tmp = t_1 else: tmp = (y / (-1.0 + ((a / z) * (0.5 / (z / t))))) * -x return tmp
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a)))) end
function code(x, y, z, t, a) t_1 = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t)))))) tmp = 0.0 if (z <= -5e+140) tmp = Float64(x * Float64(-y)); elseif (z <= -4e-188) tmp = t_1; elseif (z <= 6.8e-198) tmp = Float64(y / Float64(sqrt(Float64(a * Float64(-t))) / Float64(z * x))); elseif (z <= 4.3e+135) tmp = t_1; else tmp = Float64(Float64(y / Float64(-1.0 + Float64(Float64(a / z) * Float64(0.5 / Float64(z / t))))) * Float64(-x)); end return tmp end
function tmp = code(x, y, z, t, a) tmp = ((x * y) * z) / sqrt(((z * z) - (t * a))); end
function tmp_2 = code(x, y, z, t, a) t_1 = x * (y * (z / sqrt(((z * z) - (a * t))))); tmp = 0.0; if (z <= -5e+140) tmp = x * -y; elseif (z <= -4e-188) tmp = t_1; elseif (z <= 6.8e-198) tmp = y / (sqrt((a * -t)) / (z * x)); elseif (z <= 4.3e+135) tmp = t_1; else tmp = (y / (-1.0 + ((a / z) * (0.5 / (z / t))))) * -x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(y * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5e+140], N[(x * (-y)), $MachinePrecision], If[LessEqual[z, -4e-188], t$95$1, If[LessEqual[z, 6.8e-198], N[(y / N[(N[Sqrt[N[(a * (-t)), $MachinePrecision]], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.3e+135], t$95$1, N[(N[(y / N[(-1.0 + N[(N[(a / z), $MachinePrecision] * N[(0.5 / N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-x)), $MachinePrecision]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{+140}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-188}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-198}:\\
\;\;\;\;\frac{y}{\frac{\sqrt{a \cdot \left(-t\right)}}{z \cdot x}}\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+135}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{-1 + \frac{a}{z} \cdot \frac{0.5}{\frac{z}{t}}} \cdot \left(-x\right)\\
\end{array}
Results
| Original | 61.8% |
|---|---|
| Target | 88.4% |
| Herbie | 91.0% |
if z < -5.00000000000000008e140Initial program 20.2%
Simplified21.6%
[Start]20.2 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-*r/ [<=]21.6 | \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}}
\] |
associate-*l* [=>]21.6 | \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
Taylor expanded in z around -inf 97.8%
Simplified97.8%
[Start]97.8 | \[ -1 \cdot \left(y \cdot x\right)
\] |
|---|---|
associate-*r* [=>]97.8 | \[ \color{blue}{\left(-1 \cdot y\right) \cdot x}
\] |
mul-1-neg [=>]97.8 | \[ \color{blue}{\left(-y\right)} \cdot x
\] |
if -5.00000000000000008e140 < z < -3.9999999999999998e-188 or 6.7999999999999996e-198 < z < 4.29999999999999972e135Initial program 86.8%
Simplified91.0%
[Start]86.8 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-*r/ [<=]91.4 | \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}}
\] |
associate-*l* [=>]91.0 | \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
if -3.9999999999999998e-188 < z < 6.7999999999999996e-198Initial program 71.4%
Simplified71.2%
[Start]71.4 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-*l* [=>]71.2 | \[ \frac{\color{blue}{x \cdot \left(y \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
associate-/l* [=>]71.2 | \[ \color{blue}{\frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{y \cdot z}}}
\] |
Applied egg-rr70.7%
[Start]71.2 | \[ \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{y \cdot z}}
\] |
|---|---|
associate-/l/ [<=]68.2 | \[ \frac{x}{\color{blue}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{y}}}
\] |
associate-/r/ [=>]70.7 | \[ \color{blue}{\frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot y}
\] |
Applied egg-rr73.8%
[Start]70.7 | \[ \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot y
\] |
|---|---|
*-commutative [=>]70.7 | \[ \color{blue}{y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}
\] |
clear-num [=>]70.3 | \[ y \cdot \color{blue}{\frac{1}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{x}}}
\] |
un-div-inv [=>]70.3 | \[ \color{blue}{\frac{y}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{x}}}
\] |
associate-/l/ [=>]73.8 | \[ \frac{y}{\color{blue}{\frac{\sqrt{z \cdot z - t \cdot a}}{x \cdot z}}}
\] |
Taylor expanded in z around 0 73.8%
Simplified73.8%
[Start]73.8 | \[ \frac{y}{\frac{\sqrt{-1 \cdot \left(a \cdot t\right)}}{x \cdot z}}
\] |
|---|---|
associate-*r* [=>]73.8 | \[ \frac{y}{\frac{\sqrt{\color{blue}{\left(-1 \cdot a\right) \cdot t}}}{x \cdot z}}
\] |
neg-mul-1 [<=]73.8 | \[ \frac{y}{\frac{\sqrt{\color{blue}{\left(-a\right)} \cdot t}}{x \cdot z}}
\] |
*-commutative [<=]73.8 | \[ \frac{y}{\frac{\sqrt{\color{blue}{t \cdot \left(-a\right)}}}{x \cdot z}}
\] |
if 4.29999999999999972e135 < z Initial program 21.0%
Simplified21.0%
[Start]21.0 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-*l* [=>]19.6 | \[ \frac{\color{blue}{x \cdot \left(y \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
associate-/l* [=>]21.0 | \[ \color{blue}{\frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{y \cdot z}}}
\] |
Taylor expanded in z around inf 89.3%
Simplified97.2%
[Start]89.3 | \[ \frac{x}{\frac{1}{y} + -0.5 \cdot \frac{a \cdot t}{y \cdot {z}^{2}}}
\] |
|---|---|
associate-/l* [=>]97.2 | \[ \frac{x}{\frac{1}{y} + -0.5 \cdot \color{blue}{\frac{a}{\frac{y \cdot {z}^{2}}{t}}}}
\] |
unpow2 [=>]97.2 | \[ \frac{x}{\frac{1}{y} + -0.5 \cdot \frac{a}{\frac{y \cdot \color{blue}{\left(z \cdot z\right)}}{t}}}
\] |
Taylor expanded in y around 0 89.7%
Simplified97.4%
[Start]89.7 | \[ \frac{y \cdot x}{1 + -0.5 \cdot \frac{a \cdot t}{{z}^{2}}}
\] |
|---|---|
associate-/l* [=>]89.4 | \[ \color{blue}{\frac{y}{\frac{1 + -0.5 \cdot \frac{a \cdot t}{{z}^{2}}}{x}}}
\] |
associate-/l* [=>]97.2 | \[ \frac{y}{\frac{1 + -0.5 \cdot \color{blue}{\frac{a}{\frac{{z}^{2}}{t}}}}{x}}
\] |
unpow2 [=>]97.2 | \[ \frac{y}{\frac{1 + -0.5 \cdot \frac{a}{\frac{\color{blue}{z \cdot z}}{t}}}{x}}
\] |
associate-/l* [=>]97.4 | \[ \frac{y}{\frac{1 + -0.5 \cdot \frac{a}{\color{blue}{\frac{z}{\frac{t}{z}}}}}{x}}
\] |
Applied egg-rr97.9%
[Start]97.4 | \[ \frac{y}{\frac{1 + -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}}{x}}
\] |
|---|---|
frac-2neg [=>]97.4 | \[ \frac{y}{\color{blue}{\frac{-\left(1 + -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}\right)}{-x}}}
\] |
associate-/r/ [=>]97.8 | \[ \color{blue}{\frac{y}{-\left(1 + -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}\right)} \cdot \left(-x\right)}
\] |
neg-sub0 [=>]97.8 | \[ \frac{y}{\color{blue}{0 - \left(1 + -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}\right)}} \cdot \left(-x\right)
\] |
metadata-eval [<=]97.8 | \[ \frac{y}{\color{blue}{\log 1} - \left(1 + -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}\right)} \cdot \left(-x\right)
\] |
associate--r+ [=>]97.8 | \[ \frac{y}{\color{blue}{\left(\log 1 - 1\right) - -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}}} \cdot \left(-x\right)
\] |
metadata-eval [=>]97.8 | \[ \frac{y}{\left(\color{blue}{0} - 1\right) - -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}} \cdot \left(-x\right)
\] |
metadata-eval [=>]97.8 | \[ \frac{y}{\color{blue}{-1} - -0.5 \cdot \frac{a}{\frac{z}{\frac{t}{z}}}} \cdot \left(-x\right)
\] |
associate-*r/ [=>]97.8 | \[ \frac{y}{-1 - \color{blue}{\frac{-0.5 \cdot a}{\frac{z}{\frac{t}{z}}}}} \cdot \left(-x\right)
\] |
associate-/r/ [=>]97.8 | \[ \frac{y}{-1 - \frac{-0.5 \cdot a}{\color{blue}{\frac{z}{t} \cdot z}}} \cdot \left(-x\right)
\] |
times-frac [=>]97.9 | \[ \frac{y}{-1 - \color{blue}{\frac{-0.5}{\frac{z}{t}} \cdot \frac{a}{z}}} \cdot \left(-x\right)
\] |
Final simplification91.0%
| Alternative 1 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 7568 |
| Alternative 2 | |
|---|---|
| Accuracy | 82.0% |
| Cost | 7568 |
| Alternative 3 | |
|---|---|
| Accuracy | 81.6% |
| Cost | 7568 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 7496 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 7496 |
| Alternative 6 | |
|---|---|
| Accuracy | 76.0% |
| Cost | 1156 |
| Alternative 7 | |
|---|---|
| Accuracy | 77.1% |
| Cost | 1156 |
| Alternative 8 | |
|---|---|
| Accuracy | 74.8% |
| Cost | 1092 |
| Alternative 9 | |
|---|---|
| Accuracy | 75.9% |
| Cost | 1092 |
| Alternative 10 | |
|---|---|
| Accuracy | 73.7% |
| Cost | 712 |
| Alternative 11 | |
|---|---|
| Accuracy | 70.8% |
| Cost | 388 |
| Alternative 12 | |
|---|---|
| Accuracy | 42.5% |
| Cost | 192 |
herbie shell --seed 2023137
(FPCore (x y z t a)
:name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))