Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to find a specific solution to a differential equation. As a simplified version of my problem, here's a similar setup for a simple harmonic oscillator problem.

aargh = 
   -0.000000000001 + q''[x] == -q[x], 
   q'[π] == q'[-π], q[-π] == q[π]}, 
   q, {x, -π, π}];
Plot[Evaluate[q[x] /. aargh], {x, -π, π}]

The reason for the 0.00000000001 is to perturb the system slightly to ensure that I get a nonzero solution. This gives a beautiful harmonic function as a solution. Now, what I want to do, is specify a starting trial solution for NDSolve to look around. For example, say I wanted to find the $\sin(x)$ solution to the differential equation. Is there any way by which I can specify this and ask Mathematica to look around a particular function for my solution.

My actual problem is far more complicated, but is essentially the same. It is also homogenous, so I've added a perturbation there as well to find the non zero solution. Once again, Mathematica is returning an approximately valid solution, but I know that there exists another solution somewhere else. How do I tell Mathematica to look there?

share|improve this question
Does this help? The idea is to make q depend on another variable as well ("time") and construct the equation so that you get the solution of your boundary value problem at t -> Infinity. Now you have a PDE and it's possible to set an initial condition. – Szabolcs Jun 20 '14 at 3:02
There's a two-dimensional family of solutions to your BVP, 1.`*^-12 + C[1] Sin[x] + C[2] Cos[x]. I think the NDSolve methods for BVPs expect the solution to be unique (or perhaps a discrete set). (Execute DSolve[{-10^-12 + q''[x] == -q[x], q[π] == q[-π], q'[-π] == q'[π]}, q, x] and examine the warning messages and solution.) – Michael E2 Jun 20 '14 at 3:54
It seems that you might replace qby anothe variable, such as q[x]=Sin[x]+z[x]and reformulate your problem in terms of z[x]. This will explicitly mean "to look around". – Alexei Boulbitch Jun 20 '14 at 7:46
@Szabolcs: Hmm. Yes, that does seem similar to what i'm trying to do. I'll try that out and get back to you on the results.. – user16010 Jun 20 '14 at 13:50
@MichaelE2: Yes, I understand that in this particular sample problem there is an entire family of solutions. I want to make Mathematica converge to a preferable member of that family rather than an arbitrary one. – user16010 Jun 20 '14 at 13:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.