|
168 | 168 |
|
169 | 169 | (define cond-x (abs (/ xfl (+ xfl yfl)))) |
170 | 170 | (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)))) |
173 | 173 |
|
174 | 174 | (define x.eps (+ 127 (bigfloat-exponent (exacts-ref x-ex)))) |
175 | 175 | (define y.eps (+ 127 (bigfloat-exponent (exacts-ref y-ex)))) |
|
198 | 198 |
|
199 | 199 | ; High condition number: |
200 | 200 | ; 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)] |
202 | 202 |
|
203 | 203 | ; 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)] |
205 | 205 | [else #f])] |
206 | 206 |
|
207 | 207 | [(list (or '-.f64 '-.f32) x-ex y-ex) |
|
213 | 213 |
|
214 | 214 | (define cond-x (abs (/ xfl (- xfl yfl)))) |
215 | 215 | (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)))) |
216 | 218 |
|
217 | 219 | (define x.eps (+ 127 (bigfloat-exponent (exacts-ref x-ex)))) |
218 | 220 | (define y.eps (+ 127 (bigfloat-exponent (exacts-ref y-ex)))) |
|
240 | 242 |
|
241 | 243 | ; High condition number: |
242 | 244 | ; 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)] |
244 | 246 |
|
245 | 247 | ; 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)] |
247 | 249 | [else #f])] |
248 | 250 |
|
249 | 251 | [(list (or 'sin.f64 'sin.f32) x-ex) |
|
252 | 254 | (match-define (logfl xfl xs xe) xlog) |
253 | 255 | (define cot-x (abs (/ 1.0 (tan xfl)))) |
254 | 256 | (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)) |
255 | 260 | (cond |
256 | 261 | [(overflow? xlog) (mark-erroneous! subexpr 'oflow-rescue)] |
257 | 262 |
|
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)] |
259 | 264 |
|
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)] |
261 | 266 |
|
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)] |
263 | 268 |
|
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)] |
265 | 270 |
|
266 | 271 | [else #f])] |
267 | 272 |
|
|
0 commit comments