( ce: ComputeEngine, e: Expression )
| 3908 | return cosE; |
| 3909 | case 'Tan': |
| 3910 | return sinE.div(cosE); |
| 3911 | case 'Cot': |
| 3912 | return cosE.div(sinE); |
| 3913 | case 'Sec': |
| 3914 | return ce.One.div(cosE); |
| 3915 | case 'Csc': |
| 3916 | return ce.One.div(sinE); |
| 3917 | } |
| 3918 | } |
| 3919 | return ce.function( |
| 3920 | u.operator, |
| 3921 | u.ops.map((o) => substForTrig(o, sinE, cosE, v, ce)) |
| 3922 | ); |
| 3923 | } |
| 3924 | |
| 3925 | /** SubstFor[v, u, x] — u with the trig subexpression `v` replaced by `x` |
| 3926 | * (u is a function of v). Returns null when v isn't a handled trig target. */ |
| 3927 | function substFor3(v: Expression, u: Expression, ctx: Ctx): Expression | null { |
| 3928 | const ce = ctx.ce; |
| 3929 | const X = ce.symbol(ctx.x); |
| 3930 | const vt = substTrigNode(v, ctx.x, ce); |
| 3931 | if (vt === null) return null; |
| 3932 | // d ≠ 1 (a free factor on the substitution variable) is not handled here. |
| 3933 | if (!selectFactors(v, ctx.x, ce, true).isSame(1)) return null; |
| 3934 | const arg = vt.ops![0]; |
| 3935 | const sqrt1m = ce.function('Sqrt', [ce.One.sub(X.pow(2))]); // √(1−x²) |
| 3936 | const sqrt1p = ce.function('Sqrt', [ce.One.add(X.pow(2))]); // √(1+x²) |
no test coverage detected