# Real_Solution_Counts¶

```using HomotopyContinuation
using JuMP
using GLPK
using LinearAlgebra
using Symbolics
using Convex
using SCS
using DataFrames
using DelimitedFiles
using CSV
```
```@var s, t, r # Circle centered at (s, t) with radius r
@var u[1:3], v[1:3] # Three points of tangency (u, v), ..., (u, v)
@var a[1:6], b[1:6], c[1:6] # Three fixed conics with coefficients defined by a, ..., a; ... ; c, ..., c
```
```(HomotopyContinuation.ModelKit.Variable[a₁, a₂, a₃, a₄, a₅, a₆], HomotopyContinuation.ModelKit.Variable[b₁, b₂, b₃, b₄, b₅, b₆], HomotopyContinuation.ModelKit.Variable[c₁, c₂, c₃, c₄, c₅, c₆])
```
```f_1 = (u - s)^2 + (v - t)^2 - r # the point (u, v) lies on the circle

f_2 = (u - s)^2 + (v - t)^2 - r # the point (u, v) lies on the circle

f_3 = (u - s)^2 + (v - t)^2 - r # the point (u, v) lies on the circle

f_4 = a*u^2 + a*u*v + a*v^2 + a*u + a*v + a # the point (u, v) lies on the conic defined by coefficients a[1:6]

f_5 = b*u^2 + b*u*v + b*v^2 + b*u + b*v + b # the point (u, v) lies on the conic defined by coefficients b[1:6]

f_6 = c*u^2 + c*u*v + c*v^2 + c*u + c*v + c # the point (u, v) lies on the conic defined by coefficients c[1:6]

f_7 = det([differentiate(f_1, [u, v]) differentiate(f_4, [u, v])]) # Circle and conic are tangent at (u, v)

f_8 = det([differentiate(f_2, [u, v]) differentiate(f_5, [u, v])]) # Circle and conic are tangent at (u, v)

f_9 = det([differentiate(f_3, [u, v]) differentiate(f_6, [u, v])]) # Circle and conic are tangent at (u, v)

# Polynomial system in variables

paramVec = collect(Iterators.flatten([a,b,c]))

F = System([f_1, f_2, f_3, f_4, f_5, f_6, f_7, f_8, f_9], variables = [u, v, u, v, u, v, s, t, r], parameters = paramVec);
```
```df = DataFrame(CSV.read("filename", DataFrame))
```
```function no_real_roots(p)
S = solve(F, target_parameters = p, show_progress = false)
return length(real_solutions(S))
end
```
```no_real_roots (generic function with 1 method)
```
```df.Counts = zeros(70000) # Creates new column with all 0s, to be filled by no. of real sols.
```
```for i in range(1,70000)
if i % 500 == 0
df[i, 37] = no_real_roots(Vector(df[i, 19:36]))
print("\$(i) \n")
else
df[i, 37] = no_real_roots(Vector(df[i, 19:36]))
end
end
CSV.write("filename", df)
```
```"hc_data_70k_counts.csv"
```