| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7360 |
\[\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot \left(z + z \cdot \left(t \cdot t\right)\right)}
\]
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
(FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* (* 2.0 z) (exp (* t t))))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt(((2.0 * z) * exp((t * t))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((0.5d0 * x) - y) * sqrt(((2.0d0 * z) * exp((t * t))))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt(((2.0 * z) * Math.exp((t * t))));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.exp(((t * t) / 2.0))
def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt(((2.0 * z) * math.exp((t * t))))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0))) end
function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(Float64(2.0 * z) * exp(Float64(t * t))))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0)); end
function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt(((2.0 * z) * exp((t * t)))); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[Exp[N[(t * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\left(0.5 \cdot x - y\right) \cdot \sqrt{\left(2 \cdot z\right) \cdot e^{t \cdot t}}
Results
| Original | 0.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 0.3
Simplified0.3
[Start]0.3 | \[ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\] |
|---|---|
associate-*l* [=>]0.3 | \[ \color{blue}{\left(x \cdot 0.5 - y\right) \cdot \left(\sqrt{z \cdot 2} \cdot e^{\frac{t \cdot t}{2}}\right)}
\] |
exp-sqrt [=>]0.3 | \[ \left(x \cdot 0.5 - y\right) \cdot \left(\sqrt{z \cdot 2} \cdot \color{blue}{\sqrt{e^{t \cdot t}}}\right)
\] |
Applied egg-rr0.3
Simplified0.3
[Start]0.3 | \[ \sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}} \cdot \left(x \cdot 0.5\right) + \sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}} \cdot \left(-y\right)
\] |
|---|---|
distribute-lft-out [=>]0.3 | \[ \color{blue}{\sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}} \cdot \left(x \cdot 0.5 + \left(-y\right)\right)}
\] |
sub-neg [<=]0.3 | \[ \sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}} \cdot \color{blue}{\left(x \cdot 0.5 - y\right)}
\] |
*-commutative [<=]0.3 | \[ \color{blue}{\left(x \cdot 0.5 - y\right) \cdot \sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}}}
\] |
*-commutative [=>]0.3 | \[ \left(\color{blue}{0.5 \cdot x} - y\right) \cdot \sqrt{\left(z \cdot 2\right) \cdot e^{t \cdot t}}
\] |
*-commutative [=>]0.3 | \[ \left(0.5 \cdot x - y\right) \cdot \sqrt{\color{blue}{\left(2 \cdot z\right)} \cdot e^{t \cdot t}}
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7360 |
| Alternative 2 | |
|---|---|
| Error | 48.9 |
| Cost | 6980 |
| Alternative 3 | |
|---|---|
| Error | 47.5 |
| Cost | 6980 |
| Alternative 4 | |
|---|---|
| Error | 29.4 |
| Cost | 6980 |
| Alternative 5 | |
|---|---|
| Error | 1.1 |
| Cost | 6976 |
| Alternative 6 | |
|---|---|
| Error | 53.2 |
| Cost | 6848 |
herbie shell --seed 2023016
(FPCore (x y z t)
:name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
:precision binary64
:herbie-target
(* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp 1.0) (/ (* t t) 2.0)))
(* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))