From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solve non-linear functions rapidly?
Date: Sun, 3 Apr 2011 18:19:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <inadmp$8u$>
References: <inac45$6lr$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1301854745 286 (3 Apr 2011 18:19:05 GMT)
NNTP-Posting-Date: Sun, 3 Apr 2011 18:19:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:719796

"Jani Korhonen" <> wrote in message <inac45$6lr$>...
> Dear all,
> I want to solve this function C1 * x^2 - exp(C2 * x) = 0 in Matlab, in which C1 and C2 are constants. I know it is easy to use fsolve to solve it, e.g. x=fsolve((x)C1*x^2-exp(C2*x), 0). My question is that x is a matrix, and I want to solve this equation at each point, i.e. obtaining an individual x value at each point. C1 and C2 might be different at different points, but they can be obtained in advance.
> However, if I use a loop to find out the answer at each point, it takes a lot of time. But if I use the following: X = fsolve((X), C1*X^2-exp(C2*X), zeros(size(X, 1), size(X, 2)), where X is a matrix. Matlab says that x must be square. It seems the function was not treated at individual points. So, how can I solve this equation rapidly? Thank you very much.
> Best regards,
> Jani
- - - - - - - - - -
  Substituting w = -C2/2*x puts your equation in the form of Lambert's W equation.  Solutions for that can be obtained from the 'lambertw' function in the Symbolic Toolbox which accepts numeric matrices.  That might be faster than using 'fsolve'.

Roger Stafford