I want to implement the formula:
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;
int main(){
    double a, eps = numeric_limits<double>::epsilon();
    cout << "a=";
    cin >> a;
    double w = sqrt(a), prod = 1 + w;
    int n = 1;
    do {
        w = sqrt(w);
        prod *= 1 + w;
        cout << "ln(" << a << ")=" << ldexp(a-1, n)/prod << endl;
        n++;
    } while(abs(w - 1) > eps);
    return 0;
}
But e.g. ln(2.78787)=0.512639 and that cannot be true. Where is the mistake?

 
    