(x: Interval | IntervalResult)
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Arc sine (inverse sine). |
| 232 | * |
| 233 | * Domain: [-1, 1], Range: [-pi/2, pi/2] |
| 234 | */ |
| 235 | export function asin(x: Interval | IntervalResult): IntervalResult { |
| 236 | const unwrapped = unwrapOrPropagate(x); |
| 237 | if (!Array.isArray(unwrapped)) return unwrapped; |
| 238 | const [xVal] = unwrapped; |
| 239 | // Entirely outside domain |
| 240 | if (xVal.lo > 1 || xVal.hi < -1) { |
| 241 | return { kind: 'empty' }; |
| 242 | } |
| 243 | |
| 244 | // Clip to domain if needed |
| 245 | if (xVal.lo < -1 || xVal.hi > 1) { |
| 246 | const clippedLo = Math.max(xVal.lo, -1); |
| 247 | const clippedHi = Math.min(xVal.hi, 1); |
| 248 | return { |
| 249 | kind: 'partial', |
| 250 | value: { lo: Math.asin(clippedLo), hi: Math.asin(clippedHi) }, |
| 251 | domainClipped: |
| 252 | xVal.lo < -1 && xVal.hi > 1 ? 'both' : xVal.lo < -1 ? 'lo' : 'hi', |
| 253 | }; |
| 254 | } |
| 255 | |
| 256 | // Within domain - asin is monotonically increasing |
no test coverage detected