module NB5I

using NBodyIPs.FastPolys
using StaticArrays
# using BenchmarkTools: @btime

# include("fastpolys.jl")
# using FastPolys



tdegrees(::Val{5}) =
          (@SVector [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, ]),
    (@SVector [0, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, ])

# Primary invariants for NBody=5and deg=10
 # : definitions at the beginning of the file
const P1_1 = (1,2,3,4,5,6,7,8,9,10,)

const P2_1 = (1,1,1,2,2,3,1,1,1,2,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,)
const P2_2 = (2,3,4,3,4,4,5,6,7,5,6,7,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)

const P3_1 = (1,2,3,4,5,6,7,8,9,10,)

const P4_1 = (1,1,1,2,1,1,1,2,2,3,4,3,4,2,3,4,5,5,6,7,)
const P4_2 = (2,2,3,3,5,5,6,5,5,6,7,6,7,8,8,9,6,8,8,9,)
const P4_3 = (3,4,4,4,6,7,7,8,9,8,9,10,10,9,10,10,7,9,10,10,)

const P5_1 = (1,2,3,4,5,6,7,8,9,10,)

const P6_1 = (1,1,2,3,4,)
const P6_2 = (2,5,5,6,7,)
const P6_3 = (3,6,8,8,9,)
const P6_4 = (4,7,9,10,10,)

const P7_1 = (1,2,3,4,5,6,7,8,9,10,)

const P8_1 = (1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,1,1,1,2,2,3,4,3,4,2,3,4,)
const P8_2 = (2,2,2,2,2,2,2,3,4,2,3,4,3,4,3,4,4,4,5,5,5,5,5,5,5,6,6,5,6,7,)
const P8_3 = (3,3,3,3,3,3,5,5,5,5,6,7,5,5,6,7,6,7,6,6,6,6,7,6,7,7,7,8,8,8,)
const P8_4 = (4,4,4,4,4,4,6,6,6,8,8,9,8,8,8,9,8,9,7,7,7,8,8,8,9,8,9,9,9,9,)
const P8_5 = (5,6,7,8,9,10,7,7,7,9,10,10,9,9,10,10,10,10,8,9,10,9,9,10,10,10,10,10,10,10,)

const P9_1 = (1,2,3,4,5,6,7,8,9,10,)

const P10_1 = (1,2,3,4,5,6,7,8,9,10,)

# Irreducible secondaries for NBody=5and deg=10
 # : definitions at the beginning of the file
const IS1_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS1_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS2_1 = (1,1,1,2,2,3,5,5,6,8,)
const IS2_2 = (2,3,4,3,4,4,6,7,7,9,)
const IS2_3 = (5,6,7,8,9,10,8,9,10,10,)

const IS3_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS3_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS4_1 = (1,1,1,2,2,3,1,1,1,2,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS4_2 = (2,3,4,3,4,4,5,6,7,5,6,7,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)

const IS5_1 = (1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,8,9,10,5,5,6,7,6,7,8,9,10,8,9,10,)
const IS5_2 = (2,3,4,1,1,1,3,4,2,2,4,3,1,1,1,2,2,3,6,7,5,5,7,6,5,5,6,9,8,8,)
const IS5_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,3,4,4,8,9,8,9,10,10,6,7,7,10,10,9,)

const IS6_1 = (1,1,1,2,2,3,4,3,4,2,3,4,1,1,1,2,2,3,4,3,4,2,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,6,7,5,6,7,8,9,8,9,10,10,)
const IS6_2 = (2,2,3,1,1,1,1,1,1,3,2,2,5,5,6,5,5,6,7,6,7,8,8,9,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,6,5,5,8,8,9,5,5,6,7,6,7,)
const IS6_3 = (3,4,4,3,4,2,2,4,3,4,4,3,6,7,7,8,9,8,9,10,10,9,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,7,7,6,9,10,10,9,8,10,10,8,9,)

const IS7_1 = (1,1,1,1,1,1,2,2,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6,9,8,8,)
const IS10_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,3,4,4,8,9,8,9,10,10,6,7,7,10,10,9,)

const IS11_1 = (1,1,1,2,2,3,1,1,1,2,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS11_2 = (2,3,4,3,4,4,5,6,7,5,6,7,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)
const IS11_3 = (5,6,7,8,9,10,2,3,4,1,1,1,3,4,2,2,4,3,8,9,10,6,7,5,5,7,6,10,9,8,)

const IS12_1 = (1,1,1,2,2,3,4,3,4,2,3,4,1,1,1,2,2,3,4,3,4,2,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,6,7,5,6,7,8,9,8,9,10,10,)
const IS12_2 = (2,2,3,1,1,1,1,1,1,3,2,2,5,5,6,5,5,6,7,6,7,8,8,9,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,6,5,5,8,8,9,5,5,6,7,6,7,)
const IS12_3 = (3,4,4,3,4,2,2,4,3,4,4,3,6,7,7,8,9,8,9,10,10,9,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,7,7,6,9,10,10,9,8,10,10,8,9,)

const IS13_1 = (1,1,1,1,1,1,2,2,3,2,2,3,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS13_2 = (2,2,3,4,3,4,3,4,4,3,4,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)
const IS13_3 = (3,4,2,2,4,3,1,1,1,4,3,2,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,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6,7,6,7,5,5,6,7,6,7,8,8,8,9,8,9,2,2,3,4,3,4,2,2,3,4,3,4,3,4,3,4,4,4,3,4,3,4,4,4,6,7,5,5,7,6,6,7,5,5,7,6,5,5,5,5,6,6,9,8,9,8,8,8,7,7,7,6,7,6,8,8,8,9,8,9,6,7,6,7,7,7,9,8,9,8,8,8,)
const IS15_4 = (5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,6,7,6,7,7,7,8,9,8,9,10,10,8,9,8,9,10,10,9,9,10,10,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,8,9,8,9,10,10,8,9,8,9,10,10,6,7,6,7,7,7,10,10,10,10,9,9,8,9,8,9,10,10,9,9,10,10,10,10,9,8,10,10,8,9,10,10,10,10,9,9,)

const IS16_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS16_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS17_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS17_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS18_1 = (1,1,1,2,2,3,1,1,1,2,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS18_2 = (2,3,4,3,4,4,5,6,7,5,6,7,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)

const IS19_1 = (1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,8,9,10,5,5,6,7,6,7,8,9,10,8,9,10,)
const IS19_2 = (2,3,4,1,1,1,3,4,2,2,4,3,1,1,1,2,2,3,6,7,5,5,7,6,5,5,6,9,8,8,)
const IS19_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,3,4,4,8,9,8,9,10,10,6,7,7,10,10,9,)

const IS20_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS20_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)
const IS20_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,1,1,1,3,4,2,2,4,3,2,3,4,1,1,1,3,4,2,2,4,3,8,9,8,9,10,10,6,7,5,5,7,6,6,7,5,5,7,6,10,10,9,8,9,8,)

const IS21_1 = (1,1,1,2,2,3,5,5,6,8,)
const IS21_2 = (2,3,4,3,4,4,6,7,7,9,)
const IS21_3 = (5,6,7,8,9,10,8,9,10,10,)

const IS22_1 = (1,1,1,2,2,3,4,3,4,2,3,4,1,1,1,2,2,3,4,3,4,2,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,6,7,5,6,7,8,9,8,9,10,10,)
const IS22_2 = (2,2,3,1,1,1,1,1,1,3,2,2,5,5,6,5,5,6,7,6,7,8,8,9,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,6,5,5,8,8,9,5,5,6,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,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,6,7,6,7,7,7,8,9,8,9,10,10,8,9,8,9,10,10,9,9,10,10,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,8,9,8,9,10,10,8,9,8,9,10,10,6,7,6,7,7,7,10,10,10,10,9,9,8,9,8,9,10,10,9,9,10,10,10,10,9,8,10,10,8,9,10,10,10,10,9,9,)

const IS26_1 = (1,1,1,1,1,1,2,2,3,2,2,3,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS26_2 = (2,2,3,4,3,4,3,4,4,3,4,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)
const IS26_3 = (3,4,2,2,4,3,1,1,1,4,3,2,2,2,3,4,3,4,1,1,1,1,1,1,3,4,2,2,4,3,3,4,2,2,4,3,1,1,1,2,2,3,4,3,4,2,3,4,7,6,5,6,7,5,5,7,6,5,6,7,)
const IS26_4 = (5,5,6,7,6,7,8,9,10,8,9,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,8,9,10,6,7,5,5,7,6,10,9,8,8,9,10,9,8,10,10,8,9,10,9,8,)

const IS27_1 = (1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS27_2 =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,5,6,7,6,7,9,8,10,10,8,9,)

const IS31_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS31_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS32_1 = (1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,8,9,10,5,5,6,7,6,7,8,9,10,8,9,10,)
const IS32_2 = (2,3,4,1,1,1,3,4,2,2,4,3,1,1,1,2,2,3,6,7,5,5,7,6,5,5,6,9,8,8,)
const IS32_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,3,4,4,8,9,8,9,10,10,6,7,7,10,10,9,)

const IS33_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS33_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)
const IS33_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,1,1,1,3,4,2,2,4,3,2,3,4,1,1,1,3,4,2,2,4,3,8,9,8,9,10,10,6,7,5,5,7,6,6,7,5,5,7,6,10,10,9,8,9,8,)

const IS34_1 = (1,1,1,2,2,3,1,1,1,2,3,4,2,2,3,4,3,4,5,5,6,5,5,6,7,6,7,8,8,9,)
const IS34_2 = (2,3,4,3,4,4,5,6,7,5,6,7,8,9,8,9,10,10,6,7,7,8,9,8,9,10,10,9,10,10,)
const IS34_3 = (5,6,7,8,9,10,2,3,4,1,1,1,3,4,2,2,4,3,8,9,10,6,7,5,5,7,6,10,9,8,)

const IS35_1 = (1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,8,9,10,5,5,6,7,6,7,8,9,10,8,9,10,)
const IS35_2 = (2,3,4,1,1,1,3,4,2,2,4,3,1,1,1,2,2,3,6,7,5,5,7,6,5,5,6,9,8,8,)
const IS35_3 = (5,6,7,5,6,7,8,9,8,9,10,10,2,3,4,3,4,4,8,9,8,9,10,10,6,7,7,10,10,9,)

const IS36_1 = (1,1,1,2,2,3,4,3,4,2,3,4,1,1,1,2,2,3,4,3,4,2,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,6,7,5,6,7,8,9,8,9,10,10,)
const IS36_2 = (2,2,3,1,1,1,1,1,1,3,2,2,5,5,6,5,5,6,7,6,7,8,8,9,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,6,5,5,8,8,9,5,5,6,7,6,7,)
const IS36_3 = (3,4,4,3,4,2,2,4,3,4,4,3,6,7,7,8,9,8,9,10,10,9,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,7,7,6,9,10,10,9,8,10,10,8,9,)

