Power factor calculation