# Tag Info

2

Sorry to make this an answer, but I don't have enough reputation to comment and I feel the following clarification could be helpful: While symplectic intergrators do not exactly conserve energy, they make the total energy of the system remain bounded, independently of the number of time steps. Your max error (regarding the energy) will therefore be $\... 2 As far as I understand the fist part of your question is regarding the options of the ode15s, and which ones you can use to make the solver more efficient/accurate. Providing the Jacobian to the solver, especially if its reasonably easy to calculate, is a good idea to make things faster and more accurate. Using sparse systems for small systems of equations ... 2 We do not know what your equations look like exactly, but maybe you may get away with transforming your whole coordinate system to more meaningful units. I mean, if your units are for example au (distance earth sun), and you simulate something very small, you run into these floating point problems earlier than if you'd transform your problem to (mili/micro/... 3 Just take the log of your function, and then take the derivative of it. If the actual function is indeed positive definite as in the example then it is identically the same as the quotient that we need to calculate but without division,$\partial_z \ln(𝑓)= \frac{ 1} {f} \partial_z 𝑓$If the actual function is not positive-definite then it may become a bit ... 0 Just too long for a comment. As others mentioned, there's a huge amount of codes/literature available on the web so that you'll have no problem to find any suitable reference. Also, your specific example is one of the most standard example taken from physics. Btw, if we use backward euler, after defining$X(t)=[x(t),\dot{x}(t)]\$ and writing your ODE as a ...

2

Just introduce the velocity as an additional variable and solve: $$\frac{d}{dt}(x,\dot{x})^t = (\dot{x}, k\sin(x))^t$$ You can then solve that with any ODE integrator, e.g. ode45 in Matlab, RK45 with Scipy... Note: I am quite confused as to why you would use a Newton's method to solve this problem... You can apply it to solve each time step of an implicit ...

2

It sounds like what you want is an abstract type -- a common grid type that both Cartesian and Hermite grids inherit from. This abstract grid type doesn't actually do anything by itself, but rather it defines an interface that callers can count on the actual implementations, namely Cartesian and Hermite grids, to provide. Ideally, you'd be able to code ...

0

Welcome to scicomp! If I remember correctly, then in order to Fourier transform a function it has to be a periodical so that you can use the sine and cosine functions as base for it. In your case the peak will have a discontinuity in the derivative at the ends at x=30 or x=-30. The Fourier base is not well suited for discontinuities. If my hunch is correct, ...

Top 50 recent answers are included