It’s a rare instance where you need to know, from your own code, the state of a plugin but, for instance, this may be something particularly relevant to a theme.
The usual way is to use the PHP command
functions_exists to check whether a specific function is present. Of course, hard-coding this is probably not the best idea as function names change. Instead the WordPress function
is_plugin_active is a better solution and you only need to specify the (non-changing) plugin slug for this to work.
Now, this will tell you if the plugin is active but what if you also want to know if it’s installed or not?