A long trigonometric expression I have the following expression in my C++ code:

theta1 = theta0 - (acos((pow(constlength_link1 + length, 2) + (pow(length_base_end, 2) - pow(length_link2, 2)))
     / (2 * length_base_end * (constlength_link1 + length)))) * 180 / M_PI;


I understand that such a code will be very difficult for anyone else to debug. Should I break it down using additional variables?

Are there any other better approaches?

Edit: Sorry about the lack of details:

I am trying to calculate sum of two angles theta1 and theta2. These angles are being calculated by subtracting the inverse of cosine of an expression from a constant angle (theta0 or 180). The expression mentioned in the last line involves a division. The dividend is something like:


  (square of sum of two numbers) +/- (square of a number  - square of
  another number)


The divisor is something like:


  (2 * a number * (sum of two numbers))


The function is as shown below:

float length_angle(float length = 0.0)
{
    float theta1, theta2;

    theta1 = theta0 - (acos((pow(constlength_link1 + length, 2) + (pow(length_base_end, 2) - pow(length_link2, 2)))
     / (2 * length_base_end * (constlength_link1 + length)))) * 180 / M_PI;

    theta2 = 180 - (acos((pow(constlength_link1 + length, 2) - (pow(length_base_end, 2) - pow(length_link2, 2)))
     / (2 * length_link2 * (constlength_link1 + length)))) * 180 / M_PI;

    return theta1 + theta2;
}


I would like to write this expression better so that someone else can read or debug the code if required.
I am trying to calculate sum of two angles theta1 and theta2. These angles are being calculated by subtracting the inverse of cosine of an expression from a constant angle (theta0 or 180). The expression mentioned in the last line involves a division. The dividend is something like:
(square of sum of two numbers) +/- (square of a number - square of another number)
The divisor is something like:
(2 * a number * (sum of two numbers))

Don't tell us, tell the maintainer of your codebase!
float length_angle(float length = 0)
{
    auto square = [](auto x) { return x*x; };

    auto dividend1 = square(constlength_link1 + length) + square(length_base_end) - square(length_link2);
    auto divisor1 = 2 * length_base_end * (constlength_link1 + length);

    float theta1 = theta0 - acos(dividend1 / divisor1) * 180 / M_PI;

    auto dividend2 = square(constlength_link1 + length) - square(length_base_end) + square(length_link2);
    auto divisor2 = 2 * length_link2 * (constlength_link1 + length);

    float theta2 = 180 - acos(dividend2 / divisor2) * 180 / M_PI;

    return theta1 + theta2;
}

Three optimizations I'd make to this code for better API design: First, don't use default function arguments. If I meant to write length_angle(1) but fat-fingered length_angle() instead, give me an error! If I meant to write length_angle(0), trust me to write it. You're hurting more than you're helping when you try to save your caller that one extra character of typing.
Second, use radians. Radians are the right answer for trig in the same way that UTF-8 is the right answer for character encoding. Trust the past couple millennia of mathematicians when they tell you that angles should be measured in radians. This will save you some repetition here, and some unnecessary rounding errors as well.
Third, optionally, use double; it'll give you more accuracy and be no slower — maybe even faster — than float if you're targeting a normal desktop computer. Obviously if you're targeting a 32-bit microprocessor with hardware float and software-emulated double, don't use double. :)
In your real code, the above will be super readable because you'll be using real names for the variables instead of long placeholders like constlength_link1. You can also say sqr or sq instead of square. So:
double length_angle(double length)
{
    auto sq = [](auto x) { return x*x; };

    auto a1 = sq(L1 + length) + sq(L3) - sq(L2);
    auto b1 = 2 * L3 * (L1 + length);

    auto theta1 = theta0 - acos(a1 / b1);

    auto a2 = sq(L1 + length) + sq(L2) - sq(L3);
    auto b2 = 2 * L2 * (L1 + length);

    auto theta2 = M_PI - acos(a2 / b2);

    return theta1 + theta2;
}

Lastly, perhaps notice that theta1 + theta2 is theta0 + M_PI - (acos(a1/b1) + acos(a2/b2)); and perhaps deal with the possibility of division-by-zero when b1 or b2 is zero. Or even factor out the repeated code, now that it's been made blatantly obvious by our renamings:
double length_angle(double length)
{
    auto sq = [](auto x) { return x*x; };

    auto f = [&amp;](auto start, auto a, auto b) {
        auto y = sq(L1 + length) + sq(b) - sq(a);
        auto x = 2 * b * (L1 + length);
        return start - acos(y / x);
    };

    return f(theta0, L2, L3) + f(M_PI, L3, L2);
}