Cats DO NOT respond to spanking or rubbing noses in urine or stool!
If you are uncontrollably angry with your cat, leave the room or even the house until you are calm and and can interact rationally with the situation.
Your cat loves you. Do not teach it to fear you instead by inhumane punishment.
"I think that my cat is mad at me and getting even with me by urinating outside of the box!"
Cats do not think of getting revenge on their owners. However, stress from changes can both cause marking behavior and trigger flare ups of cystitis and inflammatory bowel disease. Stressors can include disruption of the household routine due to a new baby, extended absences of beloved family members, remodeling in the household, a move to a new house, a new pet, etc.
Difficult as it is, this is the time for you to give your cat more positive attention, even if you are upset. Find your cat doing something appropriate and praise it. For example, if the cat is in the box, praise it and give a food treat after it uses the box. Cats may not understand the words you use, but they do understand tone and body language. When you are angry with your cat, that anger increases the cat's stress and consequently is likely to increase urine marking. Reward the behavior you want to have continue. Even sitting on the sofa watching TV with your cat on your lap is perceived as positive attention by your cat. Make sure you make these bonding times a part of the daily routine even when litter box issues are occuring.
Confining the cat to a separate room with food, water and a litter box may help reduce both your cat's stress by limiting its access to other pets and areas to soil, and may reduce your stress by limiting areas that may need to be cleaned while treatment is commencing.
Remember that the inappropriate elimination will take some time to resolve. Medications need time to take effect. The behavioral modification techniques take time to implement. It takes time to clean the environment, put out extra large litter boxes, and find better litters. Also remember that if the inappropriate elimination has been long term, success may be considered if the frequency of accidents markedly decreases rather than stops completely and never happens again. You need to be consistent at following all the recommendations made for you and your cat. Picking and choosing the ones that are easiest to perform or performing them for short periods of time are unlikely to result in improvement of the litter box issues.