Search code examples
wolfram-mathematica

How to fix 'Equations may not give solutions for all "solve" variables' error


I am attempting a problem that can be solved with MUC (method of undetermined coefficients).

However, when I use the Solve function, it gives an error.

y[x_] := a x^3 + b x^2 + c x + d
Solve[{y''[x] + 2 y'[x] + y[x] == x^3}, {a, b, c, d}]

[ERROR]:
Solve::svars: Equations may not give solutions for all "solve" variables.

Shouldn't this solve for all variables in the set?

Thank You for your help :)


Solution

  • Looks like some extra methodology is needed for this.

    As you stated, a function with the finite family of derivatives for x^3 is

    y[x_] := a x^3 + b x^2 + c x + d
    

    Equating coefficients

    sol = Solve[Thread[CoefficientList[
         y''[x] + 2 y'[x] + y[x], x] == CoefficientList[x^3, x]]]
    
    {{a -> 1, b -> -6, c -> 18, d -> -24}}
    

    Checking the results

    FullSimplify[y''[x] + 2 y'[x] + y[x] == x^3 /. sol]
    
    {True}