Skip to content

Commit 109b8be

Browse files
committed
+/-/sin
1 parent b62f93d commit 109b8be

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/core/explain.rkt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168

169169
(define cond-x (abs (/ xfl (+ xfl yfl))))
170170
(define cond-y (abs (/ yfl (+ xfl yfl))))
171-
;(define cond-x.l (logabs (log/ xlog (log+ xlog ylog))))
172-
;(define cond-y.l (logabs (log/ ylog (log+ xlog ylog))))
171+
(define cond-x.l (logabs (log/ xlog (log+ xlog ylog))))
172+
(define cond-y.l (logabs (log/ ylog (log+ xlog ylog))))
173173

174174
(define x.eps (+ 127 (bigfloat-exponent (exacts-ref x-ex))))
175175
(define y.eps (+ 127 (bigfloat-exponent (exacts-ref y-ex))))
@@ -198,10 +198,10 @@
198198

199199
; High condition number:
200200
; CN(+, x, y) = |x / x + y|
201-
[(or (> cond-x 100) (> cond-y 100)) (mark-erroneous! subexpr 'cancellation)]
201+
[(or (log> cond-x.l 100.l) (log> cond-y.l 100.l)) (mark-erroneous! subexpr 'cancellation)]
202202

203203
; Maybe
204-
[(or (> cond-x 32) (> cond-y 32)) (mark-maybe! subexpr 'cancellation)]
204+
[(or (log> cond-x.l 32.l) (log> cond-y.l 32.l)) (mark-maybe! subexpr 'cancellation)]
205205
[else #f])]
206206

207207
[(list (or '-.f64 '-.f32) x-ex y-ex)
@@ -213,6 +213,8 @@
213213

214214
(define cond-x (abs (/ xfl (- xfl yfl))))
215215
(define cond-y (abs (/ yfl (- xfl yfl))))
216+
(define cond-x.l (logabs (log/ xlog (log- xlog ylog))))
217+
(define cond-y.l (logabs (log/ ylog (log- xlog ylog))))
216218

217219
(define x.eps (+ 127 (bigfloat-exponent (exacts-ref x-ex))))
218220
(define y.eps (+ 127 (bigfloat-exponent (exacts-ref y-ex))))
@@ -240,10 +242,10 @@
240242

241243
; High condition number:
242244
; CN(+, x, y) = |x / x - y|
243-
[(or (> cond-x 100) (> cond-y 100)) (mark-erroneous! subexpr 'cancellation)]
245+
[(or (log> cond-x.l 100.l) (log> cond-y.l 100.l)) (mark-erroneous! subexpr 'cancellation)]
244246

245247
; Maybe
246-
[(or (> cond-x 32) (> cond-y 32)) (mark-maybe! subexpr 'cancellation)]
248+
[(or (log> cond-x.l 32.l) (log> cond-y.l 32.l)) (mark-maybe! subexpr 'cancellation)]
247249
[else #f])]
248250

249251
[(list (or 'sin.f64 'sin.f32) x-ex)
@@ -252,16 +254,19 @@
252254
(match-define (logfl xfl xs xe) xlog)
253255
(define cot-x (abs (/ 1.0 (tan xfl))))
254256
(define cond-no (* (abs xfl) cot-x))
257+
258+
(define cot-x.l (logabs (log/ 1.l (logtan xlog))))
259+
(define cond-no.l (log* (logabs xlog) cot-x.l))
255260
(cond
256261
[(overflow? xlog) (mark-erroneous! subexpr 'oflow-rescue)]
257262

258-
[(and (> cond-no 100) (> (abs xfl) 100)) (mark-erroneous! subexpr 'sensitivity)]
263+
[(and (log> cond-no.l 100.l) (log> (logabs xlog) 100.l)) (mark-erroneous! subexpr 'sensitivity)]
259264

260-
[(and (> cond-no 100) (> cot-x 100)) (mark-erroneous! subexpr 'cancelation)]
265+
[(and (log> cond-no.l 100.l) (log> cot-x.l 100.l)) (mark-erroneous! subexpr 'cancelation)]
261266

262-
[(and (> cond-no 100) (> (abs xfl) 100)) (mark-maybe! subexpr 'sensitivity)]
267+
[(and (log> cond-no.l 100.l) (log> (logabs xlog) 100.l)) (mark-maybe! subexpr 'sensitivity)]
263268

264-
[(and (> cond-no 32) (> cot-x 32)) (mark-maybe! subexpr 'cancellation)]
269+
[(and (log> cond-no.l 32.l) (log> cot-x.l 32.l)) (mark-maybe! subexpr 'cancellation)]
265270

266271
[else #f])]
267272

src/core/logspace.rkt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,4 @@
252252
[(list op args ...) (cons (op->logop op) (map expr->logfl args))]
253253
[sym sym]))
254254

255-
(define x (flonum->logfl 2e+103))
256255
(define 1.l (flonum->logfl 1.0))
257-
(define 2.l (flonum->logfl 2.0))
258-
259-
(define x+1 (log+ x 1.l))
260-
(define 1/x+1 (log/ 1.l x+1))
261-
262-
(define 2/x (log/ 2.l x))
263-
264-
(define res (log- 1/x+1 2/x))

0 commit comments

Comments
 (0)