Rubi TrinomialParts[u,x] → {a,b,c,n} with u ≡ a + b·x^n + c·x^(2n)
(u: Expression, x: string)
| 1738 | continue; |
| 1739 | } |
| 1740 | const p = binomialPartsX(f, x); |
| 1741 | if (p === null) return null; |
| 1742 | parts.push(p); |
| 1743 | } |
| 1744 | if (parts.length === 0) return null; |
| 1745 | let acc: BinParts | null = parts[0]; |
| 1746 | for (let i = 1; i < parts.length && acc !== null; i++) |
| 1747 | acc = combineBinProduct(acc, parts[i]); |
| 1748 | if (acc === null) return null; |
| 1749 | return { |
| 1750 | a: scale.mul(acc.a).evaluate(), |
| 1751 | b: scale.mul(acc.b).evaluate(), |
| 1752 | n: acc.n, |
| 1753 | }; |
| 1754 | } |
| 1755 | case 'Add': |
| 1756 | case 'Subtract': { |
| 1757 | let constA = ce.Zero; |
| 1758 | let acc: BinParts | null = null; |
| 1759 | for (const t of sumTermsX(u)) { |
| 1760 | if (!t.has(x)) { |
| 1761 | constA = constA.add(t); |
| 1762 | continue; |
| 1763 | } |
| 1764 | const p = binomialPartsX(t, x); |
| 1765 | if (p === null) return null; |
| 1766 | if (acc === null) acc = p; |
| 1767 | else if (zeroQ(acc.n.sub(p.n))) |
| 1768 | acc = { |
| 1769 | a: acc.a.add(p.a).evaluate(), |
| 1770 | b: acc.b.add(p.b).evaluate(), |
| 1771 | n: acc.n, |
| 1772 | }; |
| 1773 | else return null; |
| 1774 | } |
| 1775 | if (acc === null) return null; |
| 1776 | return { a: acc.a.add(constA).evaluate(), b: acc.b, n: acc.n }; |
| 1777 | } |
| 1778 | } |
| 1779 | return null; |
| 1780 | } |
| 1781 | |
| 1782 | /** Rubi FunctionOfLog[u,x] → {f, v, n} with u ≡ f(Log[v]), v = a·x^n (n≠0), or |
| 1783 | * null. Faithful port of IntegrationUtilityFunctions.m FunctionOfLog: detects |
| 1784 | * that u is a function of a single Log[a·x^n], returning the substituted body |
| 1785 | * f (each Log[a·x^n] leaf → the substitution variable x), the log argument v, |
| 1786 | * and the exponent n. Every Log leaf must share the same argument v; a bare |
| 1787 | * integration variable outside a log, or any calculus head, fails closed |
| 1788 | * (null). Drives the 3.5 `∫F(Log[a·x^n]) [/x]` rules (Miscellaneous |
| 1789 | * logarithms), whose reduction is `1/n·Subst[∫f dx, x, Log[v]]`. */ |
| 1790 | /** Integer power of x appearing as a factor of a single product term (0 if x |
| 1791 | * is not a monomial factor, e.g. it sits inside Log). */ |
| 1792 | function xPowerOfTerm(t: Expression, x: string): number { |
| 1793 | if (t.symbol === x) return 1; |
| 1794 | if (t.operator === 'Negate' && t.ops) return xPowerOfTerm(t.ops[0], x); |
| 1795 | if (t.operator === 'Power' && t.ops) { |
| 1796 | if (t.ops[0].symbol !== x) return 0; |
| 1797 | const e = t.ops[1].re; |
no test coverage detected