- #1

- 69

- 1

## Homework Statement

I have a code that successfully plots the trajectory of a ball moving under gravity and air resistance, but my method is rather long-winded and I want to use a 4d vector-first order ODE instead - but I don't know how to do it. I've tried writing some simple skeletons but can't get them to work either. I basically need instructions on how to do it.

## Homework Equations

These are the equations that are processed to find (i+1) value of position and velocity in x and y components;

x2 = x1 + vx1*dt

y2 = y1+vy1*dt

vx2 = vx1 + Fx*dt

vy2 = vy1 + (-g*dt) + Fy*dt

And the corresponding equations for the functions;

Fx = (-1)*alpha*v*vx

Fy = (-1)*alpha*v*vy

(The x and y values are put into arrays and plotted on a graph)

My notes give Y = (x,y,vx,yv) and F(x,y,vx,vy,t) = (vx,vy,ax,ay)

With dY=dt = F(Y,t).

This part I am unsure on how to deal with.

## The Attempt at a Solution

My attempts at a skeleton for the vector was as follows;

REAL, DIMENSION (1,2,3,4) :: Y

Y(1) = x1 + vx1*dt

Y(2) = y1+vy1*dt

Y(3) = vx1 + Fx*dt

Y(4) = vy1 + (-g*dt) + Fy*dt

I got rank errors at the open parentheses on all vectors. In truth, I have little idea how to do this but I know it can;t be complicated.

Last edited: