# 开发时间 2024/9/30 13:47
import math

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
C = math.sqrt((15 + math.sqrt(65)) / 8)
m = 1000
# 定义二元函数
def f_1(x_1, x_2):
    tmp = (x_1+(1/(m**2))*x_2 + C)
    return -(2/5)*tmp**4 + (8/5)*C*tmp**3 + (3/2 - (12/5)*(C**2))*tmp**2 + ((8/5)*C**3 -3*C)*tmp + 1
def f_2(x_1, x_2):
    tmp = (x_2+(1/(m**2))*x_1 + C)
    return -(2/5)*tmp**4 + (8/5)*C*tmp**3 + (3/2 - (12/5)*(C**2))*tmp**2 + ((8/5)*C**3 -3*C)*tmp + 1
def f_3(x_1,x_2):
    return x_1
# 生成坐标点
x = np.linspace(-1.8, 1.8, 10000)
y = np.linspace(-3, 3, 10000)
x, y = np.meshgrid(x, y)

# 计算函数值
Z = f_1(x, y)

# 绘制图像
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, Z, cmap='Greys')

Z_1 = f_3(x,y)






ax.plot_surface(x, y, Z_1, cmap='Greys')







# plt.savefig('f_1.pdf',format='pdf')
plt.show()
x = np.linspace(1.4024, 1.4027, 10000)
z = f_1(x,y)
ax.plot(x, y, z, cmap='Reds')