/* Runge Kutta for a set of first order differential equations */
#define N 2 /* number of first order equations */
#define dist 0.1 /* stepsize in t*/
#define MAX 30.0 /* max for t */
FILE *output; /* internal filename */
void runge4(double x, double y, double step); /* Runge-Kutta function */
double f(double x, double y, int i); /* function for derivatives */
double t, y[N];
output=fopen("osc.dat", "w"); /* external filename */
y=1.0; /* initial position */
y=0.0; /* initial velocity */
fprintf(output, "0\t%f\n", y);
for (j=1; j*dist<=MAX ;j++) /* time loop */
runge4(t, y, dist);
fprintf(output, "%f\t%f\n", t, y);
void runge4(double x, double y, double step)
double h=step/2.0, /* the midpoint */
t1[N], t2[N], t3[N], /* temporary storage arrays */
k1[N], k2[N], k3[N],k4[N]; /* for Runge-Kutta */
t2[i]=y[i]+0.5*(k2[i]=step*f(x+h, t1, i));
t3[i]=y[i]+ (k3[i]=step*f(x+h, t2, i));
k4[i]= step*f(x+step, t3, i);
double f(double x, double y, int i)
x=y; /* derivative of first equation */
x= -0.2*y-y; /* derivative of second equation */
A teacher walks into the Classroom and says If only Yesterday was Tomorrow Today would have been a Saturday Which Day did the Teacher make this Statement?
How many 3s in 313433535333?
What year woould you graduate high school if you were born in 1968?
What funnehcake roblox password?
How long does it take a oak tree to grow 30m high?
How many bones in a squirrels hand?
What pro football team did dan blocker play for?
Who would be the oldest if they were alive today William Shakespeare George Washington Albert Einstein Leonardo da Vinci?
Have you ever crashed a wedding or had your wedding crashed, if so what happened?
How many times did Joe Biden run for president?
What is the world’s oldest soft drink?
How many novels did Charles Dickens write?
What do the colors on America's flag mean?
How did Harry Houdini come up with his stage name?
What is modal fabric?
What were George Washington's false teeth made from?
What helps you manage folders stored in various locations on a computer or divce?
Why is milk used an antidote for lead poisoning?
Accountancy is necessary while auditing is a luxury comment?
What term means a group of connected or related objects or materials?
Why is corruption an unwanted activity in a country like in the Philippines?
How much pavan is one kg gold?
What is the name of Lavanya in devyani serial?
Which one of the following situations is least likely to lead to a breach of the contract?
Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.