Skip to contents

Line search over indexed array in one direction

Usage

index_line_search(f, xarray, y1 = NULL, plot = "none", verbose = 0)

Arguments

f

f

xarray

xarray

y1

y1

plot

plot

verbose

Level to print

Value

List

Examples

index_line_search(function(x) {(x-100)^2}, 1:290)
#> $ind
#> [1] 100
#> 
#> $x
#> [1] 100
#> 
#> $val
#> [1] 0
#> 
index_line_search(function(x) {(-x-100)^2}, -(1:290)^.92, plot="ind")

#> $ind
#> [1] 149
#> 
#> $x
#> [1] -99.84616
#> 
#> $val
#> [1] 0.02366674
#> 
index_line_search(function(x) {(-x-100)^2}, -(1:290)^.92, plot="x")

#> $ind
#> [1] 149
#> 
#> $x
#> [1] -99.84616
#> 
#> $val
#> [1] 0.02366674
#> 
xx <- sort(runif(1e2, -250, -30))
index_line_search(function(x) {(-x-100)^2}, xx, plot="ind")

#> $ind
#> [1] 74
#> 
#> $x
#> [1] -100.3642
#> 
#> $val
#> [1] 0.1326111
#> 
index_line_search(function(x) {(-x-100)^2}, xx, plot="x")

#> $ind
#> [1] 74
#> 
#> $x
#> [1] -100.3642
#> 
#> $val
#> [1] 0.1326111
#>