[SciPy-User] Solve an arbitrary function
nicky van foreest
vanforeest@gmail....
Fri Jul 31 02:19:21 CDT 2009
Hi,
If you like a graphical approach you might give PyX a try, and have
postscript solve your problem:
http://pyx.sourceforge.net/examples/path/intersect.html
2009/7/31 Robert Kern <robert.kern@gmail.com>:
> On Thu, Jul 30, 2009 at 23:03, Permafacture<permafacture@gmail.com> wrote:
>> I'm new to this package, and am used to mathematica.
>>
>> I've been reading through the tutorials and numpy lists of functions,
>> yet i cannot find the answer to this, though it would be trivial in
>> mathematica. Can someone show me an example of how to find the
>> intersection of a line and a polynomial?
>>
>> for instance: y1=x1^2, y2=x2+1
>>
>> Solving a system of linear equations is pretty straight forward, but
>> it isn't clear to me how to approach this in scipy. The most general
>> approach to this would probably be the most useful to me.
What would be the best place to document examples such as Robert's
below? I am afraid such examples get burried in the mailing list while
they are great examples of how to use fsolve, for instance.
Nicky
>
> http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fsolve.html#scipy.optimize.fsolve
>
>
> In [1]: from scipy.optimize import fsolve
>
> In [2]: import numpy as np
>
> In [3]: def f(xy):
> ...: x, y = xy
> ...: z = np.array([y - x**2, y - x - 1.0])
> ...: return z
> ...:
>
> In [4]: fsolve(f, [1.0, 2.0])
> Out[4]: array([ 1.61803399, 2.61803399])
>
> In [5]: fsolve(f, [-0.5, 1.5])
> Out[5]: array([-0.61803399, 0.38196601])
>
>
> --
> 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
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-User
mailing list