Trigonometry and studies on energy conservation would help here for sure.
Just finding a way to use trigonometry to create a "reflection vector" would help for bouncing/rebounding balls.
However, since it's likely that your table boundaries are perfectly vertical and horizontal (assuming a 2D downwards projection) you could "reflect" by inverting the direction's x or y, depending on which side it hits.
Of course, when balls collide with other balls, you will definitely need some trigonometry.
e.g. for a ball that collides with a wall on the right-hand side of the screen (positive x value):
first, I presume you have a velocity vector (the amount added to the ball's position/the ball is moved).
once it collides with the (right-hand) side, negative the x value of the velocity vector:
velocityVector.x = -velocityVector.x;
For example, if the currently velocity vector is (14, 14) (a South-East movement of 10), negating its x value would mean it becomes (-14,14) (a South-West movement of 10).
Something to be aware of is that when a collision happens and the velocity is negated, the collision should not happen again while the ball is still in its position. So, you can move the ball an extra movement after a collision to push it away from the collision area. Or, you could just move the x part to the maximum it is allowed to be before collision.
Doing it more accurately would mean that you would need to calculate the distance it has intersected the collision boundary, move the ball back to the exact point it would have collided, then - after flipping the direction of the velocity vector - move the ball forward by the distance it had intersected.