const IS37_1 = (1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,1,1,1,1,1,1,2,2,3,4,3,4,2,2,3,4,3,4,2,2,3,4,3,4,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS37_2 = (2,2,3,4,3,4,1,1,1,1,1,1,3,4,2,2,4,3,3,4,2,2,4,3,5,5,6,7,6,7,5,5,6,7,6,7,8,9,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,9,9,10,10,10,10,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,8,9,8,9,10,10,8,9,8,9,10,10,6,7,6,7,7,7,10,10,10,10,9,9,8,9,8,9,10,10,9,9,10,10,10,10,9,8,10,10,8,9,10,10,10,10,9,9,)

const IS41_1 = (1,2,3,4,5,6,7,8,9,10,)

const IS42_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS42_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS43_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS43_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS44_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS44_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)

const IS45_1 = (1,2,3,4,5,6,7,8,9,10,)

const IS46_1 = (1,1,1,2,3,4,2,2,3,4,3,4,1,1,1,2,3,4,2,2,3,4,3,4,5,6,7,5,6,7,8,9,8,9,10,10,5,5,6,7,6,7,5,5,6,7,6,7,8,9,8,9,10,10,8,9,8,9,10,10,)
const IS46_2 = (2,3,4,1,1,1,3,4,2,2,4,3,5,6,7,5,6,7,8,9,8,9,10,10,1,1,1,2,3,4,2,2,3,4,3,4,6,7,5,5,7,6,8,9,8,9,10,10,5,5,6,7,6,7,9,8,10,10,8,9,)


# Primary invariants for NBody=5and deg=10
 # : definitions of the types at the beginning of the file
const P1 = Val((P1_1,))
const P2 = Val((P2_1,P2_2,))
const P3 = Val((P3_1,))
const P4 = Val((P4_1,P4_2,P4_3,))
const P5 = Val((P5_1,))
const P6 = Val((P6_1,P6_2,P6_3,P6_4,))
const P7 = Val((P7_1,))
const P8 = Val((P8_1,P8_2,P8_3,P8_4,P8_5,))
const P9 = Val((P9_1,))
const P10 = Val((P10_1,))
# Irreducible secondaries for NBody=5and deg=10
 # : definitions of the types at the beginning of the file
const IS1 = Val((IS1_1,IS1_2,))
const IS2 = Val((IS2_1,IS2_2,IS2_3,))
const IS3 = Val((IS3_1,IS3_2,))
const IS4 = Val((IS4_1,IS4_2,))
const IS5 = Val((IS5_1,IS5_2,IS5_3,))
const IS6 = Val((IS6_1,IS6_2,IS6_3,))
const IS7 = Val((IS7_1,IS7_2,IS7_3,))
const IS8 = Val((IS8_1,IS8_2,))
const IS9 = Val((IS9_1,IS9_2,))
const IS10 = Val((IS10_1,IS10_2,IS10_3,))
const IS11 = Val((IS11_1,IS11_2,IS11_3,))
const IS12 = Val((IS12_1,IS12_2,IS12_3,))
const IS13 = Val((IS13_1,IS13_2,IS13_3,))
const IS14 = Val((IS14_1,IS14_2,IS14_3,))
const IS15 = Val((IS15_1,IS15_2,IS15_3,IS15_4,))
const IS16 = Val((IS16_1,IS16_2,))
const IS17 = Val((IS17_1,IS17_2,))
const IS18 = Val((IS18_1,IS18_2,))
const IS19 = Val((IS19_1,IS19_2,IS19_3,))
const IS20 = Val((IS20_1,IS20_2,IS20_3,))
const IS21 = Val((IS21_1,IS21_2,IS21_3,))
const IS22 = Val((IS22_1,IS22_2,IS22_3,))
const IS23 = Val((IS23_1,IS23_2,IS23_3,))
const IS24 = Val((IS24_1,IS24_2,IS24_3,))
const IS25 = Val((IS25_1,IS25_2,IS25_3,IS25_4,))
const IS26 = Val((IS26_1,IS26_2,IS26_3,IS26_4,))
const IS27 = Val((IS27_1,IS27_2,IS27_3,))
const IS28 = Val((IS28_1,))
const IS29 = Val((IS29_1,IS29_2,))
const IS30 = Val((IS30_1,IS30_2,))
const IS31 = Val((IS31_1,IS31_2,))
const IS32 = Val((IS32_1,IS32_2,IS32_3,))
const IS33 = Val((IS33_1,IS33_2,IS33_3,))
const IS34 = Val((IS34_1,IS34_2,IS34_3,))
const IS35 = Val((IS35_1,IS35_2,IS35_3,))
const IS36 = Val((IS36_1,IS36_2,IS36_3,))
const IS37 = Val((IS37_1,IS37_2,IS37_3,))
const IS38 = Val((IS38_1,IS38_2,IS38_3,))
const IS39 = Val((IS39_1,IS39_2,IS39_3,))
const IS40 = Val((IS40_1,IS40_2,IS40_3,IS40_4,))
const IS41 = Val((IS41_1,))
const IS42 = Val((IS42_1,IS42_2,))
const IS43 = Val((IS43_1,IS43_2,))
const IS44 = Val((IS44_1,IS44_2,))
const IS45 = Val((IS45_1,))
const IS46 = Val((IS46_1,IS46_2,))


function invariants_gen(x1::SVector{10, T}) where {T}
   x2 = x1.*x1
   x3 = x2.*x1
   x4 = x3.*x1
   x5 = x4.*x1
   x6 = x5.*x1
   x7 = x6.*x1
   x8 = x7.*x1
   x9 = x8.*x1
   #------------------------------------------------
   # Primaries
   #------------------------------------------------

# Primary invariants for NBody=5and deg=10
 # : what goes in the function for the evaluation
P1 = fpoly((x1,) , Main.P1)
P2 = fpoly((x1,x1,) , Main.P2)
P3 = fpoly((x2,) , Main.P3)
P4 = fpoly((x1,x1,x1,) , Main.P4)
P5 = fpoly((x3,) , Main.P5)
P6 = fpoly((x1,x1,x1,x1,) , Main.P6)
P7 = fpoly((x4,) , Main.P7)
P8 = fpoly((x1,x1,x1,x1,x1,) , Main.P8)
P9 = fpoly((x5,) , Main.P9)
P10 = fpoly((x6,) , Main.P10)



   #------------------------------------------------
   # Irreducible secondaries
   #------------------------------------------------


# Irreducible secondaries for NBody=5and deg=10
 # : what goes in the function for the evaluation
