Polynomial fitting, regularization, Kobon triangle, Fujimura's triangle problem

using Optim
n = [3 4 5 6 7 8 9 13 15 17]
k = [1 2 5 7 11 15 21 47 65 85]
lambda = 2.5
f(lam, x) = 1/size(k)[2] * sum((x[1] .+ x[2].*(n) .+ x[3].*(n).^2 .- (k)) .^ 2) - lam * sum(abs.(x))
#f(lam, x) = 1/size(k)[2] * sum((x[1] .+ x[2].*(n) .+ x[3].*(n).^2 .+ x[4].*(n).^3 .+ x[5].*(n).^4 .+ x[6].*(n).^5 .+ x[7].*(n).^6 .+ x[8].*(n).^7 .- (k)) .^ 2) - lam * sum(abs.(x).^2)
#x0 = [0.0, 0.0, 0.0, 0.0, 0.0]
x0 = [0.0, 0.0, 0.0]
for i in 1:100
    lam = 0. + 0.002 * i
    g(x) = f(lam, x)
    res = optimize(g, x0).minimum
    println(abs(res),"###", lam)
end
lam1 = 0.1
costl1(x) = f(lam1, x)
l1res = optimize(costl1, x0).minimizer
3-element Vector{Float64}:
 -0.682241878486419
 -0.658912921983581
  0.3350440666781199
    

Kobon Triangle Problem

mathworld.wolfram.com

en.wikipedia.org

If we draw k lines, what is the largest number of triangles without overlapping?

This is we called Kobon triangle problem, or Fujimura's triangle problem. Actually, this is unsolved problem (2024 now)

 

We know some upper bound such as floor of (k-2)k/3

I conducted quadratic fitting, and obtain similar coefficients.

for polynomial fitting and its regularization, please see the following documents.

https://iopscience.iop.org/article/10.1088/1742-6596/1213/4/042054/pdf

 

Comment : Looks very interesting, but I don't fully understand how to solve that. Anyway this is just practice of programming.