How to apply Newton's first law to moving object?

I'm new to many forces, such as gravity and friction, and I don't really know how they work. I'm trying to simulate a ball bouncing with a program, and it travels at a constant speed horizontally. I can calculate the friction on it (in Newtons of force).

However, since the ball is traveling at a constant speed horizontally, there is no acceleration. Therefore, since F = MA, if A = 0, then there is no force behind it. This makes sense because of Newton's first law: if an object is in motion, then it will stay in motion, unless another force acts upon it - in this case, that force is friction.

I know the speed, mass, density, and other properties of the ball. I know the force of the friction. But I don't know how much the friction will slow down the ball.

Is there an equation, or easy way to figure out how much to reduce the speed of the ball?

Solution: As @Luke said in his comment, F = MA can be rearranged to solve for the acceleration (or deceleration) of the ball given the force and the mass.

You can rearrange the equation by dividing m: $$F = ma ⇔ a = \frac{F}{m}$$

Now, knowing the force of friction, you can calculate the acceleration.

The last remaining step is to calculate the velocity. To do so, there are two possibilities you could choose:

1. The exact solution. To gain it, you will have to solve something called a differential equation: Since the acceleration is defined to be the instantaneous change of velocity with respect to time, it is defined by the derivative $a(t) = \frac{dv}{dt}$ (you may see other notations as $f'(t)$, or $\dot{f}$, where the last one always refers to the time derivative). An equation like $a(t) = \frac{dv}{dt}$ can not be reversed by simple arithmetical operations like multiplying or adding numbers or variables. In fact, solving a differential equation can get very difficult.
2. The approximate solution. Most simulations work in the followign way: They take the state at time $t=0$, take a “step forward” in time, and approximate the change of the state in this period. Obviously, smaller intervals yield more exact results. How it's technically done in this case is by approximating the derivative by a linear slope, i.e. $\frac{da}{dt} \approx \frac{Δa}{Δt}$. Note that the left hand side is not a quotient! It is a function on time, which is why it is written as $v'(t)$ as well! Now, we have replaced this function by an actual quotient, the difference quotient, which makes the prior differential equation to a simple equation solvable by arithmetic operations. To find $Δv$, we just can do: $$\frac{F}{m} = a = \frac{dv}{dt} \approx \frac{Δv}{Δt} ⇒ Δv \approx \frac{F}{m} Δt$$

Suppose the friction is given by $f$. For the sake of convenience It is taken as constant.

Suppose the ball of mass $m$ is given an initial force of $F$ infinitesimally greater than $f$ so that it starts moving initially with infinitesimal acceleration but as there is friction, the extra kinetic energy gets converted to heat energy while the ball works against the friction ultimately to move uniformly with speed $v$.

Calculation:

Let initially, the ball has zero velocity i.e. $u = 0$. Then force$F$ is applied in order to move it. Then, by Newton's 2nd Law, the equation of motion is $$F - f = ma$$ , where $a$ is the infinitesimal acceleration. Suppose $F$ acts for time $t$, then the velocity acquired after time $t$ is $$v'= u +at \implies v'= at$$. Now, as you said the force $F$ is removed. Now, there is only one force $f$ which will work certain time $t'$ to bring a halt to the aceleration. So, the final velocity $$v = v' - \dfrac{f}{m} t' \implies v= at - \dfrac{f}{m}t' \implies v = \dfrac{F - f}{m} t - \dfrac{f}{m} t'$$. You now only need to know $t$ & $t'$.

The simplest way to model friction to solve your problem is through something called the coefficient of restitution, which gives the ratio of the ball's speed after and before the bounce.

$$C = \frac{v_f}{v_i}$$

So everytime the ball hits the ground, you can use the coefficient of restitution to calculate the new velocity based on the previous velocity.

A typical value for the coefficient $C$ might be a value like 0.8. If you set it closer to 1, then the ball will bounce for much longer. A smaller value like 0.2 and the ball would stop very quickly.

Usually, air resistance is relatively small for slow-moving objects, so you can ignore it. Most of the energy is lost when the ball hits the ground, so you can use that as the primary source of friction in your model.