MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / csc

Function csc

src/compute-engine/interval/trigonometric.ts:192–223  ·  view source on GitHub ↗
(x: Interval | IntervalResult)

Source from the content-addressed store, hash-verified

190}
191
192/**
193 * Where the pole found by the pole search lies relative to the interval
194 * `x`: `'lo'` when it is at or below the lower endpoint (and the next pole
195 * is above the upper one), `'hi'` when it is at or above the upper endpoint
196 * (and the previous pole is below the lower one), and `undefined` when the
197 * pole is inside `x` or the side cannot be decided.
198 *
199 * `at` is the location the search answered, a double near the pole, and
200 * `extremum` is the first pole of the family (`π/2` for `tan` and `sec`, 0
201 * for `cot` and `csc`); the poles are `π` apart.
202 *
203 * A POINT interval answers `undefined`, so the kernel answers `singular`:
204 * a point near a pole is a pole by the machine rule that the interpreter
205 * and compiled JavaScript apply (`machinePole`), and the point at the exact
206 * pole 0 (`cot(0)`, `csc(0)`) is the pole `~oo` of the interpreter. The
207 * compiled `interval-js` code answers `singular` wherever the interpreter
208 * answers that pole (`test/compute-engine/compile-trig-poles.test.ts`).
209 */
210function poleSide(
211 x: Interval,
212 at: number,
213 extremum: number
214): 'lo' | 'hi' | undefined {
215 if (x.lo === x.hi) return undefined;
216 const m = Math.round((at - extremum) / PI) + (extremum === 0 ? 0 : 0.5);
217 const sLo = compareWithPiMultiple(x.lo, m);
218 const sHi = compareWithPiMultiple(x.hi, m);
219 if (sLo === undefined || sHi === undefined) return undefined;
220 if (sLo >= 0)
221 return compareWithPiMultiple(x.hi, m + 1) === -1 ? 'lo' : undefined;
222 if (sHi <= 0)
223 return compareWithPiMultiple(x.lo, m - 1) === 1 ? 'hi' : undefined;
224 return undefined;
225}
226

Callers 1

Calls 5

unwrapOrPropagateFunction · 0.90
containsExtremumFunction · 0.90
okFunction · 0.90
sinMethod · 0.80
ceilMethod · 0.45

Tested by

no test coverage detected