Answers for "python solver"

2

python system of nonlinear equations

import scipy.optimize as opt
from numpy import exp

def f(variables) :
    (x,y) = variables
    first_eq = x + y**2 - 4
    second_eq = exp(x) + x*y - 3
    return [first_eq, second_eq]

solution = opt.fsolve(f, (0.1, 1)) # fsolve(equations, X_0)
print(solution)

# [ 0.62034452  1.83838393]
Posted by: Guest on March-03-2020
0

solve equation python

>>> from sympy.solvers import solve
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> solve(x**2 - 1, x) #Your equation here
[-1, 1]
Posted by: Guest on December-04-2020
0

how to write x in terms of y sympy

def express(a, b, name):
    sym = symbols(name)
    sol = solve(a-sym, b)
    assert len(sol) == 1
    return (sym, sol[0])
Posted by: Guest on June-12-2020

Python Answers by Framework

Browse Popular Code Answers by Language