UniformSampleCone, x

Specification

?
\[\left(\left(2.328306437 \cdot 10^{-10} \leq ux \land ux \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \]
(FPCore (ux uy maxCos)
  :precision binary32
  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0))
          (and (<= 2.328306437e-10 uy) (<= uy 1.0)))
     (and (<= 0.0 maxCos) (<= maxCos 1.0)))
  (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
  (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}

Reproduce

?
herbie shell --seed 2025360 
(FPCore (ux uy maxCos)
  :name "UniformSampleCone, x"
  :precision binary32
  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
  (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))

Please file a bug report with this information.

Backtrace

timeline-push!: contract violation expected: jsexpr? given: '#hash((nodes . (2 ("PI") 1 0 1/2 -2 ("+" 1 1))) (roots . (0 1 2 3 4 5 6))) in: the repeated argument of (-> symbol? jsexpr? ... void?) contract from: <pkgs>/herbie/utils/timeline.rkt blaming: <pkgs>/herbie/core/patch.rkt (assuming the contract is correct) at: <pkgs>/herbie/utils/timeline.rkt:9:24LC
raise-blame-error/usr/share/racket/collects/racket/contract/private/blame.rkt3460
loop/usr/share/racket/collects/racket/contract/private/list.rkt99112
(unnamed).../private/arrow-val-first.rkt48618
run-evaluate/home/nightlies/herbie/batch-timeline/src/core/patch.rkt1170
generate-candidates/home/nightlies/herbie/batch-timeline/src/core/patch.rkt2040
run-iteration!/home/nightlies/herbie/batch-timeline/src/core/mainloop.rkt2390
run-improve!/home/nightlies/herbie/batch-timeline/src/core/mainloop.rkt470
get-alternatives/home/nightlies/herbie/batch-timeline/src/api/sandbox.rkt610
(unnamed)/home/nightlies/herbie/batch-timeline/src/api/sandbox.rkt1816
(unnamed)/usr/share/racket/pkgs/profile-lib/main.rkt4010
profile-thunk/usr/share/racket/pkgs/profile-lib/main.rkt90
in-engine/home/nightlies/herbie/batch-timeline/src/api/sandbox.rkt1972
(unnamed)/usr/share/racket/collects/racket/engine.rkt4224