Re: How to Scale and vary plot for a Differential Equation

*To*: mathgroup at smc.vnet.net*Subject*: [mg127411] Re: How to Scale and vary plot for a Differential Equation*From*: Rahul Chakraborty <rahul.6sept at gmail.com>*Date*: Mon, 23 Jul 2012 01:03:12 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net*References*: <20120720074852.62B9B685F@smc.vnet.net>

Dear Sir, 1). Regarding the last program of plotting DE there is one problem that i'm facing.The issue is, when i open the file first time the program shows lots of errors which vanishes after i run the program using Shift + Enter. I close the file and reopens the errors appears again. The list of errors as under: NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {0.\[VeryThinSpace]+0.5[t]==0,0.5[0]==1/2,True} . >> ReplaceAll::reps: {0.\[VeryThinSpace]+0.5[t]==0,0.5[0]==1/2,True} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >> ReplaceAll::reps: {0.\[VeryThinSpace]+0.5[t]==0,0.5[0]==1/2,True} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >> ReplaceAll::reps: {0.\[VeryThinSpace]+0.5[0.]==0,0.5[0]==1/2,True} 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. >> General::ivar: 0.00033557046979865775` is not a valid variable. >> General::ivar: 0.00033557046979865775` is not a valid variable. >> General::ivar: 0.3359060402684564` is not a valid variable. >> General::stop: Further output of General::ivar will be suppressed during this calculation. >> 2). Also in case of the previous plot of 1st order DE there appers a warning K$$::shdw: Symbol K$$ appears in multiple contexts {System`,Global`}; definitions in context System` may shadow or be shadowed by other definitions. >> and the variable K appears as Global` K and it does not increment in Autorun mode. Kindly advice me. Regards, rc On 7/22/12, Bob Hanlon <hanlonr357 at gmail.com> wrote: > DSolve[{x''[t] + \[Mu] (x[t] x[t] - 1) x'[t] + x[t] == 0, x[0] === 1/2, > x'[0] == 0}, x[t], t][[1]] > > {x[t] + \[Mu]*(-1 + x[t]^2)* > Derivative[1][x][t] + > Derivative[2][x][t] == 0, > x[0] == 1/2, Derivative[1][x][ > 0] == 0} > > In this case, DSolve did not solve the DE (returned unevaluated) so > NDSolve must be used. To use NDSolve, \[Mu] must have a numeric > value so the NDSolve must be inside of the Manipulate. > > Manipulate[sol = NDSolve[ > {x''[t] + \[Mu] (x[t] x[t] - 1) x'[t] + x[t] == 0, > x[0] == 1/2, x'[0] == 0}, x[t], > {t, 0, 50}][[1]]; > ParametricPlot[Evaluate[ > {x[t] /. sol, Log[D[x[t] /. sol, t]]}], > {t, 0, 50}, > Frame -> True, > Axes -> False, > FrameLabel -> {"x", Overscript["x", "."]}, AspectRatio -> 1, > PlotRange -> {{0, 2.5}, {-6, 4.5}}, > PlotPoints -> 150], > {{\[Mu], 1}, 1, 50, 0.1, > Appearance -> "Labeled"}] > > > Bob Hanlon > > > On Sat, Jul 21, 2012 at 1:20 PM, Rahul Chakraborty > <rahul.6sept at gmail.com> wrote: >> Dear Bob, >> >> Sir, I've tried the same code for another DE. Everything is same just >> changed the equations and initial conditions. Its giving an error, i >> couldn't debug it. >> >> Clear[x]; >> DSolve[{x''[t]+\[Mu] >> (x[t]x[t]-1)x'[t]+x[t]==0,x[0]==1/2,x'[0]==0},x[t],t][[1]]//= Quiet >> {x[t]->x[t]+\[Mu] (-1+x[t]^2) >> (x^\[Prime])[t]+(x^\[Prime]\[Prime])[t]==0,x[0]==1/2,x'[0]=== 0} >> Manipulate[Module[{sol},sol={x[t]->{x[t]+\[Mu] (-1+x[t]^2) >> (x^\[Prime])[t]+(x^\[Prime]\[Prime])[t]==0,x[0]==1/2,x'[0]=== 0}};ParametricPlot[Evaluate[{x[t]/.sol,Log[D[x[t]/.sol,t]]}],{t,0,50},Frame= ->True,Axes->False,FrameLabel->{"x",Log[Overscript[x,"."]]},AspectRatio->1,= PlotRange->{{0,10.1},{-6,10.1}}]],{{\[Mu],1},1,50,0.01,Appearance->"Labeled= "}] >> >> ERROR: ParametricPlot::exclul: {Im[(x^\[Prime])[t]+2 x[t] >> (<<1>>^(<<1>>))[<<1>>]^2+(-1+Power[<<2>>]) >> (x^\[Prime]\[Prime])[t]+(x^(3))[t]==0]-0} must be a list of equaliti= es >> or real-valued functions. >> >> >> Kindly advice. >> >> Regards, >> >> rc >> >> On 7/21/12, Bob Hanlon <hanlonr357 at gmail.com> wrote: >>> It is not required. If you don't like it, don't use it. Adjust >>> PlotRange to taste. >>> >>> >>> Bob Hanlon >>> >>> >>> On Sat, Jul 21, 2012 at 12:57 AM, Rahul Chakraborty >>> <rahul.6sept at gmail.com> wrote: >>>> Dear Bob, >>>> >>>> Thanks. >>>> >>>> But one query, why it is required to use Log in " Log[D[x[t] /. sol, >>>> t]". Because in simple plot without Manipulate it is not required. >>>> >>>> >>>> Regards, >>>> rc >>>> >>>> On 7/21/12, Bob Hanlon <hanlonr357 at gmail.com> wrote: >>>>> You appear to be confusing the syntax of DSolve with that of NDSolve. >>>>> DSolve can be used to solve the DE once rather than repeatedly inside >>>>> the manipulate. >>>>> >>>>> DSolve[{x'[t] - r x[t] (1 - x[t]/K) == 0, >>>>> x[0] == 1/2}, x[t], t][[1]] // Quiet >>>>> >>>>> {x[t] -> (E^(r*t)*K)/(-1 + E^(r*t) + 2*K)} >>>>> >>>>> Manipulate[ >>>>> Module[{sol}, >>>>> sol = {x[t] -> (E^(r*t)*K)/(-1 + E^(r*t) + 2*K)}; >>>>> ParametricPlot[ >>>>> Evaluate[{ >>>>> x[t] /. sol, >>>>> Log[D[x[t] /. sol, t]]}], >>>>> {t, 0, 50}, >>>>> Frame -> True, >>>>> Axes -> False, >>>>> FrameLabel -> {"x", Log[Overscript[x, "."]]}, >>>>> AspectRatio -> 1, >>>>> PlotRange -> {{0, 5.1}, {-6, 2.1}}]], >>>>> {{r, 1}, 1, 5, 0.01, Appearance -> "Labeled"}, >>>>> {{K, 1}, 1, 5, 0.01, Appearance -> "Labeled"}] >>>>> >>>>> >>>>> Bob Hanlon >>>>> >>>>> >>>>> On Fri, Jul 20, 2012 at 3:48 AM, Rahul Chakraborty >>>>> <rahul.6sept at gmail.com> wrote: >>>>>> Dear all, >>>>>> >>>>>> Kindly guide me for the above mentioned subject. I did try to code i= t >>>>>> but >>>>>> needs guidance.The code as below >>>>>> >>>>>> Clear[x]; >>>>>> k[x_]=Manipulate[DynamicModule[{r:=1,K:=1},{Slider[Dynamic[r]]= ,Slider[Dynamic[K]]},eqn=x'[t]-r >>>>>> x[t] >>>>>> (1-x[t]/K)==0//Quiet,sol=First@DSolve[{eqn,x[0]==1/2},x[t]= ,{t,0,50}],[ParametricPlot[Evaluate[{x[t]/.sol,D[x[t]/.sol,t]}],{t,0,50},Fr= ame->True,AxesLabel->{"x",Overscript[x,"."]},AspectRatio->1],ImageSize-> >>>>>> Scaled[r,K]],{r,1,5},{K,1,5},Initialization:> >>>>>> {r:=1,K:=1},SaveDefinitions-> True]] >>>>>> >>>>>> Regards, >>>>>> rahul >>> >

**References**:**How to Scale and vary plot for a Differential Equation***From:*Rahul Chakraborty <rahul.6sept@gmail.com>