Skip to content

Commit

Permalink
expt
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavkulk committed Sep 23, 2024
1 parent 91466d4 commit 675a883
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/core/explain.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@
(define cond-x (abs yfl))
(define cond-y (abs (* yfl (log xfl))))

(define cond-x.l (logabs ylog))
(define cond-y.l (logabs (log* ylog (logln xlog))))

(cond
;; Hallucination:
;; x has a large exponent and y is 1. The ylogx is large but there is
Expand Down Expand Up @@ -517,10 +520,10 @@

[(and (overflow? xlog) (<= se MAX-EXP)) (mark-erroneous! subexpr 'oflow-rescue)]

[(and (or (> cond-x 100) (> cond-y 100)) (not (constant? y-ex)))
[(and (or (log> cond-x.l 100.l) (log> cond-y.l 100.l)) (not (constant? y-ex)))
(mark-erroneous! subexpr 'sensitivity)]

[(and (or (> cond-x 32) (> cond-y 32)) (not (constant? y-ex)))
[(and (or (log> cond-x.l 32.l) (log> cond-y.l 32.l)) (not (constant? y-ex)))
(mark-maybe! subexpr 'sensitivity)]

[else #f])]
Expand Down
9 changes: 8 additions & 1 deletion src/core/logspace.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@
#true
(* a (fllog2 euler.0))))

(define (logexpt A B)
(match-define (logfl a sa ea) A)
(match-define (logfl b sb eb) B)
(logfl (exp a)
(>= (expt a b) 0.0)
(* a (fllog2 b))))

(define (logsqrt A)
(match-define (logfl a sa ea) A)
(logfl (sqrt a)
Expand Down Expand Up @@ -193,7 +200,7 @@
['log/ log/]
['logln logln]
['logexp logexp]
; ['logexpt logexpt]
['logexpt logexpt]
['logsin logsin]
['logcos logcos]
['logtan logtan]
Expand Down

0 comments on commit 675a883

Please sign in to comment.