-2

I want to solve a system of non-linear equation by modifiying the "x" argument on the function shown below. The other arguments do not need to be modified. How can I tell python to keep fixed all arguments except for "x"?

def equations(L, N, tu, x, p, fi, A, E, a, b, n1, xc, xh, xo, m):

Thanks,

Andrés

  • fsolve is what you are looking for: http://pageperso.lif.univ-mrs.fr/~francois.denis/IAAM1/scipy-html-1.0.0/generated/scipy.optimize.fsolve.html. See example usage here: https://stackoverflow.com/questions/40783190/solve-a-system-of-non-linear-equations-in-python-scipy-optimize-fsolve – KBriggs Apr 02 '20 at 12:53

1 Answers1

0

You have to use default values: for example consider

def solveEQ(f=myfun, x=42, firstParam = 4, secondParam = 5):
    SOME_CODE_HERE

By calling simply solveEQ() you will use the default parameters: myfun for f, 42 for x, 4 for firstParam and 5 for secondParam.

If you want to change only the input for x (e.g. x=17), you have to call your function with solveEQ(x=17): all the other inputs will remain set to the default value.

Have a look here, section 4.7.1, if you need further information.

Eddymage
  • 1,008
  • 1
  • 7
  • 22