Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Manipulate a Plot of Evaluate DSolve

  • To: mathgroup at
  • Subject: [mg127504] Re: Manipulate a Plot of Evaluate DSolve
  • From: Alexei Boulbitch <Alexei.Boulbitch at>
  • Date: Mon, 30 Jul 2012 22:12:56 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:


I'm trying to Manipulate a Plot of a quite difficult function which involves solving a differential equation, but cannot be solved analytically.

To try to simplify the example and simulate it, let's assume that we have the following function:

func[coef_] = {{y -> Function[{x}, DSolve[y'[x] == Cos[coef *x], y, x]]}}

Manipulate[Plot[{{Evaluate[y[x] /. func[coef] /. C[1] -> {Range[-5, 0]}]}},{x, -10, 10}], {{coef , 1}, 0.1, 5}]

I get an error: DSolve::dsvar: "-9.99959 cannot be used as a variable"

I think that this is because Manipulate assigns a value to x (= -9.99959)BEFORE solving the DSolve, even though to avoid it I'm using the Evaluate function, which should process the function before assigning a value to x.

But the thing is that the "coef" to be Manipulated is at the same "level" as the x in the Manipulate block, so probably if I need the coef to solve the DSolve, I also have the x that gives me an error.

Is there any workaround? I guess I'm not understanding properly how Mathematica processes these simple expressions.

Thanks, Juan

Hi, Juan,

Try this:

   y[x] /. DSolve[{y'[x] == Cos[coef*x]}, y, x] /.
    C[1] -> Range[-5, 0]], {x, -10, 10}], {{coef, 1}, 0.1, 5}]

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at

  • Prev by Date: Re: Heat equation at the surface of a sphere
  • Next by Date: How do I create a circular lamina?
  • Previous by thread: Re: Manipulate a Plot of Evaluate DSolve
  • Next by thread: Best Fit Spherical Harmonics