3
$\begingroup$

I'm just a beginner learning Mathematica. I'd like to do something with it, but I don't know if it is possible.

Suppose I want to solve a system of differential equations, maybe a nonlinear one, and I just want to check whether or not a certain function satisfies the system. Is it possible to give the ansatz and let Mathematica tell me if I guessed the solution correctly?

Moreover, if there are some parameters, is it possible to know the values of the parameters for which your solution is valid?

If this is possible, can you tell me how to do it or where I should look for (books, pdf or anything) to learn how to do it?

$\endgroup$
4
$\begingroup$

No problem (if I understand your question right).

For example the well known ode x''[t]+x[t]==0 is solved by a Sin[t]+b Cos[t]

Check the ansatz

x''[t]+x[t]==0 /. x->Function[{t},a Sin[t]+b Cos[t]]
(*True*)

More general with an additional parameter

x''[t] + x[t] /. x -> Function[{t}, a Sin[c t] + b Cos[c t]]
eq = Coefficient[%, {Sin[c t], Cos[c t]}]
(*{a - a c^2, b - b c^2}*)
Solve[eq == 0, {a, b, c}]
(*{{c -> -1}, {c -> 1}, {a -> 0, b -> 0}}*)
(**)
$\endgroup$
  • $\begingroup$ Yes you understood the question right, thank you very much, it seems it is what I'm looking for. My system is fairly more complicated but one should be able to extend this to my case. I try to do it in the next days, If I don't succeed, should I edit this existing question or ask a new one maybe with a reference to this question? $\endgroup$ – AnOrAn Oct 8 at 15:40
  • $\begingroup$ There is only one thing I'm not completely understanding about the answer: does the symbol inline /. means something like assign, or replace? I've seen it somewhere else but I didn't really get it $\endgroup$ – AnOrAn Oct 8 at 15:51
  • 1
    $\begingroup$ @AnOrAn: It means to apply the replacement rule that follows. The documentation is found under ReplaceAll. $\endgroup$ – Michael Seifert Oct 8 at 15:57
  • 1
    $\begingroup$ @AnOrAn - To find out what the meaning of an object like /. just highlight the object in the notebook and press F1 for help. $\endgroup$ – Bob Hanlon Oct 8 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.