The goal of this notebook is to plot the function \((\lambda,\gamma)\mapsto A_k(\lambda,\gamma)\) defined in Lemma 4 of https://arxiv.org/abs/1906.08530
functionA <- function(k,lambda,gamma)
{
if (!require("pracma")) install.packages("pracma")
library(pracma)
A <- sqrt(lambda - 1)/lambda
A <- A * (2*sqrt(lambda)/log(lambda-1))^k * k
gamma_arg <- 0.5*sqrt(gamma)*log(lambda-1)
A <- A * gammainc(gamma_arg,k)[[2]]
A <- A + (k * (gamma*lambda)^(0.5* k - 1) - 2)/(k-2)
}
We will now compute the values of \(A_4(\cdot,\cdot)\) on a sufficiently fine grid of the rectangle \((\lambda,\gamma)\in [12,18]\times [4,6]\).
m <- 30
Matrix_A4 = matrix(0,m,m)
gamma_vec <- 4 + (6-4)*((1:m)/m)
lambda_vec <- 12 + (18 - 12) * ((1:m)/m)
for (ncol in 1:m)
{
gamma = gamma_vec[ncol]
for (nrow in 1:m)
{
lambda = lambda_vec[nrow]
Matrix_A4[nrow,ncol] <- functionA(4, lambda, gamma)
}
}
## Loading required package: pracma
We will now plot the corresponding surface.
if (!require("plotly")) install.packages("plotly")
## Loading required package: plotly
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(plotly)
lambda <- lambda_vec
gamma <- gamma_vec
A4 <- Matrix_A4
fig <- plot_ly(x = ~lambda, y = ~gamma, z = ~A4) %>% add_surface(
contours = list(
z = list(
show=TRUE,
start = 441,
end = 443, size = 0.3,
usecolormap=TRUE,
highlightcolor="#ff0000",
project=list(z=TRUE)
)
)
)
fig <- fig %>% layout(
scene = list(
camera=list(
eye = list(x=2, y=0.98, z=0.24)
)
)
)
fig
#print(functionA(4,15,5))
We do now the same for \(k=3\).
m <- 30
Matrix_A3 = matrix(0,m,m)
gamma_vec <- 4 + (6-4)*((1:m)/m)
lambda_vec <- 12 + (18 - 12) * ((1:m)/m)
for (ncol in 1:m)
{
gam = gamma_vec[ncol]
for (nrow in 1:m)
{
lamb = lambda_vec[nrow]
Matrix_A3[nrow,ncol] <- functionA(3, lamb, gam)
}
}
A3 <- Matrix_A3
fig <- plot_ly(x = ~lambda, y = ~gamma, z = ~A3) %>% add_surface(
contours = list(
z = list(
show=TRUE,
start = 40,
end = 41, size = 0.1,
usecolormap=TRUE,
highlightcolor="#ff0000",
project=list(z=TRUE)
)
)
)
fig <- fig %>% layout(
scene = list(
camera=list(
eye = list(x=2, y=0.98, z=0.24)
)
)
)
fig
The graphically determined nearly optimal values are computed here.
print(functionA(3,13,5))
## [1] 40.73317
print(functionA(4,15,5))
## [1] 441.4962