Here’s my way. I have an experimental version of LsqFit
installed, so there will be a slight difference in syntax, but I just realized I’m in a bit of a hurry so I won’t fix that.
using Plots, LsqFit, Roots
default(;fontfamily="Computer Modern", label=nothing, seriestype=:scatter) # Better plot defaults
x_1 = 1:10
x_2 = 1:8
y_1 = [8.02511788606e7, 9.98481296252e7, 2.328332483329e8, 6.148181496526e8, 9.453171952624e8, 1.2331292887706e9, 1.4394296796998e9, 1.460066157955e9, 1.3570403824485e9, 1.4269447174002e9]
y_2 = [1.434628836798e8, 1.318375623746e8, 1.108524843855e8, 6.91176196241e7, 4.19137382458e7, 1.48676444645e7, 1.00659726053e7, 7.8734512643e6]
model(x, p) = 1e9*p[1]/(1+exp(-(x-p[2])/p[3])) # logistic function
f_1 = curve_fit(model, x_1, y_1, [1.0, 1.0, 1.0])
f_2 = curve_fit(model, x_2, y_2, [1e-1, 1.0, -1.0])
x_long = range(0.5,10.5;length=200)
pl_1 = plot(x_1, y_1)
plot!(pl_1, x_2, y_2)
plot!(pl_1, x_long, model.(x_long,Ref(f_1.param)); st=:line)
plot!(pl_1, x_long, model.(x_long,Ref(f_2.param)); st=:line)
g(x) = model(x, f_1.param) - model(x, f_2.param)
pl_2 = plot(g, x_long, st=:line)
plot(pl_1, pl_2; layout=(2,1)
find_zero(g, 2.0) # returns ~ 2.27