Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11157 > unrolled thread
| Started by | Juan Barandiaran <barandiaran.juan@gmail.com> |
|---|---|
| First post | 2012-08-01 09:08 +0000 |
| Last post | 2012-08-01 09:08 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Manipulate a Plot of Evaluate DSolve Juan Barandiaran <barandiaran.juan@gmail.com> - 2012-08-01 09:08 +0000
| From | Juan Barandiaran <barandiaran.juan@gmail.com> |
|---|---|
| Date | 2012-08-01 09:08 +0000 |
| Subject | Re: Manipulate a Plot of Evaluate DSolve |
| Message-ID | <jvarmf$77f$1@smc.vnet.net> |
Thanks Bob,
Yes, I could use NDSolve instead of DSolve, in my case I'm only getting
numerical outputs, so it should do the job.
But in the example that you send me, why is nothing plotted?
Thanks again and best regards,
Juan
2012/7/30 Bob Hanlon <hanlonr357@gmail.com>
> If DSolve cannot solve the equations then use NDSolve.
>
> func[coef_?NumericQ, c_?NumericQ, x_?NumericQ] :=
> y[t] /. NDSolve[{y'[t] == Cos[coef*t], y[0] == c},
> y[t], {t, -10, 10}][[1]] /. t -> x
>
> Manipulate[Plot[
> Evaluate[func[coef, c, x] /. c -> Range[5]],
> {x, -10, 10},
> PlotRange -> {-5, 10}],
> {{coef, 1}, 0.1, 5, 0.01,
> Appearance -> "Labeled"}]
>
>
> Bob Hanlon
>
>
> On Sun, Jul 29, 2012 at 6:12 PM, Juan Barandiaran
> <barandiaran.juan@gmail.com> wrote:
> > Thanks for your answer Bob,
> > Of course your solution works, but I still don't understand why mine
> doesn't
> > and I cannot use your proposed approach because the way you write the
> > problem it is easy for Mathematica to solve the DSolve.
> > And this is just a simple example, in my real problem the DSolve cannot
> be
> > solved analytically.
> > This is why I tried to express the function as:
> >
> > {{y -> Function[{x}, DSolve[y'[x] == Cos[coef *x], y, x]]}}
> >
> > , which is something like the output I get from my DSolve.
> >
> > Thanks for your help.
> >
> > Juan
> >
> >
> > 2012/7/29 Bob Hanlon <hanlonr357@gmail.com>
> >>
> >> Clear[func];
> >>
> >> func[coef_, c_, x_] =
> >> y[x] /. DSolve[{y'[x] == Cos[coef*x], y[0] == c}, y[x], x][[1]] //
> >> Simplify
> >>
> >> c + Sin[coef*x]/coef
> >>
> >>
> >> Manipulate[Plot[Evaluate[
> >> func[coef, c, x] /.
> >> c -> Range[5]],
> >> {x, -10, 10},
> >> PlotRange -> {-5, 10}],
> >> {{coef, 1}, 0.1, 5, 0.01,
> >> Appearance -> "Labeled"}]
> >>
> >>
> >> Bob Hanlon
> >>
> >>
> >> On Sun, Jul 29, 2012 at 3:05 AM, <barandiaran.juan@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > 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
> >> >
> >
> >
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web