Advertisement
mirosh111000

2

Sep 17th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from scipy.optimize import root
  2. import numpy as np
  3.  
  4. def equations(vars):
  5.     x, y, z = vars
  6.     eq1 = np.sin(x) + 5 * np.exp(y) - 3 * z
  7.     eq2 = 2 * x - np.log(y) + np.cos(z)
  8.     eq3 = 4 * np.sin(x) + 5 * y - z
  9.     return [eq1, eq2, eq3]
  10.  
  11. initial_guess = [1, 1, 1]
  12. result = root(equations, initial_guess)
  13. print(f'x = {result.x[0]}\ny = {result.x[1]}\nz = {result.x[2]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement