Tag Info

Hot answers tagged

5

First, you're not using a fixed step method. (An Euler scheme may be applied to any step size and to one that varies.) To get a true fixed step method you have to turn off "DiscontinuityProcessing" when you have a discontinuous ODE; otherwise, NDSolve will try to adapt the steps to account for the discontinuity. The "DiscontinuityProcessing" stage resets ...


4

The reason it's not finishing is that you set MaxSteps -> Infinity with a high AccuracyGoal. We can actually solve this system analytically, by replacing NDSolve with DSolve: qq = DSolve[{q'[t] == v[t]/r - q[t]/r*(1/c), q1'[t] == (((q[t] + q1[t])/(2*a*ϵ0*k2))*δ), q[0] == 10*10^-9, q1[0] == 10*10^-9}, {q, q1}, t]; We can inspect the solution: ...


4

I misunderstood and commented only about computing the Cesaro means as per the question In s I have all partial sums, but I do not know how to divide them by corresponding n. The desired scatter plot of 500 Monte Carlo attempts with samples of increasing length could be obtained with something like ticks = Range[-0.06, 0.06, 0.02]; s = Table[u = ...


4

In your example plot the Monte-Carlo integral is computed afresh for each new amount of sampling points: s[n_] := Total[Sqrt[1 - #^2] & /@ RandomReal[1, n]]/n Then take one random point, find the mean, take two new random points, find their mean, and so on until 500. The result is: ListPlot[Table[s[n], {n, 500}], PlotRange -> {0.7, 0.9}] The ...


2

What you are missing, I believe, is sufficient experience of Mathematica's core language at the functional level that you experimenting with. I give you credit for making a good try at formulating your code in a functional way, but I'm afraid you gone somewhat wide of the mark. I have put your code into a form that works and which I think preserves your ...


2

Using Event-Handling and Euler method Expanding the solution given by Michael E2 one might figure that using EventSeries is coming closest to the "real thing" which after all is a series of discrete events: eventTimes = Range[ 0, 10, 1 ]; (* example *) isEventTimeQ[ t_?NumericQ ] := Piecewise[ Table[ { 1 , t == eventTime }, {eventTime, eventTimes}], ...


1

This is not a direct answer to your problem, but rather a generalization of @Jens' code from double to n-tuple pendulums. Meaning you can also use it for double pendulums if you like. I'm providing it due to popular demand. Needs["VariationalMethods`"] n = 10; (* number of pendulum segments *) rate = 10; (* animation frame rate *) Clear[s, ϕ, t, g, m]; ...



Only top voted, non community-wiki answers of a minimum length are eligible