IS1 = fpoly((x2,x1,) , Main.IS1)
IS2 = fpoly((x1,x1,x1,) , Main.IS2)
IS3 = fpoly((x3,x1,) , Main.IS3)
IS4 = fpoly((x2,x2,) , Main.IS4)
IS5 = fpoly((x2,x1,x1,) , Main.IS5)
IS6 = fpoly((x2,x1,x1,) , Main.IS6)
IS7 = fpoly((x2,x1,x1,) , Main.IS7)
IS8 = fpoly((x4,x1,) , Main.IS8)
IS9 = fpoly((x3,x2,) , Main.IS9)
IS10 = fpoly((x3,x1,x1,) , Main.IS10)
IS11 = fpoly((x2,x2,x1,) , Main.IS11)
IS12 = fpoly((x3,x1,x1,) , Main.IS12)
IS13 = fpoly((x2,x2,x1,) , Main.IS13)
IS14 = fpoly((x3,x1,x1,) , Main.IS14)
IS15 = fpoly((x2,x1,x1,x1,) , Main.IS15)
IS16 = fpoly((x5,x1,) , Main.IS16)
IS17 = fpoly((x4,x2,) , Main.IS17)
IS18 = fpoly((x3,x3,) , Main.IS18)
IS19 = fpoly((x4,x1,x1,) , Main.IS19)
IS20 = fpoly((x3,x2,x1,) , Main.IS20)
IS21 = fpoly((x2,x2,x2,) , Main.IS21)
IS22 = fpoly((x4,x1,x1,) , Main.IS22)
IS23 = fpoly((x3,x2,x1,) , Main.IS23)
IS24 = fpoly((x4,x1,x1,) , Main.IS24)
IS25 = fpoly((x3,x1,x1,x1,) , Main.IS25)
IS26 = fpoly((x2,x2,x1,x1,) , Main.IS26)
IS27 = fpoly((x3,x2,x1,) , Main.IS27)
IS28 = fpoly((x7,) , Main.IS28)
IS29 = fpoly((x6,x1,) , Main.IS29)
IS30 = fpoly((x5,x2,) , Main.IS30)
IS31 = fpoly((x4,x3,) , Main.IS31)
IS32 = fpoly((x5,x1,x1,) , Main.IS32)
IS33 = fpoly((x4,x2,x1,) , Main.IS33)
IS34 = fpoly((x3,x3,x1,) , Main.IS34)
IS35 = fpoly((x3,x2,x2,) , Main.IS35)
IS36 = fpoly((x5,x1,x1,) , Main.IS36)
IS37 = fpoly((x4,x2,x1,) , Main.IS37)
IS38 = fpoly((x3,x3,x1,) , Main.IS38)
IS39 = fpoly((x5,x1,x1,) , Main.IS39)
IS40 = fpoly((x4,x1,x1,x1,) , Main.IS40)
IS41 = fpoly((x8,) , Main.IS41)
IS42 = fpoly((x7,x1,) , Main.IS42)
IS43 = fpoly((x6,x2,) , Main.IS43)
IS44 = fpoly((x5,x3,) , Main.IS44)
IS45 = fpoly((x9,) , Main.IS45)
IS46 = fpoly((x8,x1,) , Main.IS46)



   #------------------------------------------------
   # All secondaries
   #------------------------------------------------


 SEC1  = 1
 SEC2  = IS1
 SEC3  = IS2
 SEC4  = IS3
 SEC5  = IS4
 SEC6  = IS5
 SEC7  = IS6
 SEC8  = IS7
 SEC9  = IS8
 SEC10  = IS9
 SEC11  = IS10
 SEC12  = IS11
 SEC13  = IS12
 SEC14  = IS13
 SEC15  = IS14
 SEC16  = IS15
 SEC17  = IS1 *IS1
 SEC18  = IS1 *IS2
 SEC19  = IS2 *IS2
 SEC20  = IS16
 SEC21  = IS17
 SEC22  = IS18
 SEC23  = IS19
 SEC24  = IS20
 SEC25  = IS21
 SEC26  = IS22
 SEC27  = IS23
 SEC28  = IS24
 SEC29  = IS25
 SEC30  = IS26
 SEC31  = IS27
 SEC32  = IS1 *IS3
 SEC33  = IS2 *IS3
 SEC34  = IS1 *IS4
 SEC35  = IS2 *IS4
 SEC36  = IS1 *IS5
 SEC37  = IS2 *IS5
 SEC38  = IS1 *IS6
 SEC39  = IS2 *IS6
 SEC40  = IS1 *IS7
 SEC41  = IS2 *IS7
 SEC42  = IS28
 SEC43  = IS29
 SEC44  = IS30
 SEC45  = IS31
 SEC46  = IS32
 SEC47  = IS33
 SEC48  = IS34
 SEC49  = IS35
 SEC50  = IS36
 SEC51  = IS37
 SEC52  = IS38
 SEC53  = IS39
 SEC54  = IS40
 SEC55  = IS4 *IS4
 SEC56  = IS3 *IS5
 SEC57  = IS4 *IS5
 SEC58  = IS5 *IS5
 SEC59  = IS3 *IS6
 SEC60  = IS4 *IS6
 SEC61  = IS5 *IS6
 SEC62  = IS6 *IS6
 SEC63  = IS3 *IS7
 SEC64  = IS4 *IS7
 SEC65  = IS5 *IS7
 SEC66  = IS6 *IS7
 SEC67  = IS7 *IS7
 SEC68  = IS1 *IS8
 SEC69  = IS2 *IS8
 SEC70  = IS1 *IS9
 SEC71  = IS2 *IS9
 SEC72  = IS1 *IS10
 SEC73  = IS2 *IS10
 SEC74  = IS1 *IS11
 SEC75  = IS2 *IS11
 SEC76  = IS1 *IS12
 SEC77  = IS2 *IS12
 SEC78  = IS1 *IS13
 SEC79  = IS2 *IS13
 SEC80  = IS1 *IS14
 SEC81  = IS2 *IS14
 SEC82  = IS1 *IS15
 SEC83  = IS2 *IS15
 SEC84  = IS41
 SEC85  = IS42
 SEC86  = IS43
 SEC87  = IS44
 SEC88  = IS3 *IS12
 SEC89  = IS4 *IS12
 SEC90  = IS5 *IS12
 SEC91  = IS6 *IS12
 SEC92  = IS7 *IS12
 SEC93  = IS3 *IS13
 SEC94  = IS4 *IS13
 SEC95  = IS5 *IS13
 SEC96  = IS6 *IS13
 SEC97  = IS7 *IS13
 SEC98  = IS3 *IS14
 SEC99  = IS4 *IS14
 SEC100  = IS5 *IS14
 SEC101  = IS6 *IS14
 SEC102  = IS7 *IS14
 SEC103  = IS3 *IS15
 SEC104  = IS4 *IS15
 SEC105  = IS5 *IS15
 SEC106  = IS6 *IS15
 SEC107  = IS7 *IS15
 SEC108  = IS1 *IS16
 SEC109  = IS2 *IS16
 SEC110  = IS1 *IS17
 SEC111  = IS2 *IS17
 SEC112  = IS1 *IS18
 SEC113  = IS2 *IS18
 SEC114  = IS1 *IS19
 SEC115  = IS2 *IS19
 SEC116  = IS1 *IS20
 SEC117  = IS2 *IS20
 SEC118  = IS1 *IS21
 SEC119  = IS2 *IS21
 SEC120  = IS1 *IS22
 SEC121  = IS2 *IS22
 SEC122  = IS1 *IS23
 SEC123  = IS2 *IS23
 SEC124  = IS1 *IS24
 SEC125  = IS2 *IS24
 SEC126  = IS1 *IS25
 SEC127  = IS2 *IS25
 SEC128  = IS1 *IS26
 SEC129  = IS2 *IS26
 SEC130  = IS1 *IS27
 SEC131  = IS2 *IS27
 SEC132  = IS45
 SEC133  = IS46
 SEC134  = IS3 *IS21
 SEC135  = IS4 *IS21
 SEC136  = IS5 *IS21
 SEC137  = IS6 *IS21
 SEC138  = IS7 *IS21
 SEC139  = IS3 *IS22
 SEC140  = IS4 *IS22
 SEC141  = IS5 *IS22
 SEC142  = IS6 *IS22
 SEC143  = IS7 *IS22
 SEC144  = IS3 *IS23
 SEC145  = IS4 *IS23
 SEC146  = IS5 *IS23
 SEC147  = IS6 *IS23
 SEC148  = IS7 *IS23
 SEC149  = IS3 *IS24
 SEC150  = IS4 *IS24
 SEC151  = IS5 *IS24
 SEC152  = IS6 *IS24
 SEC153  = IS7 *IS24
 SEC154  = IS3 *IS25
 SEC155  = IS4 *IS25
 SEC156  = IS5 *IS25
 SEC157  = IS6 *IS25
 SEC158  = IS7 *IS25
 SEC159  = IS3 *IS26
 SEC160  = IS4 *IS26
 SEC161  = IS5 *IS26
 SEC162  = IS6 *IS26
 SEC163  = IS7 *IS26
 SEC164  = IS3 *IS27
 SEC165  = IS4 *IS27
 SEC166  = IS5 *IS27
 SEC167  = IS6 *IS27
 SEC168  = IS7 *IS27
 SEC169  = IS1 *IS28
 SEC170  = IS2 *IS28
 SEC171  = IS1 *IS29
 SEC172  = IS2 *IS29
 SEC173  = IS1 *IS30
 SEC174  = IS2 *IS30
 SEC175  = IS1 *IS31
 SEC176  = IS2 *IS31
 SEC177  = IS1 *IS32
 SEC178  = IS2 *IS32
 SEC179  = IS1 *IS33
 SEC180  = IS2 *IS33
 SEC181  = IS1 *IS34
 SEC182  = IS2 *IS34
 SEC183  = IS1 *IS35
 SEC184  = IS2 *IS35
 SEC185  = IS1 *IS36
 SEC186  = IS2 *IS36
 SEC187  = IS1 *IS37
 SEC188  = IS2 *IS37
 SEC189  = IS1 *IS38
 SEC190  = IS2 *IS38
 SEC191  = IS1 *IS39
 SEC192  = IS2 *IS39
 SEC193  = IS1 *IS40
 SEC194  = IS2 *IS40


return (@SVector [P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,]), (@SVector [SEC1,SEC2,SEC3,SEC4,SEC5,SEC6,SEC7,SEC8,SEC9,SEC10,SEC11,SEC12,SEC13,SEC14,SEC15,SEC16,SEC17,SEC18,SEC19,SEC20,SEC21,SEC22,SEC23,SEC24,SEC25,SEC26,SEC27,SEC28,SEC29,SEC30,SEC31,SEC32,SEC33,SEC34,SEC35,SEC36,SEC37,SEC38,SEC39,SEC40,SEC41,SEC42,SEC43,SEC44,SEC45,SEC46,SEC47,SEC48,SEC49,SEC50,SEC51,SEC52,SEC53,SEC54,SEC55,SEC56,SEC57,SEC58,SEC59,SEC60,SEC61,SEC62,SEC63,SEC64,SEC65,SEC66,SEC67,SEC68,SEC69,SEC70,SEC71,SEC72,SEC73,SEC74,SEC75,SEC76,SEC77,SEC78,SEC79,SEC80,SEC81,SEC82,SEC83,SEC84,SEC85,SEC86,SEC87,SEC88,SEC89,SEC90,SEC91,SEC92,SEC93,SEC94,SEC95,SEC96,SEC97,SEC98,SEC99,SEC100,SEC101,SEC102,SEC103,SEC104,SEC105,SEC106,SEC107,SEC108,SEC109,SEC110,SEC111,SEC112,SEC113,SEC114,SEC115,SEC116,SEC117,SEC118,SEC119,SEC120,SEC121,SEC122,SEC123,SEC124,SEC125,SEC126,SEC127,SEC128,SEC129,SEC130,SEC131,SEC132,SEC133,SEC134,SEC135,SEC136,SEC137,SEC138,SEC139,SEC140,SEC141,SEC142,SEC143,SEC144,SEC145,SEC146,SEC147,SEC148,SEC149,SEC150,SEC151,SEC152,SEC153,SEC154,SEC155,SEC156,SEC157,SEC158,SEC159,SEC160,SEC161,SEC162,SEC163,SEC164,SEC165,SEC166,SEC167,SEC168,SEC169,SEC170,SEC171,SEC172,SEC173,SEC174,SEC175,SEC176,SEC177,SEC178,SEC179,SEC180,SEC181,SEC182,SEC183,SEC184,SEC185,SEC186,SEC187,SEC188,SEC189,SEC190,SEC191,SEC192,SEC193,SEC194,])
 end



function invariants_d_gen(x1::SVector{10, T}) where {T}
   x2 = x1.*x1
   x3 = x2.*x1
   x4 = x3.*x1
   x5 = x4.*x1
   x6 = x5.*x1
   x7 = x6.*x1
   x8 = x7.*x1
   x9 = x8.*x1

   dx1 = @SVector ones(10)
   dx2 = 2 * x1
   dx3 = 3 * x2
   dx4 = 4 * x3
   dx5 = 5 * x4
   dx6 = 6 * x5
   dx7 = 7 * x6
   dx8 = 8 * x7
   dx9 = 9 * x8
   #------------------------------------------------
   # Primaries
   #------------------------------------------------

# Primary invariants for NBody=5and deg=10
 # : what goes in the function for the derivatives
dP1 = fpoly_d((x1,),(dx1,) , Main.P1)
dP2 = fpoly_d((x1,x1,),(dx1,dx1,) , Main.P2)
dP3 = fpoly_d((x2,),(dx2,) , Main.P3)
dP4 = fpoly_d((x1,x1,x1,),(dx1,dx1,dx1,) , Main.P4)
dP5 = fpoly_d((x3,),(dx3,) , Main.P5)
dP6 = fpoly_d((x1,x1,x1,x1,),(dx1,dx1,dx1,dx1,) , Main.P6)
dP7 = fpoly_d((x4,),(dx4,) , Main.P7)
dP8 = fpoly_d((x1,x1,x1,x1,x1,),(dx1,dx1,dx1,dx1,dx1,) , Main.P8)
dP9 = fpoly_d((x5,),(dx5,) , Main.P9)
dP10 = fpoly_d((x6,),(dx6,) , Main.P10)



   #------------------------------------------------
   # Irreducible secondaries
   #------------------------------------------------


# Irreducible secondaries for NBody=5and deg=10
 # : what goes in the function for the evaluation
