Prev: Plotting a curve on a flat torus
Next: New version of Quantum Mathematica Add-On for Dirac bra ket notation quantum algebra and quantum computing
From: Jamil Ariai on 14 Jan 2010 05:47 Hi All, Can anybody kindly tell me how I can solve the following differential equation, with (x[0], x'[0]) = (0, 0): x''[t] -x[t] + g[t] = 0, where g[t] = b*v, for x'[t] > v, g[t] = b*(x'[t]-u), for Abs[x'[t]-u] < v, and g[t] = -b*v. Take b = 5, v = 0.2, and u = 0.1. Draw x[t] vs t, and x'[t] vs x[t]. Thanks. J. Ariai
From: Alois Steindl on 15 Jan 2010 03:17 Jamil Ariai <j_ariai(a)hotmail.com> writes: > Hi All, > > > > Can anybody kindly tell me how I can solve the following differential equation, with (x[0], x'[0]) = (0, 0): > > > > x''[t] -x[t] + g[t] = 0, > > > > where > > > > g[t] = b*v, for x'[t] > v, > > g[t] = b*(x'[t]-u), for Abs[x'[t]-u] < v, and > > g[t] = -b*v. > > > > Take b = 5, v = 0.2, and u = 0.1. Draw x[t] vs t, and x'[t] vs x[t]. > > > > Thanks. > > > > J. Ariai > > Hello, that looks much like a homework assignment. Who gets the credits? What have you tried so far? Alois -- Alois Steindl, Tel.: +43 (1) 58801 / 32558 Inst. for Mechanics and Mechatronics Fax.: +43 (1) 58801 / 32598 Vienna University of Technology, A-1040 Wiedner Hauptstr. 8-10
From: Daniel Lichtblau on 15 Jan 2010 03:18 Jamil Ariai wrote: > Hi All, > > Can anybody kindly tell me how I can solve the following differential equation, with (x[0], x'[0]) = (0, 0): > > x''[t] -x[t] + g[t] = 0, > > where > > g[t] = b*v, for x'[t] > v, > g[t] = b*(x'[t]-u), for Abs[x'[t]-u] < v, and > g[t] = -b*v. > > Take b = 5, v = 0.2, and u = 0.1. Draw x[t] vs t, and x'[t] vs x[t]. > > Thanks. > > J. Ariai Could set it up as below. soln = First[ With[{b = 5, v = 0.2, u = 0.1}, With[{gt = Piecewise[{{b*v, x'[t] > v}, {b*(x'[t] - u), Abs[x'[t] - u] < v}}, -b*v]}, NDSolve[{x''[t] - x[t] + gt == 0, x[0] == 0, x'[0] == 1.15}, x[t], {t, 0, 3}]]]] If your initial derivative is one or less, the default handling seems to run into trouble at one of the switches. I do not know why. Possibly some Method or other settings can improve on that. Daniel Lichtblau Wolfram Research
From: dh on 15 Jan 2010 03:21
Hi Jamil, g only depends on x'. We therefore define it as a function with one parameter (== x'). It is convenient using a Piecewise function for this. Here is the code: =================================== b = 5; v = 0.2; u = 0.1; tmax = 1; g[der_?NumericQ] = Piecewise[{{b*v, der > v}, {b*(der - u), Abs[der - u] < v}, {-b*v, True}}]; eq = { x''[t] - x[t] + g[x'[t]] == 0, x[0] == 0, x'[0] == 0 }; sol = x /. NDSolve[eq, {x}, {t, 0, tmax}][[1]]; Plot[sol[t], {t, 0, tmax}, AxesLabel -> {"t", "x[t]"}] ParametricPlot[{sol[t], sol'[t]}, {t, 0, tmax}, AxesLabel -> {"x[t]", "x'[t]"}] ============================================= Daniel Jamil Ariai wrote: > Hi All, > > > > Can anybody kindly tell me how I can solve the following differential equation, with (x[0], x'[0]) = (0, 0): > > > > x''[t] -x[t] + g[t] = 0, > > > > where > > > > g[t] = b*v, for x'[t] > v, > > g[t] = b*(x'[t]-u), for Abs[x'[t]-u] < v, and > > g[t] = -b*v. > > > > Take b = 5, v = 0.2, and u = 0.1. Draw x[t] vs t, and x'[t] vs x[t]. > > > > Thanks. > > > > J. Ariai > > |