Oct-23-2020, 09:21 AM

I've tried with fsolve.

Here is my code:

Any suggestions ?

Thanks.

Here is my code:

import math import numpy as np from scipy.optimize import fsolve def f(LCR): #variables L = LCR[0] Cs = LCR[1] Rs = LCR[2] # global constants Pi = math.pi Rin = 10.0 Cl = 3.0e-12 # measurement-related constants f0 = 130e6 f1 = 140e6 f2 = 150e6 omg = [None]*3 out = [None]*3 omg[0] = 2*Pi*f0 omg[1] = 2*Pi*f1 omg[2] = 2*Pi*f2 out[0] = 6.658482971121064 out[1] = 25.89226207742419 out[2] = 7.013950018010094 # A and B arrays Ar = [None]*3 Aj = [None]*3 Br = [None]*3 Bj = [None]*3 equ = [None]*3 # equation building for i in range(3): Ar[i] = 1 - omg[i]**2*Cl*L Aj[i] = omg[i]*Cs*Rs Br[i] = 1 - omg[i]**2*(L*(Cs + Cl) + Cl*Cs*Rin*Rs) Bj[i] = omg[i]*(Cs*Rs + Cl*Rin + Cl*Rs - omg[i]**2*Cl*Cs*Rin*L) equ[i] = out[i] - math.sqrt(Ar[i]*Ar[i] + Aj[i]*Aj[i])/math.sqrt(Br[i]*Br[i] + Bj[i]*Bj[i]) return equ LCR0 = np.array([0.3e-6, 1e-12, 1]) LCR = fsolve(f, LCR0) LCRHere is output:

```
Output:Warning (from warnings module):
File "/home/pavel47/.local/lib/python3.8/site-packages/scipy/optimize/minpack.py", line 175
warnings.warn(msg, RuntimeWarning)
RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last five Jacobian evaluations.
>>> LCR
array([ 3.10756682e-07, 1.02921301e-12, -4.22520679e+00])
>>>
```

While the first two values are correct, the third is completely wrong.Any suggestions ?

Thanks.