这个问题来自于那个calculate lim function with plot in R。莫里斯·埃弗斯提供了工作解决方案,但我需要计算渐近线的结果才能在图中标记为红点。
所以这里是lim (\lim_{x \to \infty}\left(\frac{x}{x - 1} - 2\right) )

此函数的结果=-1
这个函数(x /(x-1)- 2)的结果在R中是如何计算的,然后在这幅图上显示它。
my_func <- function(x) x / (x - 1) - 2
library(ggplot2)
ggplot(data.frame(x = 0), aes(x)) +
stat_function(fun = my_func, aes(colour = "Function")) +
geom_hline(aes(yintercept = -1, colour = "Asymptote")) +
scale_colour_manual(values = c("Asymptote" = "blue", "Function" = "orange")) +
xlim(-10, 10) +
theme_minimal()作为红点。
发布于 2018-10-27 19:59:01
由于R符合国际标准,因此它返回Inf/(Inf-1)的NaN,因此需要为函数提供一个非常大的数字:
lim <- my_func(exp(100))
> lim
[1] -1这个数字甚至可能更高。溢出发生在exp(600)和exp(800)之间的某个地方:
> exp(600)
[1] 3.77302e+260
> exp(800)
[1] Infhttps://stackoverflow.com/questions/53025268
复制相似问题