在R中找到有理函数的局部最大值 [英] Finding the local maximum of a rational function in R
本文介绍了在R中找到有理函数的局部最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何找到R中有理(多项式)函数的局部最大值,例如f(x)= 500 * t/(2 * t ^ 2 + 9)?我尝试了以下方法:
How would I find the local maximum of a rational (polynomial) function such as f(x) = 500*t/(2*t^2 + 9) in R? I tried the following:
t <- seq(0,10000,by=0.000001)
f <- 500*t/(2*t^2 + 9)
max(f)
但是我很快就用光了内存.
But I quickly ran out of memory.
推荐答案
所以,这就是我的操作方法.感谢G.和alistaire.
So, here is how I did it. Thanks to G. and alistaire.
f <- function(x){
z <- 500*x/(2*x^2+9)
return(z)
}
optimize(f,c(0,1000),maximum=TRUE)
Output:
$`maximum`
[1] 2.121332
$objective
[1] 58.92557
这篇关于在R中找到有理函数的局部最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文