Average Error: 0.1 → 0.1
Time: 18.0s
Precision: binary32
Cost: 3744
\[\left(\left(\left(\left(-1 \leq cosTheta_i \land cosTheta_i \leq 1\right) \land \left(-1 \leq cosTheta_O \land cosTheta_O \leq 1\right)\right) \land \left(-1 \leq sinTheta_i \land sinTheta_i \leq 1\right)\right) \land \left(-1 \leq sinTheta_O \land sinTheta_O \leq 1\right)\right) \land \left(-1.5707964 \leq v \land v \leq 0.1\right)\]
\[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)} \]
\[\frac{e^{0.6931 + \frac{-1}{v}}}{v} \cdot \left(0.5 + -0.5 \cdot \left(sinTheta_O \cdot \frac{sinTheta_i}{v}\right)\right) \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (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 binary32
 (*
  (/ (exp (+ 0.6931 (/ -1.0 v))) v)
  (+ 0.5 (* -0.5 (* sinTheta_O (/ sinTheta_i v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return expf(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0f / v)) + 0.6931f) + logf((1.0f / (2.0f * v)))));
}
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf((0.6931f + (-1.0f / v))) / v) * (0.5f + (-0.5f * (sinTheta_O * (sinTheta_i / v))));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = exp(((((((costheta_i * costheta_o) / v) - ((sintheta_i * sintheta_o) / v)) - (1.0e0 / v)) + 0.6931e0) + log((1.0e0 / (2.0e0 * v)))))
end function
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp((0.6931e0 + ((-1.0e0) / v))) / v) * (0.5e0 + ((-0.5e0) * (sintheta_o * (sintheta_i / v))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return exp(Float32(Float32(Float32(Float32(Float32(Float32(cosTheta_i * cosTheta_O) / v) - Float32(Float32(sinTheta_i * sinTheta_O) / v)) - Float32(Float32(1.0) / v)) + Float32(0.6931)) + log(Float32(Float32(1.0) / Float32(Float32(2.0) * v)))))
end
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(Float32(0.6931) + Float32(Float32(-1.0) / v))) / v) * Float32(Float32(0.5) + Float32(Float32(-0.5) * Float32(sinTheta_O * Float32(sinTheta_i / 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)) - (single(1.0) / v)) + single(0.6931)) + log((single(1.0) / (single(2.0) * v)))));
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp((single(0.6931) + (single(-1.0) / v))) / v) * (single(0.5) + (single(-0.5) * (sinTheta_O * (sinTheta_i / v))));
end
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)}
\frac{e^{0.6931 + \frac{-1}{v}}}{v} \cdot \left(0.5 + -0.5 \cdot \left(sinTheta_O \cdot \frac{sinTheta_i}{v}\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

    \[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)} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(cosTheta_i, \frac{cosTheta_O}{v}, 0.6931\right) - \mathsf{fma}\left(sinTheta_i, \frac{sinTheta_O}{v}, \frac{1}{v}\right)} \cdot \frac{0.5}{v}} \]
    Proof
    (*.f32 (exp.f32 (-.f32 (fma.f32 cosTheta_i (/.f32 cosTheta_O v) 6931/10000) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (Rewrite<= fma-def_binary32 (+.f32 (*.f32 cosTheta_i (/.f32 cosTheta_O v)) 6931/10000)) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 (Rewrite<= *-commutative_binary32 (*.f32 (/.f32 cosTheta_O v) cosTheta_i)) 6931/10000) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 (Rewrite=> associate-*l/_binary32 (/.f32 (*.f32 cosTheta_O cosTheta_i) v)) 6931/10000) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 (/.f32 (Rewrite<= *-commutative_binary32 (*.f32 cosTheta_i cosTheta_O)) v) 6931/10000) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (Rewrite<= +-commutative_binary32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v))) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (fma.f32 sinTheta_i (/.f32 sinTheta_O v) (Rewrite<= remove-double-neg_binary32 (neg.f32 (neg.f32 (/.f32 1 v))))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (Rewrite<= fma-neg_binary32 (-.f32 (*.f32 sinTheta_i (/.f32 sinTheta_O v)) (neg.f32 (/.f32 1 v)))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (-.f32 (Rewrite=> associate-*r/_binary32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (neg.f32 (/.f32 1 v))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (Rewrite<= associate-+r-_binary32 (+.f32 6931/10000 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (-.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (neg.f32 (/.f32 1 v))))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (Rewrite<= associate-+l-_binary32 (+.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (neg.f32 (/.f32 1 v)))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (Rewrite<= sub-neg_binary32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (Rewrite=> associate--l-_binary32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (Rewrite=> associate-+r-_binary32 (-.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (Rewrite<= +-rgt-identity_binary32 (+.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) 0)) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (Rewrite<= metadata-eval (log.f32 1))) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (+.f32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (Rewrite=> metadata-eval 0)) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (-.f32 (Rewrite=> +-rgt-identity_binary32 (+.f32 6931/10000 (/.f32 (*.f32 cosTheta_i cosTheta_O) v))) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (Rewrite<= associate-+r-_binary32 (+.f32 6931/10000 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (+.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 1 v)))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (Rewrite<= associate--l-_binary32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v))))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (Rewrite<= +-commutative_binary32 (+.f32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v)) 6931/10000))) (/.f32 1/2 v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v)) 6931/10000)) (/.f32 (Rewrite<= metadata-eval (/.f32 1 2)) v)): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v)) 6931/10000)) (Rewrite<= associate-/r*_binary32 (/.f32 1 (*.f32 2 v)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v)) 6931/10000)) (Rewrite<= rem-exp-log_binary32 (exp.f32 (log.f32 (/.f32 1 (*.f32 2 v)))))): 5 points increase in error, 3 points decrease in error
    (Rewrite<= exp-sum_binary32 (exp.f32 (+.f32 (+.f32 (-.f32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 1 v)) 6931/10000) (log.f32 (/.f32 1 (*.f32 2 v)))))): 8 points increase in error, 3 points decrease in error
  3. Taylor expanded in cosTheta_i around 0 0.1

    \[\leadsto e^{\color{blue}{0.6931 - \left(\frac{1}{v} + \frac{sinTheta_i \cdot sinTheta_O}{v}\right)}} \cdot \frac{0.5}{v} \]
  4. Taylor expanded in v around 0 0.1

    \[\leadsto e^{0.6931 - \color{blue}{\frac{1 + sinTheta_i \cdot sinTheta_O}{v}}} \cdot \frac{0.5}{v} \]
  5. Taylor expanded in sinTheta_i around 0 13.7

    \[\leadsto \color{blue}{-0.5 \cdot \frac{sinTheta_i \cdot \left(sinTheta_O \cdot e^{0.6931 - \frac{1}{v}}\right)}{{v}^{2}} + 0.5 \cdot \frac{e^{0.6931 - \frac{1}{v}}}{v}} \]
  6. Simplified0.1

    \[\leadsto \color{blue}{\frac{e^{0.6931 + \frac{-1}{v}}}{v} \cdot \left(0.5 + -0.5 \cdot \left(sinTheta_O \cdot \frac{sinTheta_i}{v}\right)\right)} \]
    Proof
    (*.f32 (/.f32 (exp.f32 (+.f32 6931/10000 (/.f32 -1 v))) v) (+.f32 1/2 (*.f32 -1/2 (*.f32 sinTheta_O (/.f32 sinTheta_i v))))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (exp.f32 (+.f32 6931/10000 (/.f32 (Rewrite<= metadata-eval (neg.f32 1)) v))) v) (+.f32 1/2 (*.f32 -1/2 (*.f32 sinTheta_O (/.f32 sinTheta_i v))))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (exp.f32 (+.f32 6931/10000 (Rewrite<= distribute-neg-frac_binary32 (neg.f32 (/.f32 1 v))))) v) (+.f32 1/2 (*.f32 -1/2 (*.f32 sinTheta_O (/.f32 sinTheta_i v))))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (exp.f32 (Rewrite<= sub-neg_binary32 (-.f32 6931/10000 (/.f32 1 v)))) v) (+.f32 1/2 (*.f32 -1/2 (*.f32 sinTheta_O (/.f32 sinTheta_i v))))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v) (+.f32 1/2 (*.f32 -1/2 (Rewrite<= *-commutative_binary32 (*.f32 (/.f32 sinTheta_i v) sinTheta_O))))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v) (+.f32 1/2 (*.f32 -1/2 (Rewrite=> associate-*l/_binary32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-out_binary32 (+.f32 (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)) (*.f32 (*.f32 -1/2 (/.f32 (*.f32 sinTheta_i sinTheta_O) v)) (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)) (Rewrite<= associate-*r*_binary32 (*.f32 -1/2 (*.f32 (/.f32 (*.f32 sinTheta_i sinTheta_O) v) (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)) (*.f32 -1/2 (Rewrite<= times-frac_binary32 (/.f32 (*.f32 (*.f32 sinTheta_i sinTheta_O) (exp.f32 (-.f32 6931/10000 (/.f32 1 v)))) (*.f32 v v))))): 109 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)) (*.f32 -1/2 (/.f32 (Rewrite<= associate-*r*_binary32 (*.f32 sinTheta_i (*.f32 sinTheta_O (exp.f32 (-.f32 6931/10000 (/.f32 1 v)))))) (*.f32 v v)))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)) (*.f32 -1/2 (/.f32 (*.f32 sinTheta_i (*.f32 sinTheta_O (exp.f32 (-.f32 6931/10000 (/.f32 1 v))))) (Rewrite<= unpow2_binary32 (pow.f32 v 2))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary32 (+.f32 (*.f32 -1/2 (/.f32 (*.f32 sinTheta_i (*.f32 sinTheta_O (exp.f32 (-.f32 6931/10000 (/.f32 1 v))))) (pow.f32 v 2))) (*.f32 1/2 (/.f32 (exp.f32 (-.f32 6931/10000 (/.f32 1 v))) v)))): 0 points increase in error, 0 points decrease in error
  7. Final simplification0.1

    \[\leadsto \frac{e^{0.6931 + \frac{-1}{v}}}{v} \cdot \left(0.5 + -0.5 \cdot \left(sinTheta_O \cdot \frac{sinTheta_i}{v}\right)\right) \]

Alternatives

Alternative 1
Error0.1
Cost3680
\[e^{0.6931 + \left(\frac{-1}{v} - \frac{sinTheta_O \cdot sinTheta_i}{v}\right)} \cdot \frac{0.5}{v} \]
Alternative 2
Error0.1
Cost3616
\[\frac{0.5}{v} \cdot e^{0.6931 - \frac{1 + sinTheta_O \cdot sinTheta_i}{v}} \]
Alternative 3
Error0.1
Cost3488
\[\frac{0.5}{v} \cdot e^{0.6931 + \frac{-1}{v}} \]
Alternative 4
Error0.7
Cost3296
\[e^{\frac{-1}{v}} \]
Alternative 5
Error28.5
Cost288
\[sinTheta_O \cdot \frac{\frac{-0.5}{\frac{v}{sinTheta_i}}}{v} \]
Alternative 6
Error30.5
Cost96
\[\frac{0.5}{v} \]

Error

Reproduce

herbie shell --seed 2022318 
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
  :name "HairBSDF, Mp, lower"
  :precision binary32
  :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))))))