Equating symbolic coefficients
I would like to look for a y
feature of ODEy'' - y' - 2y = 4x^2
I made the following script:
syms x A0 A1 A2 ypa = A2*x^2+A1*x+A0; % y_p assume cyp = diff(ypa,2) - diff(ypa) - 2*ypa % according to ODE P1 = 4*x^2; P2 = cyp ; % Equating P1 and P2 C = coeffs(P1 - P2,x); A0 = solve(C(1),A0) A1 = solve(C(2),A1) A2 = solve(C(3),A2)
I got the correct answer for A2 = -2
. But I didn't get for A0
(should be -3
) and A1
(should be 2
). How can I get them automatically?
PS I am using MATLAB R2013a.
+3
source to share
1 answer