Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: How to rectify the error for NDSolve ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127148] Re: How to rectify the error for NDSolve ?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 2 Jul 2012 05:29:06 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201207010611.CAA01041@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

So many errors in your code!

(1) As somebody already noted in a reply to your earlier post (before 
you showed any code), you forgot to use an uppercase letter in Clear.

And you also forgot to use an uppercase letter in the sine expression on 
the right-hand side of the differential equation.

(2) The root cause of the error message you received is because first 
you set t = 5 and then a multiple of that; now t is a constant! But then 
you use the _same_ symbol t as if it were the variable in your 
differential equation. Change either the constant t to some other name 
or the variable t in your differential equation et seq. to some other name.

(3) You are not using correct syntax in the definition of eqn: all 
function arguments should be enclosed in brackets, not parentheses. And 
you forgot to include the argument of t for x at the end of the 
left-hand side of the equation.  Thus you seem to want:

   eqn = x''[\[Tau]] +1/Q x'[\[Tau]] +
          (1+Subscript[V,1] Sqrt[2] Sin[2 \[Tau]]) x[t]
          ==\[CapitalGamma] (Sin[\[Tau]+\[Phi]]);

Note that I removed the parentheses in the right-hand side, as there's 
no reason to have them.

(4) Remove Subscript[V,p] and Subscript[V,1] from the Clear expression, 
as they are not Symbols (or Strings). If they don't already have values, 
you don't need to get "clear" them in any sense. If they do, you have to 
use Unset:

   Unset[Subscript[V,p]]
   Unset[Subscript[V,1]]

(You can Unset several things at once by using Map.)

(5) After all that, at this point I do not understand your differential 
equation -- I don't know what you really intend the value of \[Tau] to 
be. You had set t = 5, so that after

   \[Tau] = Subscript[\[Omega], 0] t;

\[Tau] is also a constant, as is, therefore, the right-hand side of your 
differential equation. I suspect that's NOT what you intended.

In fact, I don't understand at all why you even set t to be a constant.

But if you simply fix all the things indicated above and omit the 
assignment t = 5, I think Mathematica will not be able to deal with this 
differential equation.

However, if you change the term that involving what I said should be 
x[t] in place of just x to have variable \[Tau] instead of t -- is that 
what you actually intended?? -- I think Mathematica will still balk at 
providing a solution.

If, though, you make a change of variable from t to tt ....

   neweqn = eqn /. t -> tt/10

... then the following _will_ provide a numerical solution:

   NDSolve[{neweqn, x[0] == 0.5, x'[0] == 0}, x[tt], {tt, 0, 250}]

P.S. By any chance, did you retype your code when writing your e-mail 
post? If so, that in itself may have introduced errors. You should use 
Mathematica's menu selection Edit > Copy As Plain Text to copy, then 
past into your message.

On 7/1/12 2:11 AM, Rahul Chakraborty wrote:
> Here is my code:
>
>
>   clear[x, t, \[Tau], Q, Subscript[V, p], Subscript[V,
>    1], \[CapitalGamma], \[Phi]];
> Q = 100;
> \[CapitalGamma] = 50;
> Subscript[\[Omega], 0] = 10;
> Subscript[V, p] = 0.5;
> Subscript[C, 0] = 4.06 * 10^-4;
> t = 5;
> \[Tau] = Subscript[\[Omega], 0] t;
> \[Phi] = 90;
> Subscript[V, 1] = Subscript[C, 0]*Subscript[V, p];
> eqn = x'' (\[Tau]) +
>      1/Q x' (\[Tau]) + (1 +
>         Subscript[V, 1] Sqrt[2]
>           Sin[2 \[Tau]]) x == \[CapitalGamma] (sin[\[Tau] + \[Phi]]);
> sol = NDSolve[{eqn, x[0] == 0.5, x'[0] == 0}, x, {t, 0, 250},
>     MaxSteps -> 500000, WorkingPrecision -> 25][[1]]
> ParametricPlot[Evaluate[{x[t], x'[t]} /. sol], {t, 0, 100},
>   Frame -> True, PlotRange -> All,
>   AxesLabel -> {"t", "\!\(\*OverscriptBox[\(\[Theta]\), \(.\)]\)"}]
>
>
>   Output i'm getting is as below:
>
>    NDSolve::dsvar: 5 cannot be used as a variable. >>
>
>
>    {0.999855 x + Derivative[1][x]/2 + 50 x^\[Prime]\[Prime] ==
>    50 sin[140], x[0] == 0.5, Derivative[1][x][0] == 0}
>
>
>   ReplaceAll::reps: {0.999855 x+x^\[Prime]/2+50 x^\[Prime]\[Prime]==50 sin[140],x[0]==0.5,(x^\[Prime])[0]==0} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
>
>
>   ReplaceAll::reps: {0.999855 x+0.5 x^\[Prime]+50. x^\[Prime]\[Prime]==50. sin[140.],x[0.]==0.5,(x^\[Prime])[0.]==0.} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
>
>   ReplaceAll::reps: {0.999855 x+0.5 x^\[Prime]+50. x^\[Prime]\[Prime]==50. sin[140.],x[0.]==0.5,(x^\[Prime])[0.]==0.} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
>
>   General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. >>
>
>
>   Regards,
>
>   rahul
>


-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305



  • Prev by Date: Re: multiplying, element wise, a row by each column of a matrix.
  • Next by Date: Re: Approximate Zero Times A Symbol
  • Previous by thread: Re: How to rectify the error for NDSolve ?
  • Next by thread: Re: How to rectify the error for NDSolve ?