-1

我有这个功能:

def g(R, r):
    return (np.sqrt(2.0 * (R + r) / (r * R)) - (1 + np.sqrt(R)) / np.sqrt(R) -
            np.sqrt(2.0 / (r * (1 + r))) * (1 - r) -
            (1.0 / np.sqrt(R) - np.sqrt(2.0) * (1 - R) / np.sqrt(R * (1 + R))
             - 1))

该函数通过设置delta v_B = delta v_Hwhere delta v_Bis来定义

np.sqrt(2.0 * (R + r) / (r * R)) - (1 + np.sqrt(R)) / np.sqrt(R) -
                np.sqrt(2.0 / (r * (1 + r))) * (1 - r)

并且delta v_H

1.0 / np.sqrt(R) - np.sqrt(2.0) * (1 - R) / np.sqrt(R * (1 + R)) - 1

因此,我写gdelta v_b - delta v_H.

现在这是我的函数和我在下面使用的代码:

import pylab
import numby as np


def g(R, r):
    return (np.sqrt(2.0 * (R + r) / (r * R)) - (1 + np.sqrt(R)) / np.sqrt(R) -
            np.sqrt(2.0 / (r * (1 + r))) * (1 - r) -
            (1.0 / np.sqrt(R) - np.sqrt(2.0) * (1 - R) / np.sqrt(R * (1 + R))
             - 1))


r = np.linspace(11.9, 16, 500000)
R = np.linspace(1, 20, 500000)

fig2 = pylab.figure()
ax2 = fig2.add_subplot(111)
ax2.plot(R, g(R, r), 'r')
pylab.xlabel('$R_1 = \\frac{r_C}{r_A}$')
pylab.ylabel('$R_2 = \\frac{r_B}{r_A}$')
pylab.xlim((0, 25))
pylab.ylim((0, 100))                               

pylab.show()

该函数应在 about 处渐近无穷,并在 about处11.94与线相交y = x15.58

我怎样才能做出这样的情节?我不熟悉如何执行此操作,也不知道如何绘制这样的函数。

我的定义不适合gasg(R, r)吗?如果是这样,如果不是这种情况应该如何定义?

在此处输入图像描述

4

1 回答 1

2

这是调用隐函数曲线,您可以使用contour参数来绘制它levels=[0]

import numpy as np
import matplotlib.pyplot as plt

def g(R, r):
    return (np.sqrt(2.0 * (R + r) / (r * R)) - (1 + np.sqrt(R)) / np.sqrt(R) -
            np.sqrt(2.0 / (r * (1 + r))) * (1 - r) -
            (1.0 / np.sqrt(R) - np.sqrt(2.0) * (1 - R) / np.sqrt(R * (1 + R))
             - 1))

R, r = np.mgrid[1:30:200j, 1:100:200j]
Z = g(R,r)
plt.contour(R, r, Z, colors='k', levels=[0]) 
plt.show()

在此处输入图像描述

于 2013-07-04T01:05:42.393 回答