something like this:

~ $ ptipython
Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Dec  7 2015, 11:16:01) 
Type "copyright", "credits" or "license" for more information.


IPython 4.1.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.


In [1]: def equations(p):
   ...:     (a, b, c, d, e, f, 
   ...:     g, h, i, j, k, l, 
   ...:     m, n, o, p, q, r, s, t, u)=p
   ...:     return (1 - a*j*p + d*l*q + g*n*r, 
   ...:              0 - b*j*p + e*l*q + h*n*r, 
   ...:              0 - c*j*p + f*l*q + i*n*r, 
   ...:              0 - a*k*p + d*m*q + g*o*r, 
   ...:              1 - b*k*p + e*m*q + h*o*r, 
   ...:              0 - c*k*p + f*m*q + i*o*r, 
   ...:              0 - a*j*s + d*l*t + g*n*u, 
   ...:              1 - b*j*s + e*l*t + h*n*u, 
   ...:              0 - c*j*s + f*l*t + i*n*u, 
   ...:              0 - a*k*s + d*m*t + g*o*u, 
   ...:              0 - b*k*s + e*m*t + h*o*u, 
   ...:              1 - c*k*s + f*m*t + i*o*u)


In [2]: from scipy.optimize import fmin


In [3]: import numpy as np


In [4]: def f(p):return np.abs(np.sum(np.array(equations(p))**2)-0)


In [5]: fmin(f,(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1))
Warning: Maximum number of function evaluations has been exceeded.
Out[5]: 
array([-0.89996132,  3.24921453,  2.05127943, -2.03527783,  1.69544993,
        1.40438226,  1.92348097,  1.06625688,  0.24227183,  0.08901109,
        0.09085688,  2.91819752,  0.6803978 ,  4.09234832,  1.90642669,
        2.95941855,  0.17154083, -0.02346012,  1.44161738, -0.02367669,
       -0.03451558])


In [6]: from scipy.optimize import fmin_l_bfgs_b


In [7]: fmin_l_bfgs_b(f,(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-7-b040792986e3> in <module>()
----> 1 fmin_l_bfgs_b(f,(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1))


/home/dta/anaconda3/lib/python3.5/site-packages/scipy/optimize/lbfgsb.py in 
fmin_l_bfgs_b(func, x0, fprime, args, approx_grad, bounds, m, factr, pgtol, 
epsilon, iprint, maxfun, maxiter, disp, callback, maxls)
    191 
    192     res = _minimize_lbfgsb(fun, x0, args=args, jac=jac, bounds=
bounds,
--> 193                            **opts)
    194     d = {'grad': res['jac'],
    195          'task': res['message'],


/home/dta/anaconda3/lib/python3.5/site-packages/scipy/optimize/lbfgsb.py in 
_minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, 
maxfun, maxiter, iprint, callback, maxls, **unknown_options)
    328                 # minimization routine wants f and g at the current 
x
    329                 # Overwrite f and g:
--> 330                 f, g = func_and_grad(x)
    331         elif task_str.startswith(b'NEW_X'):
    332             # new iteration


/home/dta/anaconda3/lib/python3.5/site-packages/scipy/optimize/lbfgsb.py in 
func_and_grad(x)
    276     else:
    277         def func_and_grad(x):
--> 278             f = fun(x, *args)
    279             g = jac(x, *args)
    280             return f, g


/home/dta/anaconda3/lib/python3.5/site-packages/scipy/optimize/optimize.py 
in function_wrapper(*wrapper_args)
    287     def function_wrapper(*wrapper_args):
    288         ncalls[0] += 1
--> 289         return function(*(wrapper_args + args))
    290 
    291     return ncalls, function_wrapper


/home/dta/anaconda3/lib/python3.5/site-packages/scipy/optimize/optimize.py 
in __call__(self, x, *args)
     62         self.x = numpy.asarray(x).copy()
     63         fg = self.fun(x, *args)
---> 64         self.jac = fg[1]
     65         return fg[0]
     66 


IndexError: invalid index to scalar variable.


In [8]: from scipy.optimize import fmin_bfgs


In [9]: fmin_bfgs(f,(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
, 1, 1))
Optimization terminated successfully.
         Current function value: 2.500000
         Iterations: 12
         Function evaluations: 483
         Gradient evaluations: 21
Out[9]: 
array([ 0.99750085,  1.13125434,  0.99750097,  0.84397729,  0.75589231,
        0.84398644,  0.8439863 ,  0.75589223,  0.84397754,  1.07736067,
        1.07736081,  0.73335887,  0.73335281,  0.73335274,  0.73335887,
        1.07736068,  0.73335893,  0.73335289,  1.07736063,  0.73335281,
        0.73335887])



On Wednesday, April 13, 2016 at 11:26:48 PM UTC-5, Fmwyso null wrote:
>
> Sorry for the vagueness of "solution set", I should have specified that 
> all I require is a unique numerical solution. 
>
> If optimization can provide this optimal solution (with minimized norm2), 
> that would be great.
>
> Otherwise, if Sympy could provide a set of symbolic solutions, I could 
> construct my own minimized norm2 solution.
>
> On Wednesday, April 13, 2016 at 8:31:12 PM UTC-7, Denis Akhiyarov wrote:
>>
>> Are you trying to find set of symbolic solutions by elimination or a 
>> unique numerical solution by optimization, since it is indeterminate? 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ed17026f-9aee-4968-b704-38a5300b073f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to