IS1 = fpoly((x2,x1,) , Main.IS1)
IS2 = fpoly((x1,x1,x1,) , Main.IS2)
IS3 = fpoly((x3,x1,) , Main.IS3)
IS4 = fpoly((x2,x2,) , Main.IS4)
IS5 = fpoly((x2,x1,x1,) , Main.IS5)
IS6 = fpoly((x2,x1,x1,) , Main.IS6)
IS7 = fpoly((x2,x1,x1,) , Main.IS7)
IS8 = fpoly((x4,x1,) , Main.IS8)
IS9 = fpoly((x3,x2,) , Main.IS9)
IS10 = fpoly((x3,x1,x1,) , Main.IS10)
IS11 = fpoly((x2,x2,x1,) , Main.IS11)
IS12 = fpoly((x3,x1,x1,) , Main.IS12)
IS13 = fpoly((x2,x2,x1,) , Main.IS13)
IS14 = fpoly((x3,x1,x1,) , Main.IS14)
IS15 = fpoly((x2,x1,x1,x1,) , Main.IS15)
IS16 = fpoly((x5,x1,) , Main.IS16)
IS17 = fpoly((x4,x2,) , Main.IS17)
IS18 = fpoly((x3,x3,) , Main.IS18)
IS19 = fpoly((x4,x1,x1,) , Main.IS19)
IS20 = fpoly((x3,x2,x1,) , Main.IS20)
IS21 = fpoly((x2,x2,x2,) , Main.IS21)
IS22 = fpoly((x4,x1,x1,) , Main.IS22)
IS23 = fpoly((x3,x2,x1,) , Main.IS23)
IS24 = fpoly((x4,x1,x1,) , Main.IS24)
IS25 = fpoly((x3,x1,x1,x1,) , Main.IS25)
IS26 = fpoly((x2,x2,x1,x1,) , Main.IS26)
IS27 = fpoly((x3,x2,x1,) , Main.IS27)
IS28 = fpoly((x7,) , Main.IS28)
IS29 = fpoly((x6,x1,) , Main.IS29)
IS30 = fpoly((x5,x2,) , Main.IS30)
IS31 = fpoly((x4,x3,) , Main.IS31)
IS32 = fpoly((x5,x1,x1,) , Main.IS32)
IS33 = fpoly((x4,x2,x1,) , Main.IS33)
IS34 = fpoly((x3,x3,x1,) , Main.IS34)
IS35 = fpoly((x3,x2,x2,) , Main.IS35)
IS36 = fpoly((x5,x1,x1,) , Main.IS36)
IS37 = fpoly((x4,x2,x1,) , Main.IS37)
IS38 = fpoly((x3,x3,x1,) , Main.IS38)
IS39 = fpoly((x5,x1,x1,) , Main.IS39)
IS40 = fpoly((x4,x1,x1,x1,) , Main.IS40)
IS41 = fpoly((x8,) , Main.IS41)
IS42 = fpoly((x7,x1,) , Main.IS42)
IS43 = fpoly((x6,x2,) , Main.IS43)
IS44 = fpoly((x5,x3,) , Main.IS44)
IS45 = fpoly((x9,) , Main.IS45)
IS46 = fpoly((x8,x1,) , Main.IS46)


# Irreducible secondaries for NBody=5and deg=10
 # : what goes in the function for the derivatives
