|
154 | 154 | (define-rules arithmetic |
155 | 155 | [mult-flip (/ a b) (* a (/ 1 b))] |
156 | 156 | [mult-flip-rev (* a (/ 1 b)) (/ a b)] |
157 | | - [div-flip (/ a b) (/ 1 (/ b a)) #:unsound] ; unsound @ a = 0, b != 0 |
| 157 | + [div-flip (/ a b) (sound-/ 1 (sound-/ b a 0) (/ a b))] |
158 | 158 | [div-flip-rev (/ 1 (/ b a)) (/ a b)]) |
159 | 159 |
|
160 | 160 | ; Fractions |
|
171 | 171 |
|
172 | 172 | (define-rules polynomials |
173 | 173 | [sqr-pow (pow a b) (* (pow a (/ b 2)) (pow a (/ b 2))) #:unsound] ; unsound @ a = -1, b = 1 |
174 | | - [flip-+ (+ a b) (sound-/ (- (* a a) (* b b)) (- a b) (+ a b))] ; unsound @ a = b = 1 |
175 | | - [flip-- (- a b) (sound-/ (- (* a a) (* b b)) (+ a b) (- a b))]) ; unsound @ a = -1, b = 1 |
| 174 | + [flip-+ (+ a b) (sound-/ (- (* a a) (* b b)) (- a b) (+ a b))] |
| 175 | + [flip-- (- a b) (sound-/ (- (* a a) (* b b)) (+ a b) (- a b))]) |
176 | 176 |
|
177 | 177 | ; Difference of cubes |
178 | 178 | (define-rules polynomials |
|
181 | 181 | [difference-cubes-rev (* (+ (* a a) (+ (* b b) (* a b))) (- a b)) (- (pow a 3) (pow b 3))] |
182 | 182 | [sum-cubes-rev (* (+ (* a a) (- (* b b) (* a b))) (+ a b)) (+ (pow a 3) (pow b 3))]) |
183 | 183 |
|
184 | | -(define-rules polynomials ; unsound @ a = b = 0 |
| 184 | +(define-rules polynomials |
185 | 185 | [flip3-+ (+ a b) (sound-/ (+ (pow a 3) (pow b 3)) (+ (* a a) (- (* b b) (* a b))) (+ a b))] |
186 | 186 | [flip3-- (- a b) (sound-/ (- (pow a 3) (pow b 3)) (+ (* a a) (+ (* b b) (* a b))) (- a b))]) |
187 | 187 |
|
|
245 | 245 | [sqrt-undiv (/ (sqrt x) (sqrt y)) (sqrt (/ x y))]) |
246 | 246 |
|
247 | 247 | (define-rules arithmetic |
248 | | - [sqrt-prod (sqrt (* x y)) (* (sqrt x) (sqrt y)) #:unsound] ; unsound @ x = y = -1 |
249 | | - [sqrt-div (sqrt (/ x y)) (/ (sqrt x) (sqrt y)) #:unsound] ; unsound @ x = y = -1 |
| 248 | + [sqrt-prod (sqrt (* x y)) (* (sqrt (fabs x)) (sqrt (fabs y)))] |
| 249 | + [sqrt-div (sqrt (/ x y)) (/ (sqrt (fabs x)) (sqrt (fabs y)))] |
250 | 250 | [add-sqr-sqrt x (* (sqrt x) (sqrt x)) #:unsound]) ; unsound @ x = -1 |
251 | 251 |
|
252 | 252 | ; Cubing |
|
364 | 364 | [log-pow-rev (* b (log a)) (log (pow a b))]) |
365 | 365 |
|
366 | 366 | (define-rules exponents |
367 | | - [log-prod (log (* a b)) (+ (log a) (log b)) #:unsound] ; unsound @ a = b = -1 |
368 | | - [log-div (log (/ a b)) (- (log a) (log b)) #:unsound] ; unsound @ a = b = -1 |
369 | | - [log-pow (log (pow a b)) (* b (log a)) #:unsound]) ; unsound @ a = -1, b = 2 |
| 367 | + [log-prod (log (* a b)) (+ (log (fabs a)) (log (fabs b)))] |
| 368 | + [log-div (log (/ a b)) (- (log (fabs a)) (log (fabs b)))] |
| 369 | + [log-pow (log (pow a b)) (* b (log (fabs a)))]) |
370 | 370 |
|
371 | 371 | (define-rules exponents |
372 | 372 | [sum-log (+ (log a) (log b)) (log (* a b))] |
|
0 commit comments