Как сделать чтобы функция посчитала х2 и была возможность использовать х2 в другой функции?

функцияX2 считается в первой функции, как её передать во вторую?

import numpy as np
import scipy.integrate as integrate
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

#define universal variables
с0 = 0.03
c1 = 10
с3 = 3
m0=1
m1=2
m=m0/m1
#just a little extra, quite unimportant
def f(x):
    f = ((-m)*x)+(1/2)*((m0+m1)/m1)*(abs(x+1.0)-abs(x-1.0))
    return f
#the actual function calculating
def y(x):
    x1=(c1/с3)*f(x2-x1),
    x2=(-1/с3)*(f(x2-x1)+x3),
    x3=c3*x2
    print('x равно', x2)
    return x2


def dH_dt(H, t=0):
    x2=y(x)
    return np.array([(-c1/с3)*f(H[1]-H[0]),
                     (-1/с3)*(f(H[1]-H[0])+H[2])+(с0/с3)*(x2-H[1]),
                     c3*H[1]])
#computational time steps
t = np.linspace(0, 500, 4000)
#x, y and z initial conditions
G0 = [0.7, 0.7, 0.7]
H0 = [0.7, 0.7, 0.7]
H, infodict = integrate.odeint(dH_dt, H0, t, full_output=True)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(H[:,0], H[:,1], H[:,2])
plt.show()

Ответы (0 шт):