Matlab: Solving the logarithmic equation

I have the following equation that I want to solve with respect to a :

 x = (ab-c+d)/log((ab)/(cd)) 

where x , b , c and d known. I used Wolfram Alpha to solve the equation, and the result:

 a = bx*W(-((cd)*exp(d/xc/x))/x) 

where W is the product logarithm function (Lambert function W). It might be easier to see it on the Wolfram Alpha page .

I used the built-in Matlab lambertW function to solve the equation. This is pretty slow and this is the bottleneck in my script. Is there another quicker way to do this? It does not have to be accurate to a decimal place.

EDIT: I had no idea this equation is so hard to solve. Here is an image illustrating my problem. Temperatures bd plus LMTD vary at each time step, but are known. Heat is transferred from the red line (CO2) to the blue line (water). I need to find the temperature "a". I did not know that it was so difficult to calculate!: P enter image description here

+7
matlab logarithm natural-logarithm wolframalpha
source share
3 answers

Another option is based on the simpler Wright ω function :

 a = b - x.*wrightOmega(log(-(cd)./x) - (cd)./x); 

provided that d ~= c + x.*wrightOmega(log(-(cd)./x) - (cd)./x) (i.e. d ~= c+ba , x in this case 0/0 ). This is equivalent to the main branch of the Lambert W function , W 0 , which I think is the decision branch you want.

Like in lambertW , there is wrightOmega in the Symbolic Math toolbar. Unfortunately, this will probably also be slow for a large number of entries. However, you can use wrightOmegaq for GitHub for complex-valued floating-point inputs (double or single-precison). The function is more accurate, fully vectorized and can be three to four orders of magnitude faster than using the built-in wrightOmega for floating point inputs.

For those interested, wrightOmegaq builds on this excellent paper:

Piers W. Lawrence, Robert M. Corless and David J. Jeffrey, " Algorithm 917: A Comprehensive Two-Point Evaluation of the Wright Omaga Function ," ACM Transactions on Mathematical Software, Vol. 38, No. 3, Article 20, pp. 1-17, April 2012

This algorithm goes beyond the cubic convergence of the Halley method used by Cleve Moler Lambert_W and uses a fourth-order convergence root search method (Fritsch, Shafer and Crowley, 1973) to converge to no more than two iterations.

Also, to further accelerate Moler Lambert_W using series extensions, see my answer in Math.StackExchange .

+4
source share

Two (combinable) options:

  • Is your script already vectorized? Evaluate a function for more than one argument. The execution for i = 1:100, a(i)=lambertw(rhs(i)); end for i = 1:100, a(i)=lambertw(rhs(i)); end runs slower than a=lambertw(rhs) .
  • If you are dealing with a real LambertW branch (i.e. your arguments are in the range [-1/e, inf) ), you can use the Lambert_W implementation provided by Clive Moler on File Exchange .
+1
source share

Do you know the mass flow rate on both sides of the heat exchanger at every time step? If so, then the temperature “a” can be solved using the “efficiency-NTU” approach, which does not require any iteration, not the LMTD approach. Link: e.g., http://ceng.tu.edu.iq/ched/images/lectures/chem-lec/st3/c2/Lec23.pdf

0
source share

All Articles