Inverse kinematics is derived using the law of cosines. Given a desired $(x, y)$ position, we solve backwards for the angles. The equation for $\theta_2$ comes from the triangle formed by the two links and the vector to the target.
$$
\cos\theta_2 = \frac{x^2 + y^2 - L_1^2 - L_2^2}{2 L_1 L_2}
$$
From this, $\theta_2$ can be positive ("elbow-down") or negative ("elbow-up"), giving the two solutions. Once $\theta_2$ is known, $\theta_1$ is found using the arc tangent of the target position, adjusted for the geometry of the second link.
Common Misconceptions and Points to Note
First, the simplistic dichotomy that "Forward Kinematics (FK) is easy, while Inverse Kinematics (IK) is hard" is dangerous. While the FK for a 2-link arm is indeed simple trigonometric sums, as the number of links increases, the FK equations themselves become complex depending on the joint configuration (rotational/prismatic) and the chosen coordinate frames. On the other hand, the IK for a planar 2-link arm, like the one handled by this tool, is a special case where a geometric "solution formula" exists. For many practical arms like 6-axis manipulators, such closed-form solutions often don't exist, and solutions are found via numerical computation (iterative methods). In these cases, the nature of the difficulty between FK and IK can even reverse.
Next, it's easy to think "once a solution is found, that's it," but a perspective for evaluating the "quality" of the solution is crucial. For example, when there are two solutions ("elbow up" and "elbow down") for the same target point, which one you choose depends on the application. If there are obstacles in the workspace, you would choose the posture that avoids them. If considering energy efficiency, you might choose a posture closer to the center of the joints' range of motion. Also, solutions near singular postures (e.g., where the arm is fully extended) can lead to unstable control because small changes in the target position cause drastic changes in joint angles. You can experience this sensation in this tool by setting L1 and L2 to the same length and placing the target point far away, nearly on the X-axis (y=0).
Finally, always be mindful of parameter units and reference directions. In this tool, angles are displayed in degrees, but internal calculations and many libraries use radians. Furthermore, the definition of the reference axis for θ1 (often the X-axis) and the positive rotation direction (generally counter-clockwise) can change depending on the coordinate system and right-hand/left-hand rule conventions. This is a critical item to verify first when interfacing with other systems. For instance, if a CAD system and a robot simulator have different coordinate system definitions, completely unexpected movements can occur.
Related Engineering Fields
The principles you learn with this tool are directly applied to various "multi-body system motion descriptions" beyond robotics. For example, in the analysis of automotive suspension mechanisms or the operation of hydraulic arms in construction machinery, the posture of systems composed of multiple links and joints is calculated precisely using forward kinematics concepts. In game development and CG animation, a character's skeletal model is essentially a collection of "joints and links," and IK is widely used to determine the position of the end effectors (hands and feet). IK technology is also core to applying motion capture data to characters with different body proportions.
Furthermore, it is deeply connected to "Mechanism Design" and "Robust Design" in design engineering. Did you observe how the reachable area (workspace) changes when you modify the link lengths L1 and L2 in this tool? This is fundamental for layout design in products, determining "whether this robot can perform tasks in this range." Also, when considering manufacturing tolerances and wear, the kinematic equations handled here become the starting point for sensitivity analysis, seeking link length ratios that minimize end-effector error even with some joint angle inaccuracies (so-called low "error sensitivity" design).
Another important field is Control Engineering. What IK provides is merely a "position command value"—the joint angles needed to reach the target position. To actually move a real robot, "servo control" is necessary to make each joint motor follow that command value quickly, accurately, and without vibration. Furthermore, when external forces act on the arm, such as when lifting an object, the discussion expands into "dynamics," which calculates the torque required to maintain posture. Kinematics provides the foundational "geometric" part for all of this.
For Further Learning
The next steps are "expansion into 3D space" and "experiencing numerical solutions". While the planar 2-link case could be solved geometrically, this isn't possible for a 3D 6-axis arm. For learning, understand "homogeneous transformation matrices," the foundation of 3D coordinate transformation. This is a powerful tool that represents joint rotations and translations with 4x4 matrices, expressing forward kinematics as matrix multiplication. For inverse kinematics, learn iterative numerical methods using the "Jacobian matrix," a representative example (e.g., the Newton-Raphson method). The Jacobian matrix relates joint velocities to end-effector velocity; inverting this relationship forms the basis for IK algorithms that iteratively update joint angles step-by-step toward the target.
If you wish to deepen the mathematical background, a review of linear algebra (vectors, matrices, eigenvalues) and multivariable calculus is essential. The operations of the aforementioned homogeneous transformation matrices and Jacobian matrices are all described in the language of linear algebra. Also, understanding derivatives is necessary for tackling "optimization problems" to select optimal postures and, when moving into dynamics, for handling "Lagrange's equations." As seen in the tool with the "elbow up/down" choice, IK typically has multiple solutions. Choosing the solution that minimizes energy or equalizes joint load among these is precisely a constrained optimization problem.
A recommended specific next topic is "Robot Arm Trajectory Planning". This field considers how to smoothly interpolate postures when moving the end-effector from point A to point B (e.g., by changing each joint angle via a cubic polynomial). After experiencing FK and IK with this tool, take the first step from "solving is the end" to the practical stage of "how to move it." Using simulation tools or programming languages (like Python's Robotics Toolbox) to write a simple script that generates a trajectory will significantly deepen your understanding.