[SciPy-user] questions about solving equations in scipy
Robert Kern
robert.kern@gmail....
Wed Jun 13 11:44:51 CDT 2007
fdu.xiaojf@gmail.com wrote:
> Hi all,
>
> I have posted this to python-list, and some people kindly pointed that here is
> a better place for scipy related questions.
>
> I have two questions about scipy.
>
> 1) When I was trying to solve a single variable equations using scipy, I
> found two methods: scipy.optimize.fsolve,and scipy.optimize.newton.
>
> I have tried both, and it seemed that both worked well, and fsolve ran
> faster.
>
> My questions is, which is the right choose ?
Like I said on the python-list, whichever one works best for your particular
problem.
> And I also found that there are models and functions in both scipy and numpy,
> such as scipy.linalg.solve() and numpy.linalg.solve(), and both can solve a
> linear equation. Are they the same in the ground?
Yes.
> 2) I have to solve a linear equation, with the constraint that all
> variables should be positive. Currently I can solve this problem by
> manually adjusting the solution in each iteration after get the solution
> bu using scipy.linalg.solve().
>
> I found a web page about optimization solver in
> openoffice(http://wiki.services.openoffice.org/wiki/Optimization_Solver#Non-Linear_Programming).
> Openoffice has an option of "Allow only positive values", so I think that
> may be a well-defined problem. Sorry for my ignorance if I was wrong.
What this page is talking about is optimization (minimizing the error), not
solving a linear equation (error = 0). Take a look at the bound-constrained
optimizers in scipy.optimize: fmin_l_bfgs_b and fmin_tnc.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user
mailing list