
Differential Equations Ordinary and Partial Differential Equations Math Forum 
 LinkBack  Thread Tools  Display Modes 
August 25th, 2017, 03:29 AM  #1 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1  Numerical integration with 3 variables
I have 3 variables: v, b and h. I know how to calculate v’, b’ and h’. Starting the simulation from an initial condition, I need to calculate v, b and h after a given time using a numerical integrator (say RK4). If I use the simple Euler method, I write; v= v + dt * v’ b= b + dt * b’ h= h + dt * h’ but when I switch to RK4, I don’t know what to write. For example: h’= v * cos(b) and the RK4 function is of the form y(t + dt)= rk4(dx, x, y(t)), while the acceleration function is of the form acc= f(x, y); what should I write in place of x and y? The simulation is explained here: https://mintoc.de/index.php?title=Gravity_Turn_Maneuver 
August 25th, 2017, 04:04 AM  #2  
Senior Member Joined: Feb 2016 From: Australia Posts: 1,518 Thanks: 506 Math Focus: Yet to find out.  Quote:
This may be helpful.  
August 25th, 2017, 04:37 AM  #3 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1 
Your post is useful when I have only one equation, but since I have a poor math background, when I need to solve a slightly complicate problem, I don't know what to do. In this case, I need to solve the equation $\dot v = ...$ and $\dot b = ...$ showed here (please, don't ask me to rewrite those very long equations ). For example, b'= rk4(dx, x, y), where dx and x are times and y is b, but I have that $\dot b = f(b, v, h)$. What should I write inside the function to calculate the acceleration for b'? 
August 25th, 2017, 08:37 AM  #4 
Global Moderator Joined: Oct 2008 From: London, Ontario, Canada  The Forest City Posts: 7,742 Thanks: 1000 Math Focus: Elementary mathematics and beyond 
The resulting optimal control problem is given by where $F_{max}$ is the maximum thrust of the vehicle's engine and $\varepsilon$ is a small number that is strictly greater than zero. The differential states of the problem are $m, v, \beta, h, \theta$ while $u$ is the control function. Last edited by greg1313; August 25th, 2017 at 08:42 AM. 
August 25th, 2017, 09:08 AM  #5 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1 
Is my link not working?

September 3rd, 2017, 08:51 PM  #6 
Senior Member Joined: Feb 2016 From: Australia Posts: 1,518 Thanks: 506 Math Focus: Yet to find out.  Sorry.. I didn't realise it was you who started the other thread I linked! You definitely want to write the sim from scratch? Which language/software? Also are you sure you need to use an RK algorithm? MATLAB has inbuilt functions for solving optimisation problems like the one in the link.. although to be honest with you, I'm not sure if these can be used for constraints that include differential equations.. interesting .. 
September 4th, 2017, 08:53 AM  #7  
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1  Quote:
We have: v’ = f(t, v) g’ = f(g, v) h’ = f(g, v) x’ = f(g, v) Let’s consider for a moment the RK2 algorithm. I do (in pseudocode) [it seems that I don't know how to format the text to make it more readable]: k1= stp * fv(t, v); k2= stp * fv(t + stp * .5, v + .5 * k1); v += k2; k1= stp * fg(g, v); k2= stp * fg(g + .5 * k1, v); g += k2; k1= stp * fh(g, v); k2= stp * fh(g, v); h += k2; k1= stp * fx(g, v); k2= stp * fx(g, v); x += k2; I use the updated v and the updated g as the input for the next functions; is that correct? Or should I update v and h after the calculation of g, h and x? Quote:
Since I always wrote a program for a new simulation, I cannot use MATLAB, Mathematica or whatever; I need to code in C++.  

Tags 
integration, numerical, numerical integration, rk4, variables 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Looking for Numerical Integration algorithm  Yooklid  Math Software  11  March 27th, 2017 12:47 AM 
Help with Numerical Integration Please :)  AnomanderRakeSoD  Applied Math  0  June 21st, 2013 03:11 AM 
numerical integration  Albert.Teng  Calculus  3  July 1st, 2012 11:13 PM 
Numerical integration in Excel  dallairius  Calculus  1  April 6th, 2012 10:07 AM 
Question on numerical integration  PageUp  Applied Math  1  March 19th, 2012 06:58 AM 