Calculate Angle for Triac Phase Control
You want to find \$\alpha\$ in the following equation:
$$ V_{rms} = V_{pk}\sqrt{\frac{2\pi - 2\alpha + sin(2\alpha)}{4\pi}}$$

In other words, you want to find out when:
$$  V_{pk}\sqrt{\frac{2\pi - 2\alpha + sin(2\alpha)}{4\pi}}-V_{rms} = 0$$

Then you have an entire wikipage dedicated to Root-finding algorithms for solving these kinds of problems. 

As the second equation is right now, I wouldn't go with Newton's method because I'm too lazy to find the derivative of the second equation with respect to \$\alpha\$. I would instead use the Secant method. But! I have a quick eye and can see that if I just rewrite the equation a little bit I can find the derivative of that very easily and then use Newton's equation. I do prefer to use Newton's equation when I can, because it converges pretty fast, compared to other methods.



So before we continue, allow me to go back to the first equation, divide both sides by \$V_{pk}\$ and then square both sides. This way we won't have to deal with square roots which is relatively time consuming. Let's multiply both sides by \$4\pi\$ while we're at it so we don't have to do any division. The function you have after doing what I just said is this one:

$$ 4\pi\bigg(\frac{V_{rms}}{V_{pk}}\bigg)^2 = 2\pi - 2\alpha + sin(2\alpha)$$

And again, let's find when it reaches 0 so we can apply the Root-finding algorithms. 

$$ 2\pi - 2\alpha + sin(2\alpha) - 4\pi\bigg(\frac{V_{rms}}{V_{pk}}\bigg)^2 = 0$$

And let's derive the equation above with respect to \$\alpha\$ so we can use Newton's method:

$$ 2cos(2\alpha)- 2 = 0$$

Now we're ready to start rolling with Newton's method! 

$$
x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)} \rightarrow \alpha_{n+1} = \alpha_n - \frac{2\pi - 2\alpha + sin(2\alpha) - 4\pi\bigg(\frac{V_{rms}}{V_{pk}}\bigg)^2}{2cos(2\alpha)- 2}
$$

And we're done (ish), we just need to implement it in code. The equation above will converge quadratically to the correct \$\alpha\$.



Here is an example of Newton's method in action written in C++:

#include &lt;iostream&gt;
#include &lt;cmath&gt;

#define pi 3.1415926535

using namespace std;

float f(float Vrms,float Vpk, float alpha){
    return 2*pi-2*alpha+sin(2*alpha)-4*pi*pow(Vrms/Vpk,2);
    //calculate f
}

float df(float alpha){
    return 2*cos(2*alpha)-2;
    //calculate the derivative of f
}

float calc_alpha(float Vrms,float Vpk){

    float alpha=0.5;
    //starting point = 0.5

    for(int i=0;i&lt;10;++i){
        //it usually converges within 10 steps

        float d = f(Vrms,Vpk,alpha)/df(alpha); 
        //Calculate how much we need to change so we can leave early
        //if we decide that we are close enough.

        cout &lt;&lt; "\nalpha = " &lt;&lt; alpha;

        alpha = alpha - d;
        //update our alpha 

        if((d&lt;0.001) &amp;&amp; (d&gt;-0.001)){ return alpha;}
        //leave if we're close enough
        //otherwise we'll leave when the for loop ends
    }

    return alpha;
}

int main(){
    float rms = 3.79318159;
    float pk = 5.4;
    float a = calc_alpha(rms,pk);
    cout &lt;&lt; "\n\nVrms = " &lt;&lt; rms &lt;&lt; "\nVpk = " &lt;&lt; pk &lt;&lt; "\nalpha = " &lt;&lt; a &lt;&lt; "\n";

    return 0;
}


Compiling the code above spits out the following information:

alpha = 0.5
alpha = 0.417462
alpha = 0.40068

Vrms = 3.79318
Vpk = 5.4
alpha = 0.400001


Which is correct, since I used Vpk = 5.4 and Alpha = 0.4 to calculate Vrms to 3.79318. And as you can see, it converged close enough in only 3 steps, on the 4th step alpha would've been equal to 0.4, for other values it might converge in less or more steps. 



Edit:

After OP made some fiddling with the code above, he converged to this code: 

#include &lt;iostream&gt;
#include &lt;cmath&gt;

#define pi 3.1415926535

using namespace std;

float f(float power, float alpha){
    return 2 * pi - 2 * alpha + sin(2 * alpha) - 4 * pi*pow(sqrtf(power) / sqrtf(2), 2);
    //calculate f
}

float df(float alpha){
    return 2 * cos(2 * alpha) - 2;
    //calculate the derivative of f
}

float calc_alpha(float power){
    float alpha = 0.5;
    //starting point = 0.5
    float d, oldD = 1000.0
    bool again = true;

    while (again) {
        for (int i = 0; i &lt; 20; ++i){
            d = f(power, alpha) / df(alpha);
            if (abs(d) &gt; abs(oldD)) {
                // the equation is diverging; the starting point was bad;
                alpha = (rand() % 3000) * 0.001 + 0.005;
                oldD = 1000.0;
                break;
            }
            oldD = d;
            alpha = alpha - d;
            if ((d&lt;0.001) &amp;&amp; (d&gt;-0.001)){ return alpha; }
            if (i == 19) again = false;
        }
    }
    return alpha;
}

float calculatePower(float alpha){
    return (2 * pi - 2 * alpha + sin(2 * alpha)) / (4 * pi) * 2;
}

int main(){
    for (int i = 0; i &lt; 180; i += 5){
        float alpha = i / 180.0 * pi;
        float power = calculatePower(alpha);
        float calculatedAlpha = calc_alpha(power);
        cout &lt;&lt; alpha &lt;&lt; "\t" &lt;&lt; power &lt;&lt; "\t" &lt;&lt; calculatedAlpha &lt;&lt; "\n";
    }
    cout &lt;&lt; "Press any key to finish.";
    cin.get();
    return 0;
}


Which solves his problem. So this is a 2-man answer with my answer as a base, and OP "perfecting" it. I've gotten permission to copy &amp; paste his solution into my answer so everything is in one place.