(
t: Expr
)
| 686 | }); |
| 687 | |
| 688 | test('keeps irrational characteristic roots exact when possible', () => { |
| 689 | const equation = [ |
| 690 | 'Equal', |
| 691 | [ |
| 692 | 'Add', |
| 693 | ['D', ['D', ['y', 'x'], 'x'], 'x'], |
| 694 | ['Negate', ['D', ['y', 'x'], 'x']], |
| 695 | ['Negate', ['y', 'x']], |
| 696 | ], |
| 697 | 0, |
| 698 | ]; |
| 699 | const solution = dsolve(equation); |
| 700 | |
| 701 | expect(solution.toString()).toMatchInlineSnapshot( |
| 702 | `[y(x) == ArbitraryConstant(1) * e^(1/2 * x * (1 + sqrt(5))) + ArbitraryConstant(2) * e^(1/2 * x * (1 - sqrt(5)))]` |
| 703 | ); |
| 704 | expect( |
| 705 | verifyEquationSolution(equation, solution, { c_1: 2, c_2: 3, x: 0.75 }) |
| 706 | ).toBe(true); |
| 707 | }); |
| 708 | |
| 709 | test('solves second-order homogeneous equation with complex roots', () => { |
| 710 | const equation = [ |
| 711 | 'Equal', |
| 712 | ['Add', ['D', ['D', ['y', 'x'], 'x'], 'x'], ['y', 'x']], |
| 713 | 0, |
| 714 | ]; |
| 715 | const solution = dsolve(equation); |
| 716 | |
| 717 | expect(solution.toString()).toMatchInlineSnapshot( |
| 718 | `[y(x) == sin(x) * ArbitraryConstant(2) + cos(x) * ArbitraryConstant(1)]` |
| 719 | ); |
| 720 | expect( |
nothing calls this directly
no test coverage detected