General aviation pilot reported an NMAC during departure from ZZZ.
Synopsis
General aviation pilot reported an NMAC during departure from ZZZ.
Narrative
On Day 0; I was with Person A; a fellow member a flying club based at ZZZ. We were in the club plane which is a Piper Dakota; PA-28-235. The objective was to let Person A practice some touch and go's in the plane with myself as a safety pilot in the right seat. With the crowded airspace in and around ZZZ our members will often fly with another pilot as a second set of eyes and ears. We chose to go to ZZZ1 airport since ZZZ is too crowded for general pattern work.We took off on Runway XXR with a clearance to fly straight out. A Piper Archer belonging to a flight school was given an identical clearance just prior to our departure. We had a visual on the departing flight school aircraft during our climb-out. ZZZ-Tower gave the flight school aircraft a clearance for a right turn and we watched the Archer execute it. Shortly thereafter we were also given a clearance for a right turn which we performed at a point outside where the Archer turned. This put us to the left of the Archer and behind it; but we were a much faster airplane and started to outpace it. I had a visual of the Archer to our right and below us but at some point I lost that visual; probably when I checked our progress to our next waypoint; ZZZZZ. About the time we were exiting the lateral limits of the ZZZ Delta airspace; I received a traffic alert on my iPad as well as the Garmin 530 of an aircraft coming up behind us with a dangerously close altitude separation. Both myself and Person A frantically started looking for the traffic and I then obtained visual contact with an aircraft which was behind us and off our right wing; maybe as close as half a mile. I thought this aircraft which I now had the visual was the Archer; but have since learned this was a fast-moving Cirrus. I then heard the flight school aircraft complain to the ZZZ Tower that we had cut them off. I apologized on the frequency if we unknowingly had cut them off. We proceeded to ZZZZZ and then to ZZZ1 with the remainder of the flight uneventful.Upon our return to ZZZ; Person A asked the Ground Controller for a phone number for the Tower. Once we got back to our hanger; Person A contacted the Tower and self-reported the incident. I heard the conversation and the person on the other end of the line assured us we had done nothing wrong.I would consider my own mistake in this incident to be taking my eyes off the other aircraft even for a moment since it is often hard to reacquire the location in a moving environment.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.