2

I need to solve the following equation in C:

a + ln(a) = x

I know the value of x and I need to find the value of 'a' that satisfies this equation. Can anyone suggest an efficient method for solving this equation. May be Newton Raphson, or anything more efficient ?

taskinoor
  • 45,586
  • 12
  • 116
  • 142
Ashwin
  • 90
  • 2
  • 10

1 Answers1

2

Newton Raphson Method will do good but I suggest that you try out Lambert W function.
W(x) = inverse of the function f(x)= xex.
So, in your case ln(a)+ a= x, then, taking the exponential of each side, eln(a)+ a= aea= ex. This gives you a=W(ex).
Now, you can apply approximations to solve this. But first, I suggest that you read about Lambert method carefully.

Vaibhav Agarwal
  • 1,124
  • 4
  • 16
  • 25