differential-equations

Implementing explicit Euler method (for ODEs) in MATLAB

怎甘沉沦 提交于 2019-12-02 22:56:38
问题 I've searched everywhere, and I can't find anything. First of all, let me just say I have never used Mat Lab so I have no idea what I am doing what so ever. I have tried a few things, but none have worked. Apparently y(0)=2 tries to create a list of 0 units with the value of 2? Anyway, can someone help me? I need to write a flexible Euler's Method equation in Mat Lab to solve a few equations like this. 1) y' = 5-3sqrt(y) ; y(0)=2 With h= .1 , .05 , .025, .01 && t =.5 ,1 , 1.5 , 2 , 2.5 ,3 I

how to identify turning points in stock price data

佐手、 提交于 2019-12-02 18:53:47
This question is a continuation of this one . My goal is to find the turning points in stock price data. So far I: Tried differentiating the smoothed price set, with the help of Dr. Andrew Burnett-Thompson using the centered five-point method, as explained here . I use the EMA20 of tick data for smoothing the data set. For each point on the chart I get the 1st derivative (dy/dx). I create a second chart for the turning points. Each time the dy/dx is between [-some_small_value] and [+some_small_value] - I add a point to this chart. The problems are: I don't get the real turning points, I get

How to read a system of differential equations from a text file to solve the system with scipy.odeint?

≡放荡痞女 提交于 2019-12-02 12:31:02
问题 I have a large (>2000 equations) system of ODE's that I want to solve with python scipy's odeint. I have three problems that I want to solve (maybe I will have to ask 3 different questions?). For simplicity, I will explain them here with a toy model, but please keep in mind that my system is large. Suppose I have the following system of ODE's: dS/dt = -beta*S dI/dt = beta*S - gamma*I dR/dt = gamma*I with beta = c p I where c, p and gamma are parameters that I want to pass to odeint. odeint is

How to read a system of differential equations from a text file to solve the system with scipy.odeint?

戏子无情 提交于 2019-12-02 07:44:05
I have a large (>2000 equations) system of ODE's that I want to solve with python scipy's odeint. I have three problems that I want to solve (maybe I will have to ask 3 different questions?). For simplicity, I will explain them here with a toy model, but please keep in mind that my system is large. Suppose I have the following system of ODE's: dS/dt = -beta*S dI/dt = beta*S - gamma*I dR/dt = gamma*I with beta = c p I where c, p and gamma are parameters that I want to pass to odeint. odeint is expecting a file like this: def myODEs(y, t, params): c,p, gamma = params beta = c*p S = y[0] I = y[1]

Custom periodic function without counter

风流意气都作罢 提交于 2019-12-02 04:04:58
问题 I am using ode45 to solve a simple ODE: function dCdt=u_vent(t,C) if t> 600 && t<= 720 Q=Q2; elseif t> 1320 && t<= 1440 Q=Q2; elseif t> 2040 && t<= 2160 Q=Q2; elseif t> 2760 && t<= 2880 Q=Q2; elseif t> 3480 && t<= 3600 Q=Q2; else Q=Q1; end V=100; C_i=400; S=100; dCdt=Q/V*C_i+S/V-Q/V*C(1); return I use then to solve: [t,C]=ode45(@u_vent, [0 1*3600], 400); I would like to create a periodic function such as the one in the picture for Q , 0<t<3600 , without using those if statements... any

Make sure MATLAB does not recalculate symbolic expression

孤者浪人 提交于 2019-12-01 11:39:43
I am building (my first...) MatLab program, it needs to differentiate an equations symbolically and then use this solution many many times (with different numeric inputs). I do not want it to recalculate the symbolic differentiation every time it needs to put in a new set of numeric values. This would probably greatly add to the time taken to run this program (which - given its nature, a numeric optimiser, will probably already be hours). My question is how can I structure my program such that it will not recalculate the symbolic differentiation? The class in question is: function [ result ] =

Using odeint function definition

北城余情 提交于 2019-12-01 08:40:55
Pretty noob question so please bear with me. I am following the example given here--> http://www.codeproject.com/Articles/268589/odeint-v2-Solving-ordinary-differential-equations In particular, I am looking at this function: void lorenz( state_type &x , state_type &dxdt , double t ) { dxdt[0] = sigma * ( x[1] - x[0] ); dxdt[1] = R * x[0] - x[1] - x[0] * x[2]; dxdt[2] = x[0]*x[1] - b * x[2]; } In my case, R takes on a series of values (vector with 100 doubles). odeint is called as: integrate_const( runge_kutta4< state_type >() , lorenz , x , 0.0 , 10.0 , dt ); I would like to do this for each

Bound an odeint variable

一笑奈何 提交于 2019-12-01 08:01:12
I'm using odeint to simulate a system wherein there are several variables which should not go less than zero. Is there an appropriate way to bound a variable in odeint to a particular range? There is no such possibility in odeint. And I guess there are no algorithms which could do that. You must somehow encode the bound in your ODE. If you only want to find a bound during the evolution of your system use a loop like while( t < tmax ) { stepper.do_step( ode , x , t , dt ); t += dt; if( check_bound( x , t ) ) break; } Two side nodes, maybe this is the case for your problem: There are special

Bound an odeint variable

限于喜欢 提交于 2019-12-01 07:10:32
问题 I'm using odeint to simulate a system wherein there are several variables which should not go less than zero. Is there an appropriate way to bound a variable in odeint to a particular range? 回答1: There is no such possibility in odeint. And I guess there are no algorithms which could do that. You must somehow encode the bound in your ODE. If you only want to find a bound during the evolution of your system use a loop like while( t < tmax ) { stepper.do_step( ode , x , t , dt ); t += dt; if(

SymPy/SciPy: solving a system of ordinary differential equations with different variables

限于喜欢 提交于 2019-12-01 02:24:34
问题 I am new to SymPy and Python in general, and I am currently working with Python 2.7 and SymPy 0.7.5 with the objective to: a) read a system of differential equations from a text file b) solve the system I already read this question and this other question, and they are almost what I am looking for, but I have an additional issue: I do not know in advance the form of the system of equations, so I cannot create the corresponding function using def inside the script, as in this example. The