# Ik Stretch: Finding the Proportional Value

I have a tedious problem with IK stretch, and haven't found any hint when googling it. In a 2 bones IK chain with stretch, how to find the exact stretch value for each bone so that they are scaled with the same factor?

Let's say we want to stretch these two bones, same length in rest position. The third one at the top is the target. Setting the stretch value to 0.5 for each gives a correct scale of x2 when moving up the target bone to multiply the chain length by 2 (picture 1 and 2, click on the pic to expand it and see the unit grid better)

But, when dividing the first bone length by two in edit mode, the stretch is no more proportional (picture 3). The first bone should reach the red line to double its length, whereas it's a little higher. It's still possible to manually lower and find by iterations the stretch value of this bone to get the right scale, but i'd like to find the exact formula to write it in a python script.

Blend File

Thanks for any help!

    l1 = ulimb_p.length