How to mimic IK to move a bone using Python without actually setting up IK? Using Python in the script editor, I am currently moving my skeleton using motion capture data. For times when the data jumps to an inaccurate place or when there are gaps in the data, I want to use Inverse Kinematics logic to know where to move the bone.

Specifically, I would prefer to know the coordinate locations of where the bone head and bone tail would end up if inverse kinematics is applied and we know the locations and rotations of the bone's parent and its child.  Is there a formula or Python code to calculate this? 

edit: the reason why I can't manually set up inverse kinematics to do this is because when combined with my method of moving the armature with the mocap data, it totally freaks out so I want to do it case by case manually for a specific frame and bone when I need it
Many parts of Blender are accessible through the python API, like bones. Constraint logic is only accessible as it is via the interface, meaning you can setup constraints with python and bake their transforms.

Here you can see Blender's code structure.


  /source/blender/ikplugin/
  
  Inverse kinematics API, abstracting the itasc and iksolver modules.
  Note that while this system supports multiple inverse-kinematics
  solvers there is no plug-in system exposed from a user perspective.


You are probably interested in the iksolver_plugin.c file, which contains the code to calculate IK.

If you want to implement it from scratch, I recommend an iterative approximation.

Since you are mainly interested in arms and legs though, simple trigonometry will suffice as an IK system with only one joint only has "one" (or no) solution.