what model/year Mazda, what engine? maybe this is covered by a recall if it is a new car? it could be lots of things- low fuel in tank causing gaps in between fuel delievery to engine. could be caused when you turn hard, & all the gas sloshes to one side of the tank, opposite of the fuel pump. could be your spark plugs need to be changed, as they are missing at higher rpm... basically anything but there is no way anyone in the world would know with a question as vague as you just asked.
When was the last time you had a tune up? When the a/c pump is engaged it causes parasitic loss of horse power and rpm. The computer sees this loss and adjusts accordingly. From what you state, the vehicle rpm is dropping to low causing the vehicle to idle roughly. Give the vehicle a tune up and this should fix the problem.
iac is bad need to be replace
The 2012 Mazda Mazdaspeed3's engine produces 263 hp @ 5500 rpm.
The 2008 Mazda MAZDA3's engine produces 148 hp @ 6500 rpm.
The 2013 Mazda MAZDA3's engine produces 148 hp @ 6500 rpm.
The 2013 Mazda MAZDA6's engine produces 170 hp @ 6000 rpm.
The 2004 Mazda MAZDA3's engine produces 148 hp @ 6500 rpm.
The 2014 Mazda MAZDA2's engine produces 100 hp @ 6000 rpm.
The 2012 Mazda MAZDA5's engine produces 157 hp @ 6000 rpm.
The 2005 Mazda MAZDA6's engine produces 160 hp @ 6000 rpm.
The 2004 Mazda MAZDA6's engine produces 160 hp @ 6000 rpm.
The 2010 Mazda MAZDA5's engine produces 153 hp @ 6500 rpm.