| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 19520 |
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
(FPCore (w l) :precision binary64 (if (<= w 0.0115) (* l (+ 1.0 (* (- (log l) 1.0) w))) (+ -1.0 (- 1.0 (/ l (- (exp w)))))))
double code(double w, double l) {
return exp(-w) * pow(l, exp(w));
}
double code(double w, double l) {
double tmp;
if (w <= 0.0115) {
tmp = l * (1.0 + ((log(l) - 1.0) * w));
} else {
tmp = -1.0 + (1.0 - (l / -exp(w)));
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * (l ** exp(w))
end function
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 0.0115d0) then
tmp = l * (1.0d0 + ((log(l) - 1.0d0) * w))
else
tmp = (-1.0d0) + (1.0d0 - (l / -exp(w)))
end if
code = tmp
end function
public static double code(double w, double l) {
return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
public static double code(double w, double l) {
double tmp;
if (w <= 0.0115) {
tmp = l * (1.0 + ((Math.log(l) - 1.0) * w));
} else {
tmp = -1.0 + (1.0 - (l / -Math.exp(w)));
}
return tmp;
}
def code(w, l): return math.exp(-w) * math.pow(l, math.exp(w))
def code(w, l): tmp = 0 if w <= 0.0115: tmp = l * (1.0 + ((math.log(l) - 1.0) * w)) else: tmp = -1.0 + (1.0 - (l / -math.exp(w))) return tmp
function code(w, l) return Float64(exp(Float64(-w)) * (l ^ exp(w))) end
function code(w, l) tmp = 0.0 if (w <= 0.0115) tmp = Float64(l * Float64(1.0 + Float64(Float64(log(l) - 1.0) * w))); else tmp = Float64(-1.0 + Float64(1.0 - Float64(l / Float64(-exp(w))))); end return tmp end
function tmp = code(w, l) tmp = exp(-w) * (l ^ exp(w)); end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.0115) tmp = l * (1.0 + ((log(l) - 1.0) * w)); else tmp = -1.0 + (1.0 - (l / -exp(w))); end tmp_2 = tmp; end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[w_, l_] := If[LessEqual[w, 0.0115], N[(l * N[(1.0 + N[(N[(N[Log[l], $MachinePrecision] - 1.0), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(1.0 - N[(l / (-N[Exp[w], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\begin{array}{l}
\mathbf{if}\;w \leq 0.0115:\\
\;\;\;\;\ell \cdot \left(1 + \left(\log \ell - 1\right) \cdot w\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(1 - \frac{\ell}{-e^{w}}\right)\\
\end{array}
Results
if w < 0.0115Initial program 0.3
Taylor expanded in w around 0 1.3
Simplified1.3
[Start]1.3 | \[ e^{-w} \cdot \left(\ell + \ell \cdot \left(w \cdot \log \ell\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]1.3 | \[ e^{-w} \cdot \left(\ell + \ell \cdot \color{blue}{\left(\log \ell \cdot w\right)}\right)
\] |
Taylor expanded in l around 0 1.3
Simplified1.3
[Start]1.3 | \[ e^{-w} \cdot \left(\ell \cdot \left(1 + w \cdot \log \ell\right)\right)
\] |
|---|---|
rational.json-simplify-43 [=>]1.3 | \[ \color{blue}{\ell \cdot \left(\left(1 + w \cdot \log \ell\right) \cdot e^{-w}\right)}
\] |
rational.json-simplify-1 [=>]1.3 | \[ \ell \cdot \left(\color{blue}{\left(w \cdot \log \ell + 1\right)} \cdot e^{-w}\right)
\] |
rational.json-simplify-2 [=>]1.3 | \[ \ell \cdot \left(\left(\color{blue}{\log \ell \cdot w} + 1\right) \cdot e^{-w}\right)
\] |
rational.json-simplify-43 [=>]1.3 | \[ \color{blue}{\left(\log \ell \cdot w + 1\right) \cdot \left(e^{-w} \cdot \ell\right)}
\] |
rational.json-simplify-2 [=>]1.3 | \[ \color{blue}{\left(e^{-w} \cdot \ell\right) \cdot \left(\log \ell \cdot w + 1\right)}
\] |
exponential.json-simplify-2 [=>]1.3 | \[ \left(\color{blue}{\frac{1}{e^{w}}} \cdot \ell\right) \cdot \left(\log \ell \cdot w + 1\right)
\] |
rational.json-simplify-7 [<=]1.3 | \[ \left(\frac{1}{e^{w}} \cdot \color{blue}{\frac{\ell}{1}}\right) \cdot \left(\log \ell \cdot w + 1\right)
\] |
rational.json-simplify-55 [=>]1.3 | \[ \color{blue}{\frac{\frac{\ell}{1}}{\frac{e^{w}}{1}}} \cdot \left(\log \ell \cdot w + 1\right)
\] |
rational.json-simplify-7 [=>]1.3 | \[ \frac{\color{blue}{\ell}}{\frac{e^{w}}{1}} \cdot \left(\log \ell \cdot w + 1\right)
\] |
rational.json-simplify-7 [=>]1.3 | \[ \frac{\ell}{\color{blue}{e^{w}}} \cdot \left(\log \ell \cdot w + 1\right)
\] |
rational.json-simplify-1 [=>]1.3 | \[ \frac{\ell}{e^{w}} \cdot \color{blue}{\left(1 + \log \ell \cdot w\right)}
\] |
rational.json-simplify-17 [=>]1.3 | \[ \frac{\ell}{e^{w}} \cdot \color{blue}{\left(\log \ell \cdot w - -1\right)}
\] |
metadata-eval [<=]1.3 | \[ \frac{\ell}{e^{w}} \cdot \left(\log \ell \cdot w - \color{blue}{\left(-1 - 0\right)}\right)
\] |
rational.json-simplify-45 [<=]1.3 | \[ \frac{\ell}{e^{w}} \cdot \color{blue}{\left(0 - \left(-1 - \log \ell \cdot w\right)\right)}
\] |
rational.json-simplify-12 [<=]1.3 | \[ \frac{\ell}{e^{w}} \cdot \color{blue}{\left(-\left(-1 - \log \ell \cdot w\right)\right)}
\] |
rational.json-simplify-10 [=>]1.3 | \[ \frac{\ell}{e^{w}} \cdot \color{blue}{\frac{-1 - \log \ell \cdot w}{-1}}
\] |
rational.json-simplify-49 [<=]1.3 | \[ \color{blue}{\frac{\left(-1 - \log \ell \cdot w\right) \cdot \frac{\ell}{e^{w}}}{-1}}
\] |
rational.json-simplify-49 [<=]1.3 | \[ \frac{\color{blue}{\frac{\ell \cdot \left(-1 - \log \ell \cdot w\right)}{e^{w}}}}{-1}
\] |
rational.json-simplify-47 [=>]1.3 | \[ \color{blue}{\frac{\ell \cdot \left(-1 - \log \ell \cdot w\right)}{e^{w} \cdot -1}}
\] |
Taylor expanded in w around 0 1.3
if 0.0115 < w Initial program 0.1
Taylor expanded in w around 0 1.4
Applied egg-rr0.9
Final simplification1.2
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 19520 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 19456 |
| Alternative 3 | |
|---|---|
| Error | 1.4 |
| Cost | 13440 |
| Alternative 4 | |
|---|---|
| Error | 1.9 |
| Cost | 6656 |
| Alternative 5 | |
|---|---|
| Error | 1.9 |
| Cost | 6592 |
| Alternative 6 | |
|---|---|
| Error | 2.6 |
| Cost | 516 |
| Alternative 7 | |
|---|---|
| Error | 2.6 |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 13.7 |
| Cost | 64 |
herbie shell --seed 2023075
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))