```Path: news.mathworks.com!not-for-mail
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
References: <inac45\$6lr\$1@fred.mathworks.com>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1301854745 286 172.30.248.47 (3 Apr 2011 18:19:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 3 Apr 2011 18:19:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:719796

"Jani Korhonen" <eagle_nokia@hotmail.com> wrote in message <inac45\$6lr\$1@fred.mathworks.com>...
> 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
```