DerivativeDivides[y, u, x] — see block comment. Returns the x-free quotient * or the `False` symbol.
(y: Expression, u: Expression, ctx: Ctx)
| 3082 | if (!c.ops || polyDegreeX(c.ops[0], x) !== 1) return null; |
| 3083 | const coef = |
| 3084 | rest.length === 0 |
| 3085 | ? t.engine.One |
| 3086 | : rest.length === 1 |
| 3087 | ? rest[0] |
| 3088 | : t.engine.function('Multiply', rest); |
| 3089 | return { coef, arg: c.ops[0] }; |
| 3090 | } |
| 3091 | return null; |
| 3092 | } |
| 3093 | |
| 3094 | /** `a + b·cos[arg]` → `a + b·sin[arg + π/2]` when the base's only x-dependence |
| 3095 | * is a single linear-argument cosine (the standalone-cosine clause); else null. */ |
| 3096 | function cosBaseToSin( |
| 3097 | ce: ComputeEngine, |
| 3098 | base: Expression, |
| 3099 | x: string |
| 3100 | ): Expression | null { |
| 3101 | const terms = base.operator === 'Add' && base.ops ? base.ops : [base]; |
| 3102 | let a = ce.Zero; |
| 3103 | let cosCoef: Expression | null = null; |
| 3104 | let cosArg: Expression | null = null; |
| 3105 | for (const t of terms) { |
| 3106 | if (!t.has(x)) { |
| 3107 | a = a.add(t); |
| 3108 | continue; |
| 3109 | } |
| 3110 | const parts = cosTermParts(t, x); |
| 3111 | if (parts === null) return null; // an x-dependent non-cosine term ⇒ not standalone |
| 3112 | if (cosArg === null) { |
| 3113 | cosCoef = parts.coef; |
no test coverage detected