dIS1 = fpoly_d((x2,x1,),(dx2,dx1,) , Main.IS1)
dIS2 = fpoly_d((x1,x1,x1,),(dx1,dx1,dx1,) , Main.IS2)
dIS3 = fpoly_d((x3,x1,),(dx3,dx1,) , Main.IS3)
dIS4 = fpoly_d((x2,x2,),(dx2,dx2,) , Main.IS4)
dIS5 = fpoly_d((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS5)
dIS6 = fpoly_d((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS6)
dIS7 = fpoly_d((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS7)
dIS8 = fpoly_d((x4,x1,),(dx4,dx1,) , Main.IS8)
dIS9 = fpoly_d((x3,x2,),(dx3,dx2,) , Main.IS9)
dIS10 = fpoly_d((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS10)
dIS11 = fpoly_d((x2,x2,x1,),(dx2,dx2,dx1,) , Main.IS11)
dIS12 = fpoly_d((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS12)
dIS13 = fpoly_d((x2,x2,x1,),(dx2,dx2,dx1,) , Main.IS13)
dIS14 = fpoly_d((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS14)
dIS15 = fpoly_d((x2,x1,x1,x1,),(dx2,dx1,dx1,dx1,) , Main.IS15)
dIS16 = fpoly_d((x5,x1,),(dx5,dx1,) , Main.IS16)
dIS17 = fpoly_d((x4,x2,),(dx4,dx2,) , Main.IS17)
dIS18 = fpoly_d((x3,x3,),(dx3,dx3,) , Main.IS18)
dIS19 = fpoly_d((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS19)
dIS20 = fpoly_d((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS20)
dIS21 = fpoly_d((x2,x2,x2,),(dx2,dx2,dx2,) , Main.IS21)
dIS22 = fpoly_d((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS22)
dIS23 = fpoly_d((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS23)
dIS24 = fpoly_d((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS24)
dIS25 = fpoly_d((x3,x1,x1,x1,),(dx3,dx1,dx1,dx1,) , Main.IS25)
dIS26 = fpoly_d((x2,x2,x1,x1,),(dx2,dx2,dx1,dx1,) , Main.IS26)
dIS27 = fpoly_d((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS27)
dIS28 = fpoly_d((x7,),(dx7,) , Main.IS28)
dIS29 = fpoly_d((x6,x1,),(dx6,dx1,) , Main.IS29)
dIS30 = fpoly_d((x5,x2,),(dx5,dx2,) , Main.IS30)
dIS31 = fpoly_d((x4,x3,),(dx4,dx3,) , Main.IS31)
dIS32 = fpoly_d((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS32)
dIS33 = fpoly_d((x4,x2,x1,),(dx4,dx2,dx1,) , Main.IS33)
dIS34 = fpoly_d((x3,x3,x1,),(dx3,dx3,dx1,) , Main.IS34)
dIS35 = fpoly_d((x3,x2,x2,),(dx3,dx2,dx2,) , Main.IS35)
dIS36 = fpoly_d((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS36)
dIS37 = fpoly_d((x4,x2,x1,),(dx4,dx2,dx1,) , Main.IS37)
dIS38 = fpoly_d((x3,x3,x1,),(dx3,dx3,dx1,) , Main.IS38)
dIS39 = fpoly_d((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS39)
dIS40 = fpoly_d((x4,x1,x1,x1,),(dx4,dx1,dx1,dx1,) , Main.IS40)
dIS41 = fpoly_d((x8,),(dx8,) , Main.IS41)
dIS42 = fpoly_d((x7,x1,),(dx7,dx1,) , Main.IS42)
dIS43 = fpoly_d((x6,x2,),(dx6,dx2,) , Main.IS43)
dIS44 = fpoly_d((x5,x3,),(dx5,dx3,) , Main.IS44)
dIS45 = fpoly_d((x9,),(dx9,) , Main.IS45)
dIS46 = fpoly_d((x8,x1,),(dx8,dx1,) , Main.IS46)



   #------------------------------------------------
   # All secondaries
   #------------------------------------------------


 dSEC1   = @SVector zeros(10)
 dSEC2  = dIS1
 dSEC3  = dIS2
 dSEC4  = dIS3
 dSEC5  = dIS4
 dSEC6  = dIS5
 dSEC7  = dIS6
 dSEC8  = dIS7
 dSEC9  = dIS8
 dSEC10  = dIS9
 dSEC11  = dIS10
 dSEC12  = dIS11
 dSEC13  = dIS12
 dSEC14  = dIS13
 dSEC15  = dIS14
 dSEC16  = dIS15
 dSEC17   =  dIS1 *IS1 + IS1 *dIS1
 dSEC18   =  dIS1 *IS2 + IS1 *dIS2
 dSEC19   =  dIS2 *IS2 + IS2 *dIS2
 dSEC20  = dIS16
 dSEC21  = dIS17
 dSEC22  = dIS18
 dSEC23  = dIS19
 dSEC24  = dIS20
 dSEC25  = dIS21
 dSEC26  = dIS22
 dSEC27  = dIS23
 dSEC28  = dIS24
 dSEC29  = dIS25
 dSEC30  = dIS26
 dSEC31  = dIS27
 dSEC32   =  dIS1 *IS3 + IS1 *dIS3
 dSEC33   =  dIS2 *IS3 + IS2 *dIS3
 dSEC34   =  dIS1 *IS4 + IS1 *dIS4
 dSEC35   =  dIS2 *IS4 + IS2 *dIS4
 dSEC36   =  dIS1 *IS5 + IS1 *dIS5
 dSEC37   =  dIS2 *IS5 + IS2 *dIS5
 dSEC38   =  dIS1 *IS6 + IS1 *dIS6
 dSEC39   =  dIS2 *IS6 + IS2 *dIS6
 dSEC40   =  dIS1 *IS7 + IS1 *dIS7
 dSEC41   =  dIS2 *IS7 + IS2 *dIS7
 dSEC42  = dIS28
 dSEC43  = dIS29
 dSEC44  = dIS30
 dSEC45  = dIS31
 dSEC46  = dIS32
 dSEC47  = dIS33
 dSEC48  = dIS34
 dSEC49  = dIS35
 dSEC50  = dIS36
 dSEC51  = dIS37
 dSEC52  = dIS38
 dSEC53  = dIS39
 dSEC54  = dIS40
 dSEC55   =  dIS4 *IS4 + IS4 *dIS4
 dSEC56   =  dIS3 *IS5 + IS3 *dIS5
 dSEC57   =  dIS4 *IS5 + IS4 *dIS5
 dSEC58   =  dIS5 *IS5 + IS5 *dIS5
 dSEC59   =  dIS3 *IS6 + IS3 *dIS6
 dSEC60   =  dIS4 *IS6 + IS4 *dIS6
 dSEC61   =  dIS5 *IS6 + IS5 *dIS6
 dSEC62   =  dIS6 *IS6 + IS6 *dIS6
 dSEC63   =  dIS3 *IS7 + IS3 *dIS7
 dSEC64   =  dIS4 *IS7 + IS4 *dIS7
 dSEC65   =  dIS5 *IS7 + IS5 *dIS7
 dSEC66   =  dIS6 *IS7 + IS6 *dIS7
 dSEC67   =  dIS7 *IS7 + IS7 *dIS7
 dSEC68   =  dIS1 *IS8 + IS1 *dIS8
 dSEC69   =  dIS2 *IS8 + IS2 *dIS8
 dSEC70   =  dIS1 *IS9 + IS1 *dIS9
 dSEC71   =  dIS2 *IS9 + IS2 *dIS9
 dSEC72   =  dIS1 *IS10 + IS1 *dIS10
 dSEC73   =  dIS2 *IS10 + IS2 *dIS10
 dSEC74   =  dIS1 *IS11 + IS1 *dIS11
 dSEC75   =  dIS2 *IS11 + IS2 *dIS11
 dSEC76   =  dIS1 *IS12 + IS1 *dIS12
 dSEC77   =  dIS2 *IS12 + IS2 *dIS12
 dSEC78   =  dIS1 *IS13 + IS1 *dIS13
 dSEC79   =  dIS2 *IS13 + IS2 *dIS13
 dSEC80   =  dIS1 *IS14 + IS1 *dIS14
 dSEC81   =  dIS2 *IS14 + IS2 *dIS14
 dSEC82   =  dIS1 *IS15 + IS1 *dIS15
 dSEC83   =  dIS2 *IS15 + IS2 *dIS15
 dSEC84  = dIS41
 dSEC85  = dIS42
 dSEC86  = dIS43
 dSEC87  = dIS44
 dSEC88   =  dIS3 *IS12 + IS3 *dIS12
 dSEC89   =  dIS4 *IS12 + IS4 *dIS12
 dSEC90   =  dIS5 *IS12 + IS5 *dIS12
 dSEC91   =  dIS6 *IS12 + IS6 *dIS12
 dSEC92   =  dIS7 *IS12 + IS7 *dIS12
 dSEC93   =  dIS3 *IS13 + IS3 *dIS13
 dSEC94   =  dIS4 *IS13 + IS4 *dIS13
 dSEC95   =  dIS5 *IS13 + IS5 *dIS13
 dSEC96   =  dIS6 *IS13 + IS6 *dIS13
 dSEC97   =  dIS7 *IS13 + IS7 *dIS13
 dSEC98   =  dIS3 *IS14 + IS3 *dIS14
 dSEC99   =  dIS4 *IS14 + IS4 *dIS14
 dSEC100   =  dIS5 *IS14 + IS5 *dIS14
 dSEC101   =  dIS6 *IS14 + IS6 *dIS14
 dSEC102   =  dIS7 *IS14 + IS7 *dIS14
 dSEC103   =  dIS3 *IS15 + IS3 *dIS15
 dSEC104   =  dIS4 *IS15 + IS4 *dIS15
 dSEC105   =  dIS5 *IS15 + IS5 *dIS15
 dSEC106   =  dIS6 *IS15 + IS6 *dIS15
 dSEC107   =  dIS7 *IS15 + IS7 *dIS15
 dSEC108   =  dIS1 *IS16 + IS1 *dIS16
 dSEC109   =  dIS2 *IS16 + IS2 *dIS16
 dSEC110   =  dIS1 *IS17 + IS1 *dIS17
 dSEC111   =  dIS2 *IS17 + IS2 *dIS17
 dSEC112   =  dIS1 *IS18 + IS1 *dIS18
 dSEC113   =  dIS2 *IS18 + IS2 *dIS18
 dSEC114   =  dIS1 *IS19 + IS1 *dIS19
 dSEC115   =  dIS2 *IS19 + IS2 *dIS19
 dSEC116   =  dIS1 *IS20 + IS1 *dIS20
 dSEC117   =  dIS2 *IS20 + IS2 *dIS20
 dSEC118   =  dIS1 *IS21 + IS1 *dIS21
 dSEC119   =  dIS2 *IS21 + IS2 *dIS21
 dSEC120   =  dIS1 *IS22 + IS1 *dIS22
 dSEC121   =  dIS2 *IS22 + IS2 *dIS22
 dSEC122   =  dIS1 *IS23 + IS1 *dIS23
 dSEC123   =  dIS2 *IS23 + IS2 *dIS23
 dSEC124   =  dIS1 *IS24 + IS1 *dIS24
 dSEC125   =  dIS2 *IS24 + IS2 *dIS24
 dSEC126   =  dIS1 *IS25 + IS1 *dIS25
 dSEC127   =  dIS2 *IS25 + IS2 *dIS25
 dSEC128   =  dIS1 *IS26 + IS1 *dIS26
 dSEC129   =  dIS2 *IS26 + IS2 *dIS26
 dSEC130   =  dIS1 *IS27 + IS1 *dIS27
 dSEC131   =  dIS2 *IS27 + IS2 *dIS27
 dSEC132  = dIS45
 dSEC133  = dIS46
 dSEC134   =  dIS3 *IS21 + IS3 *dIS21
 dSEC135   =  dIS4 *IS21 + IS4 *dIS21
 dSEC136   =  dIS5 *IS21 + IS5 *dIS21
 dSEC137   =  dIS6 *IS21 + IS6 *dIS21
 dSEC138   =  dIS7 *IS21 + IS7 *dIS21
 dSEC139   =  dIS3 *IS22 + IS3 *dIS22
 dSEC140   =  dIS4 *IS22 + IS4 *dIS22
 dSEC141   =  dIS5 *IS22 + IS5 *dIS22
 dSEC142   =  dIS6 *IS22 + IS6 *dIS22
 dSEC143   =  dIS7 *IS22 + IS7 *dIS22
 dSEC144   =  dIS3 *IS23 + IS3 *dIS23
 dSEC145   =  dIS4 *IS23 + IS4 *dIS23
 dSEC146   =  dIS5 *IS23 + IS5 *dIS23
 dSEC147   =  dIS6 *IS23 + IS6 *dIS23
 dSEC148   =  dIS7 *IS23 + IS7 *dIS23
 dSEC149   =  dIS3 *IS24 + IS3 *dIS24
 dSEC150   =  dIS4 *IS24 + IS4 *dIS24
 dSEC151   =  dIS5 *IS24 + IS5 *dIS24
 dSEC152   =  dIS6 *IS24 + IS6 *dIS24
 dSEC153   =  dIS7 *IS24 + IS7 *dIS24
 dSEC154   =  dIS3 *IS25 + IS3 *dIS25
 dSEC155   =  dIS4 *IS25 + IS4 *dIS25
 dSEC156   =  dIS5 *IS25 + IS5 *dIS25
 dSEC157   =  dIS6 *IS25 + IS6 *dIS25
 dSEC158   =  dIS7 *IS25 + IS7 *dIS25
 dSEC159   =  dIS3 *IS26 + IS3 *dIS26
 dSEC160   =  dIS4 *IS26 + IS4 *dIS26
 dSEC161   =  dIS5 *IS26 + IS5 *dIS26
 dSEC162   =  dIS6 *IS26 + IS6 *dIS26
 dSEC163   =  dIS7 *IS26 + IS7 *dIS26
 dSEC164   =  dIS3 *IS27 + IS3 *dIS27
 dSEC165   =  dIS4 *IS27 + IS4 *dIS27
 dSEC166   =  dIS5 *IS27 + IS5 *dIS27
 dSEC167   =  dIS6 *IS27 + IS6 *dIS27
 dSEC168   =  dIS7 *IS27 + IS7 *dIS27
 dSEC169   =  dIS1 *IS28 + IS1 *dIS28
 dSEC170   =  dIS2 *IS28 + IS2 *dIS28
 dSEC171   =  dIS1 *IS29 + IS1 *dIS29
 dSEC172   =  dIS2 *IS29 + IS2 *dIS29
 dSEC173   =  dIS1 *IS30 + IS1 *dIS30
 dSEC174   =  dIS2 *IS30 + IS2 *dIS30
 dSEC175   =  dIS1 *IS31 + IS1 *dIS31
 dSEC176   =  dIS2 *IS31 + IS2 *dIS31
 dSEC177   =  dIS1 *IS32 + IS1 *dIS32
 dSEC178   =  dIS2 *IS32 + IS2 *dIS32
 dSEC179   =  dIS1 *IS33 + IS1 *dIS33
 dSEC180   =  dIS2 *IS33 + IS2 *dIS33
 dSEC181   =  dIS1 *IS34 + IS1 *dIS34
 dSEC182   =  dIS2 *IS34 + IS2 *dIS34
 dSEC183   =  dIS1 *IS35 + IS1 *dIS35
 dSEC184   =  dIS2 *IS35 + IS2 *dIS35
 dSEC185   =  dIS1 *IS36 + IS1 *dIS36
 dSEC186   =  dIS2 *IS36 + IS2 *dIS36
 dSEC187   =  dIS1 *IS37 + IS1 *dIS37
 dSEC188   =  dIS2 *IS37 + IS2 *dIS37
 dSEC189   =  dIS1 *IS38 + IS1 *dIS38
 dSEC190   =  dIS2 *IS38 + IS2 *dIS38
 dSEC191   =  dIS1 *IS39 + IS1 *dIS39
 dSEC192   =  dIS2 *IS39 + IS2 *dIS39
 dSEC193   =  dIS1 *IS40 + IS1 *dIS40
 dSEC194   =  dIS2 *IS40 + IS2 *dIS40


return (dP1,dP2,dP3,dP4,dP5,dP6,dP7,dP8,dP9,dP10,), (dSEC1,dSEC2,dSEC3,dSEC4,dSEC5,dSEC6,dSEC7,dSEC8,dSEC9,dSEC10,dSEC11,dSEC12,dSEC13,dSEC14,dSEC15,dSEC16,dSEC17,dSEC18,dSEC19,dSEC20,dSEC21,dSEC22,dSEC23,dSEC24,dSEC25,dSEC26,dSEC27,dSEC28,dSEC29,dSEC30,dSEC31,dSEC32,dSEC33,dSEC34,dSEC35,dSEC36,dSEC37,dSEC38,dSEC39,dSEC40,dSEC41,dSEC42,dSEC43,dSEC44,dSEC45,dSEC46,dSEC47,dSEC48,dSEC49,dSEC50,dSEC51,dSEC52,dSEC53,dSEC54,dSEC55,dSEC56,dSEC57,dSEC58,dSEC59,dSEC60,dSEC61,dSEC62,dSEC63,dSEC64,dSEC65,dSEC66,dSEC67,dSEC68,dSEC69,dSEC70,dSEC71,dSEC72,dSEC73,dSEC74,dSEC75,dSEC76,dSEC77,dSEC78,dSEC79,dSEC80,dSEC81,dSEC82,dSEC83,dSEC84,dSEC85,dSEC86,dSEC87,dSEC88,dSEC89,dSEC90,dSEC91,dSEC92,dSEC93,dSEC94,dSEC95,dSEC96,dSEC97,dSEC98,dSEC99,dSEC100,dSEC101,dSEC102,dSEC103,dSEC104,dSEC105,dSEC106,dSEC107,dSEC108,dSEC109,dSEC110,dSEC111,dSEC112,dSEC113,dSEC114,dSEC115,dSEC116,dSEC117,dSEC118,dSEC119,dSEC120,dSEC121,dSEC122,dSEC123,dSEC124,dSEC125,dSEC126,dSEC127,dSEC128,dSEC129,dSEC130,dSEC131,dSEC132,dSEC133,dSEC134,dSEC135,dSEC136,dSEC137,dSEC138,dSEC139,dSEC140,dSEC141,dSEC142,dSEC143,dSEC144,dSEC145,dSEC146,dSEC147,dSEC148,dSEC149,dSEC150,dSEC151,dSEC152,dSEC153,dSEC154,dSEC155,dSEC156,dSEC157,dSEC158,dSEC159,dSEC160,dSEC161,dSEC162,dSEC163,dSEC164,dSEC165,dSEC166,dSEC167,dSEC168,dSEC169,dSEC170,dSEC171,dSEC172,dSEC173,dSEC174,dSEC175,dSEC176,dSEC177,dSEC178,dSEC179,dSEC180,dSEC181,dSEC182,dSEC183,dSEC184,dSEC185,dSEC186,dSEC187,dSEC188,dSEC189,dSEC190,dSEC191,dSEC192,dSEC193,dSEC194,)
 end



function invariants_ed_gen(x1::SVector{10, T}) where {T}
   x2 = x1.*x1
   x3 = x2.*x1
   x4 = x3.*x1
   x5 = x4.*x1
   x6 = x5.*x1
   x7 = x6.*x1
   x8 = x7.*x1
   x9 = x8.*x1

   dx1 = @SVector ones(10)
   dx2 = 2 * x1
   dx3 = 3 * x2
   dx4 = 4 * x3
   dx5 = 5 * x4
   dx6 = 6 * x5
   dx7 = 7 * x6
   dx8 = 8 * x7
   dx9 = 9 * x8
   #------------------------------------------------
   # Primaries
   #------------------------------------------------

# Primary invariants for NBody=5and deg=10
 # : what goes in the function for the evaluation and derivatives
P1, dP1 = fpoly_ed((x1,),(dx1,) , Main.P1)
P2, dP2 = fpoly_ed((x1,x1,),(dx1,dx1,) , Main.P2)
P3, dP3 = fpoly_ed((x2,),(dx2,) , Main.P3)
P4, dP4 = fpoly_ed((x1,x1,x1,),(dx1,dx1,dx1,) , Main.P4)
P5, dP5 = fpoly_ed((x3,),(dx3,) , Main.P5)
P6, dP6 = fpoly_ed((x1,x1,x1,x1,),(dx1,dx1,dx1,dx1,) , Main.P6)
P7, dP7 = fpoly_ed((x4,),(dx4,) , Main.P7)
P8, dP8 = fpoly_ed((x1,x1,x1,x1,x1,),(dx1,dx1,dx1,dx1,dx1,) , Main.P8)
P9, dP9 = fpoly_ed((x5,),(dx5,) , Main.P9)
P10, dP10 = fpoly_ed((x6,),(dx6,) , Main.P10)



   #------------------------------------------------
   # Irreducible secondaries
   #------------------------------------------------


# Irreducible secondaries for NBody=5and deg=10
 # : what goes in the function for the evaluation and derivatives
IS1, dIS1 = fpoly_ed((x2,x1,),(dx2,dx1,) , Main.IS1)
IS2, dIS2 = fpoly_ed((x1,x1,x1,),(dx1,dx1,dx1,) , Main.IS2)
IS3, dIS3 = fpoly_ed((x3,x1,),(dx3,dx1,) , Main.IS3)
IS4, dIS4 = fpoly_ed((x2,x2,),(dx2,dx2,) , Main.IS4)
IS5, dIS5 = fpoly_ed((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS5)
IS6, dIS6 = fpoly_ed((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS6)
IS7, dIS7 = fpoly_ed((x2,x1,x1,),(dx2,dx1,dx1,) , Main.IS7)
IS8, dIS8 = fpoly_ed((x4,x1,),(dx4,dx1,) , Main.IS8)
IS9, dIS9 = fpoly_ed((x3,x2,),(dx3,dx2,) , Main.IS9)
IS10, dIS10 = fpoly_ed((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS10)
IS11, dIS11 = fpoly_ed((x2,x2,x1,),(dx2,dx2,dx1,) , Main.IS11)
IS12, dIS12 = fpoly_ed((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS12)
IS13, dIS13 = fpoly_ed((x2,x2,x1,),(dx2,dx2,dx1,) , Main.IS13)
IS14, dIS14 = fpoly_ed((x3,x1,x1,),(dx3,dx1,dx1,) , Main.IS14)
IS15, dIS15 = fpoly_ed((x2,x1,x1,x1,),(dx2,dx1,dx1,dx1,) , Main.IS15)
IS16, dIS16 = fpoly_ed((x5,x1,),(dx5,dx1,) , Main.IS16)
IS17, dIS17 = fpoly_ed((x4,x2,),(dx4,dx2,) , Main.IS17)
IS18, dIS18 = fpoly_ed((x3,x3,),(dx3,dx3,) , Main.IS18)
IS19, dIS19 = fpoly_ed((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS19)
IS20, dIS20 = fpoly_ed((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS20)
IS21, dIS21 = fpoly_ed((x2,x2,x2,),(dx2,dx2,dx2,) , Main.IS21)
IS22, dIS22 = fpoly_ed((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS22)
IS23, dIS23 = fpoly_ed((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS23)
IS24, dIS24 = fpoly_ed((x4,x1,x1,),(dx4,dx1,dx1,) , Main.IS24)
IS25, dIS25 = fpoly_ed((x3,x1,x1,x1,),(dx3,dx1,dx1,dx1,) , Main.IS25)
IS26, dIS26 = fpoly_ed((x2,x2,x1,x1,),(dx2,dx2,dx1,dx1,) , Main.IS26)
IS27, dIS27 = fpoly_ed((x3,x2,x1,),(dx3,dx2,dx1,) , Main.IS27)
IS28, dIS28 = fpoly_ed((x7,),(dx7,) , Main.IS28)
IS29, dIS29 = fpoly_ed((x6,x1,),(dx6,dx1,) , Main.IS29)
IS30, dIS30 = fpoly_ed((x5,x2,),(dx5,dx2,) , Main.IS30)
IS31, dIS31 = fpoly_ed((x4,x3,),(dx4,dx3,) , Main.IS31)
IS32, dIS32 = fpoly_ed((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS32)
IS33, dIS33 = fpoly_ed((x4,x2,x1,),(dx4,dx2,dx1,) , Main.IS33)
IS34, dIS34 = fpoly_ed((x3,x3,x1,),(dx3,dx3,dx1,) , Main.IS34)
IS35, dIS35 = fpoly_ed((x3,x2,x2,),(dx3,dx2,dx2,) , Main.IS35)
IS36, dIS36 = fpoly_ed((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS36)
IS37, dIS37 = fpoly_ed((x4,x2,x1,),(dx4,dx2,dx1,) , Main.IS37)
IS38, dIS38 = fpoly_ed((x3,x3,x1,),(dx3,dx3,dx1,) , Main.IS38)
IS39, dIS39 = fpoly_ed((x5,x1,x1,),(dx5,dx1,dx1,) , Main.IS39)
IS40, dIS40 = fpoly_ed((x4,x1,x1,x1,),(dx4,dx1,dx1,dx1,) , Main.IS40)
IS41, dIS41 = fpoly_ed((x8,),(dx8,) , Main.IS41)
IS42, dIS42 = fpoly_ed((x7,x1,),(dx7,dx1,) , Main.IS42)
IS43, dIS43 = fpoly_ed((x6,x2,),(dx6,dx2,) , Main.IS43)
IS44, dIS44 = fpoly_ed((x5,x3,),(dx5,dx3,) , Main.IS44)
IS45, dIS45 = fpoly_ed((x9,),(dx9,) , Main.IS45)
IS46, dIS46 = fpoly_ed((x8,x1,),(dx8,dx1,) , Main.IS46)



   #------------------------------------------------
   # All secondaries
   #------------------------------------------------


 SEC1  = 1
 SEC2  = IS1
 SEC3  = IS2
 SEC4  = IS3
 SEC5  = IS4
 SEC6  = IS5
 SEC7  = IS6
 SEC8  = IS7
 SEC9  = IS8
 SEC10  = IS9
 SEC11  = IS10
 SEC12  = IS11
 SEC13  = IS12
 SEC14  = IS13
 SEC15  = IS14
 SEC16  = IS15
 SEC17  = IS1 *IS1
 SEC18  = IS1 *IS2
 SEC19  = IS2 *IS2
 SEC20  = IS16
 SEC21  = IS17
 SEC22  = IS18
 SEC23  = IS19
 SEC24  = IS20
 SEC25  = IS21
 SEC26  = IS22
 SEC27  = IS23
 SEC28  = IS24
 SEC29  = IS25
 SEC30  = IS26
 SEC31  = IS27
 SEC32  = IS1 *IS3
 SEC33  = IS2 *IS3
 SEC34  = IS1 *IS4
 SEC35  = IS2 *IS4
 SEC36  = IS1 *IS5
 SEC37  = IS2 *IS5
 SEC38  = IS1 *IS6
 SEC39  = IS2 *IS6
 SEC40  = IS1 *IS7
 SEC41  = IS2 *IS7
 SEC42  = IS28
 SEC43  = IS29
 SEC44  = IS30
 SEC45  = IS31
 SEC46  = IS32
 SEC47  = IS33
 SEC48  = IS34
 SEC49  = IS35
 SEC50  = IS36
 SEC51  = IS37
 SEC52  = IS38
 SEC53  = IS39
 SEC54  = IS40
 SEC55  = IS4 *IS4
 SEC56  = IS3 *IS5
 SEC57  = IS4 *IS5
 SEC58  = IS5 *IS5
 SEC59  = IS3 *IS6
 SEC60  = IS4 *IS6
 SEC61  = IS5 *IS6
 SEC62  = IS6 *IS6
 SEC63  = IS3 *IS7
 SEC64  = IS4 *IS7
 SEC65  = IS5 *IS7
 SEC66  = IS6 *IS7
 SEC67  = IS7 *IS7
 SEC68  = IS1 *IS8
 SEC69  = IS2 *IS8
 SEC70  = IS1 *IS9
 SEC71  = IS2 *IS9
 SEC72  = IS1 *IS10
 SEC73  = IS2 *IS10
 SEC74  = IS1 *IS11
 SEC75  = IS2 *IS11
 SEC76  = IS1 *IS12
 SEC77  = IS2 *IS12
 SEC78  = IS1 *IS13
 SEC79  = IS2 *IS13
 SEC80  = IS1 *IS14
 SEC81  = IS2 *IS14
 SEC82  = IS1 *IS15
 SEC83  = IS2 *IS15
 SEC84  = IS41
 SEC85  = IS42
 SEC86  = IS43
 SEC87  = IS44
 SEC88  = IS3 *IS12
 SEC89  = IS4 *IS12
 SEC90  = IS5 *IS12
 SEC91  = IS6 *IS12
 SEC92  = IS7 *IS12
 SEC93  = IS3 *IS13
 SEC94  = IS4 *IS13
 SEC95  = IS5 *IS13
 SEC96  = IS6 *IS13
 SEC97  = IS7 *IS13
 SEC98  = IS3 *IS14
 SEC99  = IS4 *IS14
 SEC100  = IS5 *IS14
 SEC101  = IS6 *IS14
 SEC102  = IS7 *IS14
 SEC103  = IS3 *IS15
 SEC104  = IS4 *IS15
 SEC105  = IS5 *IS15
 SEC106  = IS6 *IS15
 SEC107  = IS7 *IS15
 SEC108  = IS1 *IS16
 SEC109  = IS2 *IS16
 SEC110  = IS1 *IS17
 SEC111  = IS2 *IS17
 SEC112  = IS1 *IS18
 SEC113  = IS2 *IS18
 SEC114  = IS1 *IS19
 SEC115  = IS2 *IS19
 SEC116  = IS1 *IS20
 SEC117  = IS2 *IS20
 SEC118  = IS1 *IS21
 SEC119  = IS2 *IS21
 SEC120  = IS1 *IS22
 SEC121  = IS2 *IS22
 SEC122  = IS1 *IS23
 SEC123  = IS2 *IS23
 SEC124  = IS1 *IS24
 SEC125  = IS2 *IS24
 SEC126  = IS1 *IS25
 SEC127  = IS2 *IS25
 SEC128  = IS1 *IS26
 SEC129  = IS2 *IS26
 SEC130  = IS1 *IS27
 SEC131  = IS2 *IS27
 SEC132  = IS45
 SEC133  = IS46
 SEC134  = IS3 *IS21
 SEC135  = IS4 *IS21
 SEC136  = IS5 *IS21
 SEC137  = IS6 *IS21
 SEC138  = IS7 *IS21
 SEC139  = IS3 *IS22
 SEC140  = IS4 *IS22
 SEC141  = IS5 *IS22
 SEC142  = IS6 *IS22
 SEC143  = IS7 *IS22
 SEC144  = IS3 *IS23
 SEC145  = IS4 *IS23
 SEC146  = IS5 *IS23
 SEC147  = IS6 *IS23
 SEC148  = IS7 *IS23
 SEC149  = IS3 *IS24
 SEC150  = IS4 *IS24
 SEC151  = IS5 *IS24
 SEC152  = IS6 *IS24
 SEC153  = IS7 *IS24
 SEC154  = IS3 *IS25
 SEC155  = IS4 *IS25
 SEC156  = IS5 *IS25
 SEC157  = IS6 *IS25
 SEC158  = IS7 *IS25
 SEC159  = IS3 *IS26
 SEC160  = IS4 *IS26
 SEC161  = IS5 *IS26
 SEC162  = IS6 *IS26
 SEC163  = IS7 *IS26
 SEC164  = IS3 *IS27
 SEC165  = IS4 *IS27
 SEC166  = IS5 *IS27
 SEC167  = IS6 *IS27
 SEC168  = IS7 *IS27
 SEC169  = IS1 *IS28
 SEC170  = IS2 *IS28
 SEC171  = IS1 *IS29
 SEC172  = IS2 *IS29
 SEC173  = IS1 *IS30
 SEC174  = IS2 *IS30
 SEC175  = IS1 *IS31
 SEC176  = IS2 *IS31
 SEC177  = IS1 *IS32
 SEC178  = IS2 *IS32
 SEC179  = IS1 *IS33
 SEC180  = IS2 *IS33
 SEC181  = IS1 *IS34
 SEC182  = IS2 *IS34
 SEC183  = IS1 *IS35
 SEC184  = IS2 *IS35
 SEC185  = IS1 *IS36
 SEC186  = IS2 *IS36
 SEC187  = IS1 *IS37
 SEC188  = IS2 *IS37
 SEC189  = IS1 *IS38
 SEC190  = IS2 *IS38
 SEC191  = IS1 *IS39
 SEC192  = IS2 *IS39
 SEC193  = IS1 *IS40
 SEC194  = IS2 *IS40


 dSEC1   = @SVector zeros(10)
 dSEC2  = dIS1
 dSEC3  = dIS2
 dSEC4  = dIS3
 dSEC5  = dIS4
 dSEC6  = dIS5
 dSEC7  = dIS6
 dSEC8  = dIS7
 dSEC9  = dIS8
 dSEC10  = dIS9
 dSEC11  = dIS10
 dSEC12  = dIS11
 dSEC13  = dIS12
 dSEC14  = dIS13
 dSEC15  = dIS14
 dSEC16  = dIS15
 dSEC17   =  dIS1 *IS1 + IS1 *dIS1
 dSEC18   =  dIS1 *IS2 + IS1 *dIS2
 dSEC19   =  dIS2 *IS2 + IS2 *dIS2
 dSEC20  = dIS16
 dSEC21  = dIS17
 dSEC22  = dIS18
 dSEC23  = dIS19
 dSEC24  = dIS20
 dSEC25  = dIS21
 dSEC26  = dIS22
 dSEC27  = dIS23
 dSEC28  = dIS24
 dSEC29  = dIS25
 dSEC30  = dIS26
 dSEC31  = dIS27
 dSEC32   =  dIS1 *IS3 + IS1 *dIS3
 dSEC33   =  dIS2 *IS3 + IS2 *dIS3
 dSEC34   =  dIS1 *IS4 + IS1 *dIS4
 dSEC35   =  dIS2 *IS4 + IS2 *dIS4
 dSEC36   =  dIS1 *IS5 + IS1 *dIS5
 dSEC37   =  dIS2 *IS5 + IS2 *dIS5
 dSEC38   =  dIS1 *IS6 + IS1 *dIS6
 dSEC39   =  dIS2 *IS6 + IS2 *dIS6
 dSEC40   =  dIS1 *IS7 + IS1 *dIS7
 dSEC41   =  dIS2 *IS7 + IS2 *dIS7
 dSEC42  = dIS28
 dSEC43  = dIS29
 dSEC44  = dIS30
 dSEC45  = dIS31
 dSEC46  = dIS32
 dSEC47  = dIS33
 dSEC48  = dIS34
 dSEC49  = dIS35
 dSEC50  = dIS36
 dSEC51  = dIS37
 dSEC52  = dIS38
 dSEC53  = dIS39
 dSEC54  = dIS40
 dSEC55   =  dIS4 *IS4 + IS4 *dIS4
 dSEC56   =  dIS3 *IS5 + IS3 *dIS5
 dSEC57   =  dIS4 *IS5 + IS4 *dIS5
 dSEC58   =  dIS5 *IS5 + IS5 *dIS5
 dSEC59   =  dIS3 *IS6 + IS3 *dIS6
 dSEC60   =  dIS4 *IS6 + IS4 *dIS6
 dSEC61   =  dIS5 *IS6 + IS5 *dIS6
 dSEC62   =  dIS6 *IS6 + IS6 *dIS6
 dSEC63   =  dIS3 *IS7 + IS3 *dIS7
 dSEC64   =  dIS4 *IS7 + IS4 *dIS7
 dSEC65   =  dIS5 *IS7 + IS5 *dIS7
 dSEC66   =  dIS6 *IS7 + IS6 *dIS7
 dSEC67   =  dIS7 *IS7 + IS7 *dIS7
 dSEC68   =  dIS1 *IS8 + IS1 *dIS8
 dSEC69   =  dIS2 *IS8 + IS2 *dIS8
 dSEC70   =  dIS1 *IS9 + IS1 *dIS9
 dSEC71   =  dIS2 *IS9 + IS2 *dIS9
 dSEC72   =  dIS1 *IS10 + IS1 *dIS10
 dSEC73   =  dIS2 *IS10 + IS2 *dIS10
 dSEC74   =  dIS1 *IS11 + IS1 *dIS11
 dSEC75   =  dIS2 *IS11 + IS2 *dIS11
 dSEC76   =  dIS1 *IS12 + IS1 *dIS12
 dSEC77   =  dIS2 *IS12 + IS2 *dIS12
 dSEC78   =  dIS1 *IS13 + IS1 *dIS13
 dSEC79   =  dIS2 *IS13 + IS2 *dIS13
 dSEC80   =  dIS1 *IS14 + IS1 *dIS14
 dSEC81   =  dIS2 *IS14 + IS2 *dIS14
 dSEC82   =  dIS1 *IS15 + IS1 *dIS15
 dSEC83   =  dIS2 *IS15 + IS2 *dIS15
 dSEC84  = dIS41
 dSEC85  = dIS42
 dSEC86  = dIS43
 dSEC87  = dIS44
 dSEC88   =  dIS3 *IS12 + IS3 *dIS12
 dSEC89   =  dIS4 *IS12 + IS4 *dIS12
 dSEC90   =  dIS5 *IS12 + IS5 *dIS12
 dSEC91   =  dIS6 *IS12 + IS6 *dIS12
 dSEC92   =  dIS7 *IS12 + IS7 *dIS12
 dSEC93   =  dIS3 *IS13 + IS3 *dIS13
 dSEC94   =  dIS4 *IS13 + IS4 *dIS13
 dSEC95   =  dIS5 *IS13 + IS5 *dIS13
 dSEC96   =  dIS6 *IS13 + IS6 *dIS13
 dSEC97   =  dIS7 *IS13 + IS7 *dIS13
 dSEC98   =  dIS3 *IS14 + IS3 *dIS14
 dSEC99   =  dIS4 *IS14 + IS4 *dIS14
 dSEC100   =  dIS5 *IS14 + IS5 *dIS14
 dSEC101   =  dIS6 *IS14 + IS6 *dIS14
 dSEC102   =  dIS7 *IS14 + IS7 *dIS14
 dSEC103   =  dIS3 *IS15 + IS3 *dIS15
 dSEC104   =  dIS4 *IS15 + IS4 *dIS15
 dSEC105   =  dIS5 *IS15 + IS5 *dIS15
 dSEC106   =  dIS6 *IS15 + IS6 *dIS15
 dSEC107   =  dIS7 *IS15 + IS7 *dIS15
 dSEC108   =  dIS1 *IS16 + IS1 *dIS16
 dSEC109   =  dIS2 *IS16 + IS2 *dIS16
 dSEC110   =  dIS1 *IS17 + IS1 *dIS17
 dSEC111   =  dIS2 *IS17 + IS2 *dIS17
 dSEC112   =  dIS1 *IS18 + IS1 *dIS18
 dSEC113   =  dIS2 *IS18 + IS2 *dIS18
 dSEC114   =  dIS1 *IS19 + IS1 *dIS19
 dSEC115   =  dIS2 *IS19 + IS2 *dIS19
 dSEC116   =  dIS1 *IS20 + IS1 *dIS20
 dSEC117   =  dIS2 *IS20 + IS2 *dIS20
 dSEC118   =  dIS1 *IS21 + IS1 *dIS21
 dSEC119   =  dIS2 *IS21 + IS2 *dIS21
 dSEC120   =  dIS1 *IS22 + IS1 *dIS22
 dSEC121   =  dIS2 *IS22 + IS2 *dIS22
 dSEC122   =  dIS1 *IS23 + IS1 *dIS23
 dSEC123   =  dIS2 *IS23 + IS2 *dIS23
 dSEC124   =  dIS1 *IS24 + IS1 *dIS24
 dSEC125   =  dIS2 *IS24 + IS2 *dIS24
 dSEC126   =  dIS1 *IS25 + IS1 *dIS25
 dSEC127   =  dIS2 *IS25 + IS2 *dIS25
 dSEC128   =  dIS1 *IS26 + IS1 *dIS26
 dSEC129   =  dIS2 *IS26 + IS2 *dIS26
 dSEC130   =  dIS1 *IS27 + IS1 *dIS27
 dSEC131   =  dIS2 *IS27 + IS2 *dIS27
 dSEC132  = dIS45
 dSEC133  = dIS46
 dSEC134   =  dIS3 *IS21 + IS3 *dIS21
 dSEC135   =  dIS4 *IS21 + IS4 *dIS21
 dSEC136   =  dIS5 *IS21 + IS5 *dIS21
 dSEC137   =  dIS6 *IS21 + IS6 *dIS21
 dSEC138   =  dIS7 *IS21 + IS7 *dIS21
 dSEC139   =  dIS3 *IS22 + IS3 *dIS22
 dSEC140   =  dIS4 *IS22 + IS4 *dIS22
 dSEC141   =  dIS5 *IS22 + IS5 *dIS22
 dSEC142   =  dIS6 *IS22 + IS6 *dIS22
 dSEC143   =  dIS7 *IS22 + IS7 *dIS22
 dSEC144   =  dIS3 *IS23 + IS3 *dIS23
 dSEC145   =  dIS4 *IS23 + IS4 *dIS23
 dSEC146   =  dIS5 *IS23 + IS5 *dIS23
 dSEC147   =  dIS6 *IS23 + IS6 *dIS23
 dSEC148   =  dIS7 *IS23 + IS7 *dIS23
 dSEC149   =  dIS3 *IS24 + IS3 *dIS24
 dSEC150   =  dIS4 *IS24 + IS4 *dIS24
 dSEC151   =  dIS5 *IS24 + IS5 *dIS24
 dSEC152   =  dIS6 *IS24 + IS6 *dIS24
 dSEC153   =  dIS7 *IS24 + IS7 *dIS24
 dSEC154   =  dIS3 *IS25 + IS3 *dIS25
 dSEC155   =  dIS4 *IS25 + IS4 *dIS25
 dSEC156   =  dIS5 *IS25 + IS5 *dIS25
 dSEC157   =  dIS6 *IS25 + IS6 *dIS25
 dSEC158   =  dIS7 *IS25 + IS7 *dIS25
 dSEC159   =  dIS3 *IS26 + IS3 *dIS26
 dSEC160   =  dIS4 *IS26 + IS4 *dIS26
 dSEC161   =  dIS5 *IS26 + IS5 *dIS26
 dSEC162   =  dIS6 *IS26 + IS6 *dIS26
 dSEC163   =  dIS7 *IS26 + IS7 *dIS26
 dSEC164   =  dIS3 *IS27 + IS3 *dIS27
 dSEC165   =  dIS4 *IS27 + IS4 *dIS27
 dSEC166   =  dIS5 *IS27 + IS5 *dIS27
 dSEC167   =  dIS6 *IS27 + IS6 *dIS27
 dSEC168   =  dIS7 *IS27 + IS7 *dIS27
 dSEC169   =  dIS1 *IS28 + IS1 *dIS28
 dSEC170   =  dIS2 *IS28 + IS2 *dIS28
 dSEC171   =  dIS1 *IS29 + IS1 *dIS29
 dSEC172   =  dIS2 *IS29 + IS2 *dIS29
 dSEC173   =  dIS1 *IS30 + IS1 *dIS30
 dSEC174   =  dIS2 *IS30 + IS2 *dIS30
 dSEC175   =  dIS1 *IS31 + IS1 *dIS31
 dSEC176   =  dIS2 *IS31 + IS2 *dIS31
 dSEC177   =  dIS1 *IS32 + IS1 *dIS32
 dSEC178   =  dIS2 *IS32 + IS2 *dIS32
 dSEC179   =  dIS1 *IS33 + IS1 *dIS33
 dSEC180   =  dIS2 *IS33 + IS2 *dIS33
 dSEC181   =  dIS1 *IS34 + IS1 *dIS34
 dSEC182   =  dIS2 *IS34 + IS2 *dIS34
 dSEC183   =  dIS1 *IS35 + IS1 *dIS35
 dSEC184   =  dIS2 *IS35 + IS2 *dIS35
 dSEC185   =  dIS1 *IS36 + IS1 *dIS36
 dSEC186   =  dIS2 *IS36 + IS2 *dIS36
 dSEC187   =  dIS1 *IS37 + IS1 *dIS37
 dSEC188   =  dIS2 *IS37 + IS2 *dIS37
 dSEC189   =  dIS1 *IS38 + IS1 *dIS38
 dSEC190   =  dIS2 *IS38 + IS2 *dIS38
 dSEC191   =  dIS1 *IS39 + IS1 *dIS39
 dSEC192   =  dIS2 *IS39 + IS2 *dIS39
 dSEC193   =  dIS1 *IS40 + IS1 *dIS40
 dSEC194   =  dIS2 *IS40 + IS2 *dIS40


return (@SVector [P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,]), (@SVector [SEC1,SEC2,SEC3,SEC4,SEC5,SEC6,SEC7,SEC8,SEC9,SEC10,SEC11,SEC12,SEC13,SEC14,SEC15,SEC16,SEC17,SEC18,SEC19,SEC20,SEC21,SEC22,SEC23,SEC24,SEC25,SEC26,SEC27,SEC28,SEC29,SEC30,SEC31,SEC32,SEC33,SEC34,SEC35,SEC36,SEC37,SEC38,SEC39,SEC40,SEC41,SEC42,SEC43,SEC44,SEC45,SEC46,SEC47,SEC48,SEC49,SEC50,SEC51,SEC52,SEC53,SEC54,SEC55,SEC56,SEC57,SEC58,SEC59,SEC60,SEC61,SEC62,SEC63,SEC64,SEC65,SEC66,SEC67,SEC68,SEC69,SEC70,SEC71,SEC72,SEC73,SEC74,SEC75,SEC76,SEC77,SEC78,SEC79,SEC80,SEC81,SEC82,SEC83,SEC84,SEC85,SEC86,SEC87,SEC88,SEC89,SEC90,SEC91,SEC92,SEC93,SEC94,SEC95,SEC96,SEC97,SEC98,SEC99,SEC100,SEC101,SEC102,SEC103,SEC104,SEC105,SEC106,SEC107,SEC108,SEC109,SEC110,SEC111,SEC112,SEC113,SEC114,SEC115,SEC116,SEC117,SEC118,SEC119,SEC120,SEC121,SEC122,SEC123,SEC124,SEC125,SEC126,SEC127,SEC128,SEC129,SEC130,SEC131,SEC132,SEC133,SEC134,SEC135,SEC136,SEC137,SEC138,SEC139,SEC140,SEC141,SEC142,SEC143,SEC144,SEC145,SEC146,SEC147,SEC148,SEC149,SEC150,SEC151,SEC152,SEC153,SEC154,SEC155,SEC156,SEC157,SEC158,SEC159,SEC160,SEC161,SEC162,SEC163,SEC164,SEC165,SEC166,SEC167,SEC168,SEC169,SEC170,SEC171,SEC172,SEC173,SEC174,SEC175,SEC176,SEC177,SEC178,SEC179,SEC180,SEC181,SEC182,SEC183,SEC184,SEC185,SEC186,SEC187,SEC188,SEC189,SEC190,SEC191,SEC192,SEC193,SEC194,]), (@SVector [dP1,dP2,dP3,dP4,dP5,dP6,dP7,dP8,dP9,dP10,]), (@SVector [dSEC1,dSEC2,dSEC3,dSEC4,dSEC5,dSEC6,dSEC7,dSEC8,dSEC9,dSEC10,dSEC11,dSEC12,dSEC13,dSEC14,dSEC15,dSEC16,dSEC17,dSEC18,dSEC19,dSEC20,dSEC21,dSEC22,dSEC23,dSEC24,dSEC25,dSEC26,dSEC27,dSEC28,dSEC29,dSEC30,dSEC31,dSEC32,dSEC33,dSEC34,dSEC35,dSEC36,dSEC37,dSEC38,dSEC39,dSEC40,dSEC41,dSEC42,dSEC43,dSEC44,dSEC45,dSEC46,dSEC47,dSEC48,dSEC49,dSEC50,dSEC51,dSEC52,dSEC53,dSEC54,dSEC55,dSEC56,dSEC57,dSEC58,dSEC59,dSEC60,dSEC61,dSEC62,dSEC63,dSEC64,dSEC65,dSEC66,dSEC67,dSEC68,dSEC69,dSEC70,dSEC71,dSEC72,dSEC73,dSEC74,dSEC75,dSEC76,dSEC77,dSEC78,dSEC79,dSEC80,dSEC81,dSEC82,dSEC83,dSEC84,dSEC85,dSEC86,dSEC87,dSEC88,dSEC89,dSEC90,dSEC91,dSEC92,dSEC93,dSEC94,dSEC95,dSEC96,dSEC97,dSEC98,dSEC99,dSEC100,dSEC101,dSEC102,dSEC103,dSEC104,dSEC105,dSEC106,dSEC107,dSEC108,dSEC109,dSEC110,dSEC111,dSEC112,dSEC113,dSEC114,dSEC115,dSEC116,dSEC117,dSEC118,dSEC119,dSEC120,dSEC121,dSEC122,dSEC123,dSEC124,dSEC125,dSEC126,dSEC127,dSEC128,dSEC129,dSEC130,dSEC131,dSEC132,dSEC133,dSEC134,dSEC135,dSEC136,dSEC137,dSEC138,dSEC139,dSEC140,dSEC141,dSEC142,dSEC143,dSEC144,dSEC145,dSEC146,dSEC147,dSEC148,dSEC149,dSEC150,dSEC151,dSEC152,dSEC153,dSEC154,dSEC155,dSEC156,dSEC157,dSEC158,dSEC159,dSEC160,dSEC161,dSEC162,dSEC163,dSEC164,dSEC165,dSEC166,dSEC167,dSEC168,dSEC169,dSEC170,dSEC171,dSEC172,dSEC173,dSEC174,dSEC175,dSEC176,dSEC177,dSEC178,dSEC179,dSEC180,dSEC181,dSEC182,dSEC183,dSEC184,dSEC185,dSEC186,dSEC187,dSEC188,dSEC189,dSEC190,dSEC191,dSEC192,dSEC193,dSEC194,])
 end

end
