| Alternative 1 | |
|---|---|
| Error | 29.0 |
| Cost | 6980 |
\[\begin{array}{l}
t_0 := \frac{cosTheta_i \cdot cosTheta_O}{v}\\
\mathbf{if}\;cosTheta_i \cdot cosTheta_O \leq -8.6 \cdot 10^{-283}:\\
\;\;\;\;e^{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary64
(exp
(+
(+
(-
(- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v))
(/ 1.0 v))
0.6931)
(log (/ 1.0 (* 2.0 v))))))(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary64 (exp (/ (- (* cosTheta_i cosTheta_O) 1.0) v)))
double code(double cosTheta_i, double cosTheta_O, double sinTheta_i, double sinTheta_O, double v) {
return exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0 / v)) + 0.6931) + log((1.0 / (2.0 * v)))));
}
double code(double cosTheta_i, double cosTheta_O, double sinTheta_i, double sinTheta_O, double v) {
return exp((((cosTheta_i * cosTheta_O) - 1.0) / v));
}
real(8) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(8), intent (in) :: costheta_i
real(8), intent (in) :: costheta_o
real(8), intent (in) :: sintheta_i
real(8), intent (in) :: sintheta_o
real(8), intent (in) :: v
code = exp(((((((costheta_i * costheta_o) / v) - ((sintheta_i * sintheta_o) / v)) - (1.0d0 / v)) + 0.6931d0) + log((1.0d0 / (2.0d0 * v)))))
end function
real(8) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(8), intent (in) :: costheta_i
real(8), intent (in) :: costheta_o
real(8), intent (in) :: sintheta_i
real(8), intent (in) :: sintheta_o
real(8), intent (in) :: v
code = exp((((costheta_i * costheta_o) - 1.0d0) / v))
end function
public static double code(double cosTheta_i, double cosTheta_O, double sinTheta_i, double sinTheta_O, double v) {
return Math.exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0 / v)) + 0.6931) + Math.log((1.0 / (2.0 * v)))));
}
public static double code(double cosTheta_i, double cosTheta_O, double sinTheta_i, double sinTheta_O, double v) {
return Math.exp((((cosTheta_i * cosTheta_O) - 1.0) / v));
}
def code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v): return math.exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0 / v)) + 0.6931) + math.log((1.0 / (2.0 * v)))))
def code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v): return math.exp((((cosTheta_i * cosTheta_O) - 1.0) / v))
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float64(Float64(Float64(Float64(Float64(Float64(cosTheta_i * cosTheta_O) / v) - Float64(Float64(sinTheta_i * sinTheta_O) / v)) - Float64(1.0 / v)) + 0.6931) + log(Float64(1.0 / Float64(2.0 * v))))) end
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float64(Float64(Float64(cosTheta_i * cosTheta_O) - 1.0) / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0 / v)) + 0.6931) + log((1.0 / (2.0 * v))))); end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp((((cosTheta_i * cosTheta_O) - 1.0) / v)); end
code[cosTheta$95$i_, cosTheta$95$O_, sinTheta$95$i_, sinTheta$95$O_, v_] := N[Exp[N[(N[(N[(N[(N[(N[(cosTheta$95$i * cosTheta$95$O), $MachinePrecision] / v), $MachinePrecision] - N[(N[(sinTheta$95$i * sinTheta$95$O), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] - N[(1.0 / v), $MachinePrecision]), $MachinePrecision] + 0.6931), $MachinePrecision] + N[Log[N[(1.0 / N[(2.0 * v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[cosTheta$95$i_, cosTheta$95$O_, sinTheta$95$i_, sinTheta$95$O_, v_] := N[Exp[N[(N[(N[(cosTheta$95$i * cosTheta$95$O), $MachinePrecision] - 1.0), $MachinePrecision] / v), $MachinePrecision]], $MachinePrecision]
e^{\left(\left(\left(\frac{cosTheta_i \cdot cosTheta_O}{v} - \frac{sinTheta_i \cdot sinTheta_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)}
e^{\frac{cosTheta_i \cdot cosTheta_O - 1}{v}}
Results
Initial program 0.0
Simplified0.0
Taylor expanded in cosTheta_O around inf 0.0
Taylor expanded in v around 0 0.4
Taylor expanded in v around 0 0.4
| Alternative 1 | |
|---|---|
| Error | 29.0 |
| Cost | 6980 |
| Alternative 2 | |
|---|---|
| Error | 33.9 |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Error | 62.0 |
| Cost | 64 |
herbie shell --seed 2023033
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:name "HairBSDF, Mp, lower"
:precision binary64
:pre (and (and (and (and (and (<= -1.0 cosTheta_i) (<= cosTheta_i 1.0)) (and (<= -1.0 cosTheta_O) (<= cosTheta_O 1.0))) (and (<= -1.0 sinTheta_i) (<= sinTheta_i 1.0))) (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0))) (and (<= -1.5707964 v) (<= v 0.1)))
(exp (+ (+ (- (- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v)) (/ 1.0 v)) 0.6931) (log (/ 1.0 (* 2.0 v))))))