text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

                     @variable(m, -1 <= x[i=1:4] <= 1)

                     @variable(m, -11.08168115564476 <= q <= 12.629895565298366)

                     add_NL_constraint(m, :(softplus(-0.8013086439641905 + -0.577380120181807*softplus(-0.15161094843442724 + 0.3901524114721284*$(x[1]) + -0.7620628362671806*$(x[2]) + 0.5531251925343885*$(x[3]) + 0.8877751701397409*$(x[4])) + -0.9073468716494122*softplus(-0.9517329762307463 + 0.7324043290359472*$(x[1]) + -0.6011940599882695*$(x[2]) + 0.8132214951552479*$(x[3]) + 0.2016959253369457*$(x[4])) + -0.34890000179172853*softplus(0.5700564024677015 + -0.6508434167160906*$(x[1]) + 0.3531203702734036*$(x[2]) + 0.9592602519851474*$(x[3]) + -0.2457804299770685*$(x[4]))) + softplus(-0.6400914085711236 + 0.5999574270201746*softplus(-0.15161094843442724 + 0.3901524114721284*$(x[1]) + -0.7620628362671806*$(x[2]) + 0.5531251925343885*$(x[3]) + 0.8877751701397409*$(x[4])) + -0.3302091884595031*softplus(-0.9517329762307463 + 0.7324043290359472*$(x[1]) + -0.6011940599882695*$(x[2]) + 0.8132214951552479*$(x[3]) + 0.2016959253369457*$(x[4])) + 0.9262651374928534*softplus(0.5700564024677015 + -0.6508434167160906*$(x[1]) + 0.3531203702734036*$(x[2]) + 0.9592602519851474*$(x[3]) + -0.2457804299770685*$(x[4]))) + softplus(0.7171327203675486 + 0.9873737246227612*softplus(-0.15161094843442724 + 0.3901524114721284*$(x[1]) + -0.7620628362671806*$(x[2]) + 0.5531251925343885*$(x[3]) + 0.8877751701397409*$(x[4])) + -0.03055409136192777*softplus(-0.9517329762307463 + 0.7324043290359472*$(x[1]) + -0.6011940599882695*$(x[2]) + 0.8132214951552479*$(x[3]) + 0.2016959253369457*$(x[4])) + 0.20254351925716962*softplus(0.5700564024677015 + -0.6508434167160906*$(x[1]) + 0.3531203702734036*$(x[2]) + 0.9592602519851474*$(x[3]) + -0.2457804299770685*$(x[4]))) - $q <= 0.0))

                     @objective(m, Min, q)

                     return m


text:
const unary_function_list = [:+,:-,:cos,:sin,:tan,:acos,:asin,:atan,:cosh,:sinh,:tanh,:acosh,:asinh,:atanh,:sqrt,:exp,:log,:expm1,:erf,:erfc]
const binary_function_list = [:+,:-,:*,:/,:^,:hypot,:atan2]
const unary_diff = Dict(
    (+) => x -> 1,
    (-) => x -> -1,
    (cos) => x -> -sin(x),
    (sin) => x -> cos(x),
    (tan) => x -> tan(x)^2 + 1,
    (acos) => x -> -1/sqrt(-x^2 + 1),
    (asin) => x -> 1/sqrt(-x^2 + 1),
    (atan) => x -> 1/(x^2 + 1),
    (cosh) => x -> sinh(x),
    (sinh) => x -> cosh(x),
    (tanh) => x -> -tanh(x)^2 + 1,
    (acosh) => x -> 1/sqrt(x^2 - 1),
    (asinh) => x -> 1/sqrt(x^2 + 1),
    (atanh) => x -> 1/(-x^2 + 1),
    (sqrt) => x -> 1/(2*sqrt(x)),
    (exp) => x -> exp(x),
    (log) => x -> 1/x,
    (expm1) => x -> exp(x),
    (erf) => x -> 2*exp(-x^2)/sqrt(pi),
    (erfc) => x -> -2*exp(-x^2)/sqrt(pi))

const binary1_diff = Dict(
    (+) => ( x, y ) -> 1,
    (-) => ( x, y ) -> 1,
    (*) => ( x, y ) -> y,
    (/) => ( x, y ) -> 1/y,
    (^) => ( x, y ) -> x^y*y/x,
    (hypot) => ( x, y ) -> x/sqrt(x^2 + y^2),
    (atan2) => ( x, y ) -> 1/(y*(x^2/y^2 + 1)))

const binary2_diff = Dict(
    (+) => ( x, y ) -> 1,
    (-) => ( x, y ) -> -1,
    (*) => ( x, y ) -> x,
    (/) => ( x, y ) -> -x/y^2,
    (^) => ( x, y ) -> x^y*log(x),
    (hypot) => ( x, y ) -> y/sqrt(x^2 + y^2),
    (atan2) => ( x, y ) -> -x/(y^2*(x^2/y^2 + 1)))

ext: jl

max_stars_repo_name: sabjohnso/AutoDiff

max_issues_repo_name: sabjohnso/AutoDiff

max_forks_repo_name: sabjohnso/AutoDiff


text:
using Flux: Dense

in_channel = 3
out_channel = 5
N = 4
adj = [0. 1. 0. 1.;
       1. 0. 1. 0.;
       0. 1. 0. 1.;
       1. 0. 1. 0.]

@testset "layer" begin
    @testset "GCNConv" begin
        X = rand(in_channel, N)
        @testset "layer with graph" begin
            gc = GCNConv(adj, in_channel=>out_channel)
            @test size(gc.weight) == (out_channel, in_channel)
            @test size(gc.bias) == (out_channel,)
            @test graph(gc.fg) === adj

            Y = gc(X)
            @test size(Y) == (out_channel, N)

            g = Zygote.gradient(() -> sum(gc(X)), params(gc))
            @test length(g.grads) == 2
        end

        @testset "layer without graph" begin
            gc = GCNConv(in_channel=>out_channel)
            @test size(gc.weight) == (out_channel, in_channel)
            @test size(gc.bias) == (out_channel,)
            @test !has_graph(gc.fg)

            fg = FeaturedGraph(adj, X)
            fg_ = gc(fg)
            @test size(node_feature(fg_)) == (out_channel, N)
            @test_throws AssertionError gc(X)

            g = Zygote.gradient(() -> sum(node_feature(gc(fg))), params(gc))
            @test length(g.grads) == 4
        end
    end

    @testset "ChebConv" begin
        k = 6
        X = rand(in_channel, N)
        @testset "layer with graph" begin
            cc = ChebConv(adj, in_channel=>out_channel, k)
            @test size(cc.weight) == (out_channel, in_channel, k)
            @test size(cc.bias) == (out_channel,)
            @test graph(cc.fg) === adj
            @test cc.k == k
            @test cc.in_channel == in_channel
            @test cc.out_channel == out_channel

            Y = cc(X)
            @test size(Y) == (out_channel, N)

            g = Zygote.gradient(() -> sum(cc(X)), params(cc))
            @test length(g.grads) == 3
        end

        @testset "layer without graph" begin
            cc = ChebConv(in_channel=>out_channel, k)
            @test size(cc.weight) == (out_channel, in_channel, k)
            @test size(cc.bias) == (out_channel,)
            @test !has_graph(cc.fg)
            @test cc.k == k
            @test cc.in_channel == in_channel
            @test cc.out_channel == out_channel

            fg = FeaturedGraph(adj, X)
            fg_ = cc(fg)
            @test size(node_feature(fg_)) == (out_channel, N)
            @test_throws AssertionError cc(X)

            g = Zygote.gradient(() -> sum(node_feature(cc(fg))), params(cc))
            @test length(g.grads) == 4
        end
    end

    @testset "GraphConv" begin
        @testset "layer with graph" begin
            gc = GraphConv(adj, in_channel=>out_channel)
            @test graph(gc.fg) == [[2,4], [1,3], [2,4], [1,3]]
            @test size(gc.weight1) == (out_channel, in_channel)
            @test size(gc.weight2) == (out_channel, in_channel)
            @test size(gc.bias) == (out_channel,)

            X = rand(in_channel, N)
            Y = gc(X)
            @test size(Y) == (out_channel, N)

            # Test that the gradient can be computed
            g = Zygote.gradient(() -> sum(gc(X)), params(gc))
            @test length(g.grads) == 5
        end

        @testset "layer without graph" begin
            gc = GraphConv(in_channel=>out_channel)
            @test size(gc.weight1) == (out_channel, in_channel)
            @test size(gc.weight2) == (out_channel, in_channel)
            @test size(gc.bias) == (out_channel,)

            X = rand(in_channel, N)
            fg = FeaturedGraph(adj, X)
            fg_ = gc(fg)
            @test size(node_feature(fg_)) == (out_channel, N)
            @test_throws AssertionError gc(X)

            g = Zygote.gradient(() -> sum(node_feature(gc(fg))), params(gc))
            @test length(g.grads) == 5
        end
    end

    @testset "GATConv" begin
        X = rand(in_channel, N)

        @testset "layer with graph" begin
            @testset "concat=true" begin
                for heads = [1, 6]
                    gat = GATConv(adj, in_channel=>out_channel, heads=heads, concat=true)
                    @test graph(gat.fg) == [[2,4], [1,3], [2,4], [1,3]]
                    @test size(gat.weight) == (out_channel * heads, in_channel)
                    @test size(gat.bias) == (out_channel * heads,)
                    @test size(gat.a) == (2*out_channel, heads, 1)

                    Y = gat(X)
                    @test size(Y) == (out_channel * heads, N)

                    g = Zygote.gradient(() -> sum(gat(X)), params(gat))
                    @test length(g.grads) == 5
                end
            end

            @testset "concat=false" begin
                for heads = [1, 6]
                    gat = GATConv(adj, in_channel=>out_channel, heads=heads, concat=false)
                    @test graph(gat.fg) == [[2,4], [1,3], [2,4], [1,3]]
                    @test size(gat.weight) == (out_channel * heads, in_channel)
                    @test size(gat.bias) == (out_channel * heads,)
                    @test size(gat.a) == (2*out_channel, heads, 1)

                    Y = gat(X)
                    @test size(Y) == (out_channel * heads, 1)

                    g = Zygote.gradient(() -> sum(gat(X)), params(gat))
                    @test length(g.grads) == 5
                end
            end
        end

        @testset "layer without graph" begin
            fg = FeaturedGraph(adj, X)

            @testset "concat=true" begin
                for heads = [1, 6]
                    gat = GATConv(in_channel=>out_channel, heads=heads, concat=true)
                    @test size(gat.weight) == (out_channel * heads, in_channel)
                    @test size(gat.bias) == (out_channel * heads,)
                    @test size(gat.a) == (2*out_channel, heads, 1)

                    fg_ = gat(fg)
                    Y = node_feature(fg_)
                    @test size(Y) == (out_channel * heads, N)
                    @test_throws AssertionError gat(X)

                    g = Zygote.gradient(() -> sum(node_feature(gat(fg))), params(gat))
                    @test length(g.grads) == 5
                end
            end

            @testset "concat=false" begin
                for heads = [1, 6]
                    gat = GATConv(in_channel=>out_channel, heads=heads, concat=false)
                    @test size(gat.weight) == (out_channel * heads, in_channel)
                    @test size(gat.bias) == (out_channel * heads,)
                    @test size(gat.a) == (2*out_channel, heads, 1)

                    fg_ = gat(fg)
                    Y = node_feature(fg_)
                    @test size(Y) == (out_channel * heads, 1)
                    @test_throws AssertionError gat(X)

                    g = Zygote.gradient(() -> sum(node_feature(gat(fg))), params(gat))
                    @test length(g.grads) == 5
                end
            end
        end
    end

    @testset "GatedGraphConv" begin
        num_layers = 3
        @testset "layer with graph" begin
            ggc = GatedGraphConv(adj, out_channel, num_layers)
            @test graph(ggc.fg) == [[2,4], [1,3], [2,4], [1,3]]
            @test size(ggc.weight) == (out_channel, out_channel, num_layers)

            X = rand(in_channel, N)
            Y = ggc(X)
            @test size(Y) == (out_channel, N)

            g = Zygote.gradient(() -> sum(ggc(X)), params(ggc))
            @test length(g.grads) == 13
        end

        @testset "layer without graph" begin
            ggc = GatedGraphConv(out_channel, num_layers)
            @test size(ggc.weight) == (out_channel, out_channel, num_layers)

            X = rand(in_channel, N)
            fg = FeaturedGraph(adj, X)
            fg_ = ggc(fg)
            @test size(node_feature(fg_)) == (out_channel, N)
            @test_throws AssertionError ggc(X)

            g = Zygote.gradient(() -> sum(node_feature(ggc(fg))), params(ggc))
            @test length(g.grads) == 13
        end
    end

    @testset "EdgeConv" begin
        @testset "layer with graph" begin
            ec = EdgeConv(adj, Dense(2*in_channel, out_channel))
            @test graph(ec.fg) == [[2,4], [1,3], [2,4], [1,3]]

            X = rand(in_channel, N)
            Y = ec(X)
            @test size(Y) == (out_channel, N)

            g = Zygote.gradient(() -> sum(ec(X)), params(ec))
            @test length(g.grads) == 4
        end

        @testset "layer without graph" begin
            ec = EdgeConv(Dense(2*in_channel, out_channel))

            X = rand(in_channel, N)
            fg = FeaturedGraph(adj, X)
            fg_ = ec(fg)
            @test size(node_feature(fg_)) == (out_channel, N)
            @test_throws AssertionError ec(X)

            g = Zygote.gradient(() -> sum(node_feature(ec(fg))), params(ec))
            @test length(g.grads) == 4
        end
    end
end


text:
module Multigraphs

export
  Multigraph,
  mEdge,
  mVertex,
  add_vertex!,
  add_edge!,
  remove_edge!,
  in_degree,
  out_degree

include("multigraph_core.jl")

end # module


text:
module PrettyPrint
export pprint, pformat, pprint_impl

function pprint_for_seq(io, left, right, seq :: Union{Vector, Tuple}, indent, newline)
    print(io, left)
    n = length(seq)
    is_empty = n === 0
    if !is_empty
        print(io, '\n')
        print(io, repeat(" ", indent + 2))
        head = seq[1]
        range = 2:n
        pprint(io, head, indent + 2, false)
        print(io, ',')
    else
        range = []
    end
    for i in range
        each = seq[i]
        pprint(io, each, indent + 2, true)
        print(io, ",")
    end
    if !is_empty
        print(io, "\n")
        print(io, repeat(" ", indent))
    end
    print(io, right)
end

"""
The implementation of `pprint` and `pformat`.

You can extend pretty print support via such boilerplate:
```
    function PrettyPrint.pprint_impl(io, data::YourType, indent::Int, newline::Bool)
        print(io, data)
    end
```
"""
function pprint_impl(io, seq::Vector, indent, newline)
    pprint_for_seq(io, '[', ']', seq, indent, newline)
end

function pprint_impl(io, seq::Tuple, indent, newline)
    pprint_for_seq(io, '(', ')', seq, indent, newline)
end

function pprint_impl(io, seq::Set, indent, newline)
    pprint_for_seq(io, '{', '}', collect(seq), indent, newline)
end

function pprint_impl(io, ::Nothing, indent, newline)
    print(io, "nothing")
end

@generated function pprint_impl(io, data, indent, newline)
    head = string(data) * "(\n"
    fields = fieldnames(data)
    if isempty(fields)
        return quote print(io, data) end
    end
    expr_seqs = map(fields) do field
        quote
            print(io, repeat(" ", indent + 2))
            print(io, $(QuoteNode(field)))
            print(io, "=")
            pprint(io, data.$field, indent + 2, false)
            print(io, ",\n")
        end
    end
    quote
        print(io, $head)
        $(expr_seqs...)
        print(io, repeat(" ", indent))
        print(io, ")")
    end
end

"""
pretty print to IO.
"""
function pprint(io, data, indent, newline)
    if newline
        print(io, "\n")
        print(io, repeat(" ", indent))
    end
    pprint_impl(io, data, indent, newline)
end

function pprint(io, data)
    pprint(io, data, 0, false)
end

function pprint(data)
    pprint(stdout, data)
end

"""
return pretty formatted string
"""
function pformat(data)
    io = IOBuffer()
    pprint(io, data)
    String(take!(io))
end

pprint_impl(io, s :: String, indent, newline) = show(io, s)

end # module


text:
## MODEL TRAITS

# model trait names:
const MODEL_TRAITS = [
    :input_scitype, :output_scitype, :target_scitype,
    :is_pure_julia, :package_name, :package_license,
    :load_path, :package_uuid, :package_url,
    :is_wrapper, :supports_weights, :supports_online,
    :docstring, :name, :is_supervised,
    :prediction_type, :implemented_methods, :hyperparameters,
    :hyperparameter_types, :hyperparameter_ranges]

for trait in MODEL_TRAITS
    ex = quote
        $trait(x) = $trait(typeof(x))
    end
    MLJModelInterface.eval(ex)
end

# fallback trait declarations:
input_scitype(::Type)          = Unknown
output_scitype(::Type)         = Unknown
target_scitype(::Type)         = Unknown  # used for measures too
is_pure_julia(::Type)          = false
package_name(::Type)           = "unknown"
package_license(::Type)        = "unknown"
load_path(::Type)              = "unknown"
package_uuid(::Type)           = "unknown"
package_url(::Type)            = "unknown"
is_wrapper(::Type)             = false
supports_online(::Type)        = false
supports_weights(::Type)       = false  # used for measures too
hyperparameter_ranges(T::Type) = Tuple(fill(nothing, length(fieldnames(T))))
docstring(M::Type)             = string(M)
docstring(M::Type{<:MLJType})  = name(M)
docstring(M::Type{<:Model})    = "$(name(M)) from $(package_name(M)).jl.\n" *
                                 "[Documentation]($(package_url(M)))."
# "derived" traits:
name(M::Type)            = string(M)
name(M::Type{<:MLJType}) = split(string(coretype(M)), '.')[end] |> String

is_supervised(::Type)                    = false
is_supervised(::Type{<:Supervised})      = true
prediction_type(::Type)                  = :unknown # used for measures too
prediction_type(::Type{<:Deterministic}) = :deterministic
prediction_type(::Type{<:Probabilistic}) = :probabilistic
prediction_type(::Type{<:Interval})      = :interval
hyperparameters(M::Type)                 = fieldnames(M)
hyperparameter_types(M::Type)            = string.(fieldtypes(M))

# implementation is deferred as it requires methodswith which depends upon
# InteractiveUtils which we don't want to bring here as a dependency
# (even if it's stdlib).
implemented_methods(M::Type) = implemented_methods(get_interface_mode(), M)
implemented_methods(::LightInterface, M) = errlight("implemented_methods")


text:
using Lazy, JSON, MacroTools
export JSString

jsexpr(io, x) = JSON.print(io, x)

type JSString
  s::String
end

jsexpr(x) = JSString(sprint(jsexpr, x))

jsstring(x) = jsexpr(x).s

macro js_str(s)
  :(JSString($(esc(s))))
end

# Expressions

jsexpr(io, x::JSString) = print(io, x.s)
jsexpr(io, x::Symbol) = (x==:nothing ? print(io, "null") : print(io, x))
jsexpr(io, x::QuoteNode) = jsexpr(io, x.value)
jsexpr(io, x::LineNumberNode) = nothing

function jsexpr_joined(io::IO, xs, delim=",")
  isempty(xs) && return
  for i = 1:length(xs)-1
    jsexpr(io, xs[i])
    print(io, delim)
  end
  jsexpr(io, xs[end])
end

jsexpr_joined(xs, delim=",") = sprint(jsexpr_joined, xs, delim)

function block_expr(io, args)
  print(io, "{")
  jsexpr_joined(io, rmlines(args), "; ")
  print(io, "}")
end

function call_expr(io, f, args...)
  f in [:(=), :+, :-, :*, :/, :%] &&
    return print(io, "(", jsexpr_joined(args, string(f)), ")")
  jsexpr(io, f)
  print(io, "(")
  jsexpr_joined(io, args)
  print(io, ")")
end

function ref_expr(io, x, args...)
  jsexpr(io, x)
  print(io, "[")
  jsexpr_joined(io, args)
  print(io, "]")
end

function func_expr(io, args, body)
  named = isexpr(args, :call)
  named || print(io, "(")
  print(io, "function ")
  if named
    print(io, args.args[1])
    args = args.args[2]
  end
  print(io, "(")
  isexpr(args, Symbol) ? print(io, args) : join(io, args.args, ",")
  print(io, ")")
  print(io, "{")
  jsexpr(io, body)
  print(io, "}")
  named || print(io, ")")
end

function dict_expr(io, xs)
  print(io, "{")
  xs = [jsexpr(x).s for x in xs]
  join(io, xs, ",")
  print(io, "}")
end

function if_expr(io, xs)
    if length(xs) >= 2  # we have an if
        print(io, "if (")
        jsexpr(io, xs[1])
        print(io, ") ")
        jsexpr(io, xs[2])
    end

    if length(xs) == 3  # Also have an else
        print(io, "else")
        jsexpr(io, xs[3])
    end
end

function jsexpr(io, x::Expr)
  isexpr(x, :block) && return block_expr(io, rmlines(x).args)
  @match x begin
    d(xs__) => dict_expr(io, xs)
    Dict(xs__) => dict_expr(io, xs)
    # Pairs on 0.5
    $(Expr(:(=>), :_, :_)) => print(io, jsexpr(x.args[1]).s, ":", jsexpr(x.args[2]).s)

    # Pairs on 0.6
    $(Expr(:call, :(=>), :_, :_)) => print(io, jsexpr(x.args[2]).s, ":", jsexpr(x.args[3]).s)
    $(Expr(:comparison, :_, :(==), :_)) => jsexpr_joined(io, [x.args[1], x.args[3]], "==")  # 0.4

    # must include this particular `:call` expr before the catchall below
    $(Expr(:call, :(==), :_, :_)) => jsexpr_joined(io, [x.args[2], x.args[3]], "==")  # 0.5+
    f_(xs__) => call_expr(io, f, xs...)
    (a_ -> b_) => func_expr(io, a, b)
    a_.b_ | a_.(b_) => jsexpr_joined(io, [a, b], ".")
    (a_ = b_) => jsexpr_joined(io, [a, b], "=")
    $(Expr(:if, :__)) => if_expr(io, x.args)
    a_[i__] => ref_expr(io, a, i...)
    (@m_ xs__) => jsexpr(io, macroexpand(Blink, x))
    (c_ ? t_ : f_) => (jsexpr(io, c); print(io, "?"); jsexpr(io, t); print(io, ":"); jsexpr(io, f))
    (return a_) => (print(io, "return "); jsexpr(io, a))
    $(Expr(:function, :__)) => func_expr(io, x.args...)
    $(Expr(:new, :_)) => (print(io, "new "); jsexpr(io, x.args[1]))
    $(Expr(:var, :_)) => (print(io, "var "); jsexpr(io, x.args[1]))
    _ => error("JSExpr: Unsupported `$(x.head)` expression, $x")
  end
end

macro new(x) esc(Expr(:new, x)) end
macro var(x) esc(Expr(:var, x)) end


text:
module JetPack

using FFTW
using Jets
using LinearAlgebra
using SpecialFunctions
using Statistics

include("jop_atan.jl")
include("jop_blend.jl")
include("jop_circshift.jl")
include("jop_derivative.jl")
include("jop_diagonal.jl")
include("jop_difference.jl")
include("jop_erf.jl")
include("jop_exp.jl")
include("jop_gradient.jl")
include("jop_highpass.jl")
include("jop_imag.jl")
include("jop_interp.jl")
include("jop_laplacian.jl")
include("jop_leaky_integration.jl")
include("jop_log.jl")
include("jop_lmo.jl")
include("jop_mix.jl")
include("jop_nim.jl")
include("jop_normalize.jl")
include("jop_pad.jl")
include("jop_permute.jl")
include("jop_permutedims.jl")
include("jop_pow.jl")
include("jop_projection.jl")
include("jop_real.jl")
include("jop_removedc.jl")
include("jop_reghost.jl")
include("jop_reshape.jl")
include("jop_restriction.jl")
include("jop_roughness.jl")
include("jop_shift.jl")
include("jop_sigmoid.jl")
include("jop_taper.jl")
include("jop_tanh.jl")
include("jop_translation.jl")

end


text:
using MinimalRides
using Test

@testset "MinimalRides.jl" begin
    # Write your tests here.
end


text:
"""
    SimulatedABCRejection(
        reference_data,
        simulator_function,
        priors,
        threshold,
        n_particles;
        summary_statistic   = "keep_all",
        distance_function   = Distances.euclidean,
        max_iter            = 10 * n_particles,
        write_progress      = true,
        progress_every      = 1000,
        )

Run simulation-based rejection ABC algorithm. Particles are sampled from the prior, and the model is simulated for
each particle. Only those particles are included in the posterior that have distance between the simulation results
and the reference data below the threshold (after taking summary statistics into account).

See [ABC Overview](@ref abc-overview) for more details.

# Mandatory arguments
- `reference_data::AbstractArray{Float,2}`: Observed data to which the simulated model output will be compared. Array dimensions sould match that of the simulator function result.
- `simulator_function::Function`: A function that takes a parameter vector as an argument and outputs model results.
- `priors::AbstractArray{ContinuousUnivariateDistribution,1}`: Continuous univariate distributions, from which candidate parameters will be sampled. Array size should match the number of parameters.
- `threshold::Float`: The ``\\varepsilon`` threshold to be used in ABC algorithm. Only those particles that produce simulated results that are within this threshold from the reference data are included into the posterior.
- `n_particles::Int`: The number of parameter vectors (particles) that will be included in the posterior.

# Optional keyword arguments
- `summary_statistic::Union{String,AbstractArray{String,1},Function}`: Summary statistics that will be applied to the data before computing the distances. Defaults to `keep_all`. See [detailed documentation of summary statistics](@ref summary_stats).
- `distance_function::Function`: A function that will be used to compute the distance between the summary statistic of the simulated data and that of reference data. Defaults to `Distances.euclidean`.
- `max_iter::Int`: The maximum number of simulations that will be run. The default is `1000 * n_particles`.
- `write_progress::Bool`: Whether algorithm progress should be printed on standard output. Defaults to `true`.
- `progress_every::Int`: Number of iterations at which to print progress. Defaults to 1000.

# Returns
An [`ABCRejectionOutput`](@ref) object.
"""
function SimulatedABCRejection(reference_data::AbstractArray{AF,2},
    simulator_function::Function,
    priors::AbstractArray{D,1},
    threshold::AF,
    n_particles::Int;
    summary_statistic::Union{String,AbstractArray{String,1},Function}="keep_all",
    distance_function::Function=Distances.euclidean,
    max_iter::Int=10 * n_particles,
    kwargs...
    ) where {
    AF<:AbstractFloat,
    D<:ContinuousUnivariateDistribution
    }

    n_params = length(priors)
    summary_statistic = build_summary_statistic(summary_statistic)
    reference_summary_statistic = summary_statistic(reference_data)
    distance_simulation_input = DistanceSimulationInput(reference_summary_statistic, simulator_function, summary_statistic, distance_function)
    input = SimulatedABCRejectionInput(n_params, n_particles, threshold,
                                        priors,
                                        distance_simulation_input,
                                        max_iter)

    return ABCrejection(input; kwargs...)

end

"""
    SimulatedABCSMC(
        reference_data,
        simulator_function,
        priors,
        threshold_schedule,
        n_particles;
        summary_statistic   = "keep_all",
        distance_function   = Distances.euclidean,
        max_iter            = 10 * n_particles,
        write_progress      = true,
        progress_every      = 1000,
        )

Run a simulation-based ABC-SMC algorithm. This is similar to [`SimulatedABCRejection`](@ref),
the main difference being that an array of thresholds is provided instead of a single threshold.
It is assumed that thresholds are sorted in decreasing order.

A simulation based ABC iteration is executed for each threshold. For the first threshold, the provided prior is used.
For each subsequent threshold, the posterior from the previous iteration is used as a prior.

See [ABC Overview](@ref abc-overview) for more details.

# Mandatory arguments
- `reference_data::AbstractArray{Float,2}`: Observed data to which the simulated model output will be compared. Array dimensions sould match that of the simulator function result.
- `simulator_function::Function`: A function that takes a parameter vector as an argument and outputs model results.
- `priors::AbstractArray{ContinuousUnivariateDistribution,1}`: Continuous univariate distributions, from which candidate parameters will be sampled during the first iteration. Array size should match the number of parameters.
- `threshold_schedule::AbstractArray{Float,1}`: The threshold schedule to be used in ABC algorithm. An ABC iteration is executed for each threshold. It is assumed that thresholds are sorted in decreasing order.
- `n_particles::Int`: The number of parameter vectors (particles) that will be included in the posterior.

# Optional keyword arguments
- `summary_statistic::Union{String,AbstractArray{String,1},Function}`: Summary statistics that will be applied to the data before computing the distances. Defaults to `keep_all`. See [detailed documentation of summary statistics](@ref summary_stats).
- `distance_function::Function`: A function that will be used to compute the distance between the summary statistic of the simulated data and that of reference data. Defaults to `Distances.euclidean`.
- `max_iter::Int`: The maximum number of simulations that will be run. The default is `1000 * n_particles`.
- `write_progress::Bool`: Whether algorithm progress should be printed on standard output. Defaults to `true`.
- `progress_every::Int`: Number of iterations at which to print progress. Defaults to 1000.

# Returns
An [`ABCSMCOutput`](@ref) object.
"""
function SimulatedABCSMC(reference_data::AbstractArray{AF,2},
    simulator_function::Function,
    priors::AbstractArray{D,1},
    threshold_schedule::AbstractArray{AF,1},
    n_particles::Int;
    summary_statistic::Union{String,AbstractArray{String,1},Function} = "keep_all",
    distance_function::Function=Distances.euclidean,
    max_iter::Int=10 * n_particles,
    kwargs...
    ) where {
    AF<:AbstractFloat,
    D<:ContinuousUnivariateDistribution
    }

    n_params = length(priors)

    summary_statistic = build_summary_statistic(summary_statistic)
    reference_summary_statistic = summary_statistic(reference_data)
    distance_simulation_input = DistanceSimulationInput(reference_summary_statistic, simulator_function, summary_statistic, distance_function)
    input = SimulatedABCSMCInput(n_params, n_particles, threshold_schedule,
                                    priors, distance_simulation_input,
                                    max_iter)

    return ABCSMC(input; kwargs...)

end

"""
    SimulatedModelSelection

Perform model selection using simulation-based ABC.

# Arguments
- `reference_data::AbstractArray{Float64,2}`: The observed data to which the simulated model output will be compared. Size: (n_model_trajectories, n_time_points)
- `threshold_schedule::AbstractArray{Float64}`: A set of maximum distances from the summarised model output to summarised observed data for a parameter vector to be included in the posterior. Each distance will be used in a single run of the ABC-SMC algorithm.
- `parameter_priors::AbstractArray{AbstractArray{ContinuousUnivariateDistribution},1}`: Priors for the parameters of each model. The length of the outer array is the number of models.
- `summary_statistic::Union{String,AbstractArray{String,1},Function}`: Either: 1. A `String` or 1D Array of strings that Or 2. A function that outputs a 1D Array of Floats that summarises model output. Defaults to `keep_all`. See [detailed documentation of summary statistics](@ref summary_stats).
- `simulator_functions::AbstractArray{Function,1}`: An array of functions that take a parameter vector as an argument and outputs model results (one per model).
- 'model_prior::DiscreteUnivariateDistribution': The prior from which models are sampled. Default is a discrete, uniform distribution.
- `distance_function::Function`: Any function that computes the distance between 2 1D Arrays. Optional argument (default is to use the Euclidean distance).
- `max_iter::Int`: The maximum number of simulations that will be run. The default is 1000*`n_particles`. Each iteration samples a single model and performs ABC using a single particle.

# Returns
A [`ModelSelectionOutput`](@ref) object that contains which models are supported by the observed data.
"""
function SimulatedModelSelection(
    reference_data::AbstractArray{AF,2},
    simulator_functions::AbstractArray{Function,1},
    parameter_priors::AbstractArray{AD,1},
    threshold_schedule::AbstractArray{Float64,1},
    n_particles::Int,
    model_prior::DiscreteUnivariateDistribution=Distributions.DiscreteUniform(1,length(parameter_priors));
    summary_statistic::Union{String,AbstractArray{String,1},Function}="keep_all",
    distance_function::Function=Distances.euclidean,
    max_iter::Int=10000
    ) where {
    AF<:AbstractFloat,
    D<:ContinuousUnivariateDistribution,
    AD<:AbstractArray{D,1}
    }

    summary_statistic = build_summary_statistic(summary_statistic)
    reference_summary_statistic = summary_statistic(reference_data)
    distance_simulation_input = [DistanceSimulationInput(reference_summary_statistic,
        simulator_functions[m], summary_statistic, distance_function) for m in 1:length(parameter_priors)]
    input = SimulatedModelSelectionInput(length(parameter_priors),
        n_particles,
        threshold_schedule,
        model_prior,
        parameter_priors,
        distance_simulation_input,
        max_iter)

    return model_selection(input)
end


text:
using ArgParse
using WindMixing

type = "NDE"

FILE_NAMES = ["NDE_training_mpp_5sim_-1e-3_-9e-4_-8e-4_-7e-4_-5e-4_diffusivity_1e-1_Ri_1e-1_weights_divide1f5_gradient_smallNN_scale_5e-3_rate_1e-4",
              "NDE_training_mpp_5sim_-1e-3_-9e-4_-8e-4_-7e-4_-5e-4_diffusivity_1e-1_Ri_1e-1_weights_divide1f5_gradient_smallNN_scale_5e-3_rate_2e-4",
              "NDE_training_mpp_5sim_-1e-3_-9e-4_-8e-4_-7e-4_-5e-4_diffusivity_1e-1_Ri_1e-1_weights_divide1f5_gradient_smallNN_scale_1e-2_rate_1e-4",
              "NDE_training_mpp_5sim_-1e-3_-9e-4_-8e-4_-7e-4_-5e-4_diffusivity_1e-1_Ri_1e-1_weights_divide1f5_gradient_smallNN_scale_1e-2_rate_2e-4"
              ]

FILE_PATHS = [joinpath(pwd(), "training_output", "$(FILE_NAME).jld2") for FILE_NAME in FILE_NAMES]
OUTPUT_PATHS = [joinpath(pwd(), "extracted_training_output", "$(FILE_NAME)_extracted.jld2") for FILE_NAME in FILE_NAMES]

Threads.@threads for i in 1:length(FILE_NAMES)
    FILE_PATH = FILE_PATHS[i]
    OUTPUT_PATH = OUTPUT_PATHS[i]
    extract_NN(FILE_PATH, OUTPUT_PATH, type)
end


text:
struct HRESULT
    opaque::UInt32
end

issucceeded(x::HRESULT) = x.opaque >> 31 & 0x1 == 0
isfailed(x::HRESULT) = !issucceeded(x)
Base.convert(::Type{UInt32}, x::HRESULT) = x.opaque

function Base.show(io::IO, x::HRESULT)
    write(io, "HRESULT(")
    show(io, x.opaque)
    @static if Sys.iswindows()
        str = errmsg(x)
        if str != nothing
            write(io, " = ")
            show(io, errmsg(x))
        end
    end
    write(io, ")")
    nothing
end

@static if Sys.iswindows()
    function errmsg(hr::HRESULT)
        FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100
        FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
        FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200
        ptrbuf = Ref(Ptr{UInt16}(0))
        ccall(:FormatMessageW, stdcall,
            UInt32, (UInt32, Ptr{Cvoid}, UInt32, UInt32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}),
            FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
            C_NULL, hr, 0, ptrbuf, 0, C_NULL)
        result = nothing
        if ptrbuf[] != C_NULL
            len = ccall(:wcslen, UInt, (Ptr{Cvoid},), ptrbuf[])
            strbuf = Array{UInt16}(undef, len)
            unsafe_copyto!(pointer(strbuf), ptrbuf[], len)
            result = chomp(String(transcode(UInt8, strbuf)))
            ccall(:LocalFree, stdcall, Ptr{Cvoid}, (Ptr{Cvoid},), ptrbuf[])
        end
        return result
    end
end

struct CLRHostError <: Exception
    prefix::AbstractString
    hr::HRESULT
end

function Base.showerror(io::IO, ex::CLRHostError)
    print(io, "CLRHostError: $(ex.prefix): $(ex.hr)")
end

primitive type BStr Sys.WORD_SIZE end

function Base.cconvert(::Type{BStr}, x::AbstractString)
    cunit = transcode(UInt16, x)
    cch = UInt32(length(cunit))
    buf = Vector{UInt16}(undef, cch + 3)
    ptr = Ptr{UInt32}(pointer(buf))
    unsafe_store!(ptr, cch * sizeof(UInt16))
    copyto!(buf, 3, cunit, 1, cch)
    buf[end] = 0
    return buf
end

function Base.unsafe_convert(::Type{BStr}, x::Vector{UInt16})
    return reinterpret(BStr, pointer(x) + sizeof(UInt32))
end

function Base.unsafe_string(bstr::BStr)
    ptr = reinterpret(Ptr{UInt16}, bstr)
    if ptr == C_NULL
        throw(UndefRefError())
    end
    cb = unsafe_load(Ptr{UInt32}(ptr - sizeof(UInt32)))
    buf = Vector{UInt16}(undef, ceil(Int, cb / sizeof(UInt16)))
    unsafe_copyto!(Ptr{UInt8}(pointer(buf)), Ptr{UInt8}(ptr), cb)
    return transcode(String, buf)
end

abstract type CLRHost end

function detect_runtime end

function create_host end

function create_delegate end


text:
#graphs of assets

function formpreliminaryfunds()

  local funds::DataFrame

  #form the data to grph
  funds = readprocessfundsdata()
  series = aggregatefunds(funds)

  PRELIM_STYLE_IDX::Dict = Dict(:textsize => 12.0,
      :linesize => 0.5,
      :shapesize => 0.25,
      #:xdomain => [1926, 2018],
      :width => 400,
      :height => 300,
      :widthscatter => 1600,
      :heightscatter => 1200,
      :xaxisname=>"Year",
      :legendtextsize => 9.0,
      :xaxisscattername=>"10ˣ_assets",
      :pointsize=>8.0,
      #:ydomain => [-1.0,2.0]#,
      #=:seriescolor => :black=#)

  #println(describe(series))
  graphfundassets(series,
    styleidx=PRELIM_STYLE_IDX,
    graphname="fundassets",
    yaxisname = "Assets")

  graphscatterfunds(funds,
    styleidx=PRELIM_STYLE_IDX,
    graphname="scattercash",
    yaxisname = "% cash",
    Fy = :wpercash)

    graphscatterfunds(funds,
      styleidx=PRELIM_STYLE_IDX,
      graphname="scattereq",
      yaxisname = "% eq",
      Fy = :wpercom)

end

function graphfundassets(
  series::AbstractDataFrame;
  outputfolder::String = PARAM[:figurepath],
  styleidx::Dict = error("styleidx is required"),
  Fx=:date,
  Fy=:value,
  Fgroup=:variable,
  graphname::String = error("graph name is required"),
  yaxisname::String = error("y-axis name is required"))

 #  println(series)

  panel = @vlplot() +
    @vlplot( #first part contains the line and circle dots
      data = series,
      width=styleidx[:width],
      height=styleidx[:height],
      title=nothing,
      mark={:line,
        clip=true,
        size=styleidx[:linesize]},
      x={Fx,
        axis={title=styleidx[:xaxisname],
          grid=false,
          titleFontSize=styleidx[:textsize],
          tickCount=11,
          titleFontWeight=:normal,
          labels=true},
        type=:temporal,
        },
      y={Fy,
        axis={title=yaxisname,
            grid=false,
            tickCount=4,
            titleFontSize=styleidx[:textsize],
            titleFontWeight=:normal},
          type=:quantitative,
          scale={type=:log},
        },
      color={Fgroup,
        type=:nominal,
        legend = {
          title=nothing,
          orient="bottom-right"
          }
        }
      )

  save("$outputfolder\\$graphname.pdf", panel)
end

#read in the appropriate file
function readprocessfundsdata(;prelimfundspath::String = "$(PARAM[:preliminarypath])\\$(PARAM[:prelimfunddata])",
  prelimfundretspath::String = "$(PARAM[:preliminarypath])\\$(PARAM[:prelimfundretsdata])")

  local altwords::Vector{String} = PARAM[:prelimaltwords]
  local funds::DataFrame
  local fundrets::DataFrame

  #scrubs the names and dates
  function initialclean(df::DataFrame)
    rename!(df, (cleanname).(names(df)))
    df.date = (i::Int->Date("$i", PARAM[:wrdsdateformat])).(df.caldt)
    df.year = (d->year(d)).(df.date)

    return df
  end

  if PARAM[:refreshpreliminaryfunds]
    #first get the summery data
    funds = CSV.read("$(prelimfundspath).csv") |> DataFrame
    funds = initialclean(funds)
    sort!(funds, [:year, :crspfundno, :date])
    funds.tokeep = trues(size(funds,1))
    #dedup funds

    for sfunds ∈ groupby(funds, [:year, :crspfundno])
      if size(sfunds,1) > 1
        sfunds.tokeep .= false
        sfunds.tokeep[end] = true
      end
    end
    funds = funds[funds.tokeep,:]
    #select!(funds, [:year, :crspfundno, :lipperclassname, :lipperobjname])
    size(unique(funds[!,[:year,:crspfundno]]),1) == size(funds,1) || error(
      "non-unique fund-years found! $(size(unique(funds[!,[:year,:crspfundno]]),1) - size(funds,1))")

    #put an indicator for if the fun is an alt
    funds.alt = falses(size(funds,1))
    funds.lipperclassname .= (s::MString->ismissing(s) ? missing : lowercase(s)).(funds.lipperclassname)
    funds.lipperobjname .= (s::MString->ismissing(s) ? missing : lowercase(s)).(funds.lipperobjname)

    for r ∈ eachrow(funds)
      r.alt = (!ismissing(r.lipperclassname)) && sum((s->occursin(s,r.lipperclassname)).(altwords)) > 0
      r.alt && continue
      r.alt = (!ismissing(r.lipperobjname)) && sum((s->occursin(s,r.lipperobjname)).(altwords)) > 0
    end

    #get the assets data
    fundrets = CSV.read("$(prelimfundretspath).csv") |> DataFrame
    fundrets = initialclean(fundrets)
    #println(describe(fundrets))
    fundrets.assets = (s::MString->
      ismissing(s) ? missing : parseormissing(Float64, s)).(fundrets.mtna)
    fundrets = fundrets[(!ismissing).(fundrets.assets),:]
    fundrets = fundrets[fundrets.assets .> 0,:]
    select!(fundrets, [:year, :assets, :crspfundno])

    #take the average of assets for each fund-year
    aggfunc(v::AbstractVector{<:MFloat64}) = mean(skipmissing(v))
    fundretss = groupby(fundrets, [:year, :crspfundno])
    fundrets = combine(fundretss, valuecols(fundretss) .=> aggfunc)
    rename!(fundrets, (s::String-> s=>nofunction(s, "_aggfunc")).(names(fundrets)))
    fundrets.date = (y->Date(y,12,31)).(fundrets.year)

    #merge the assets with the descriptive data
    rename!(funds, :date=>:rawdate)
    funds = innerjoin(funds, fundrets, on=[:year, :crspfundno])

    #winsorize percentage data
    @inline winper(::Missing, any...) = missing
    @inline winper(per::Real, lo::Real = -100., hi::Real = 100.) = min(hi, max(per, lo))

    funds.l10assets = (log10).(funds.assets .* 1_000_000.)
    funds.wpercash = (winper).(funds.percash)
    funds.wpercom = (x->winper(x,-100,200)).(funds.percom)

    serialize("$(prelimfundspath).jls", funds)
  else
    funds = deserialize("$(prelimfundspath).jls")
  end

    #display(funds[funds.crspfundno .== 25619,:])
  return funds
end

#adds the assets across funds
function aggregatefunds(funds::AbstractDataFrame)

  local series::DataFrame

  aggfunc(v::AbstractVector{<:MFloat64}) = sum(skipmissing(v))
  seriess::GroupedDataFrame = groupby(view(funds, :, [:date, :assets]), :date)
  series = combine(seriess, valuecols(seriess) .=> aggfunc)

  #fix the names
  rename!(series, (s::String-> s=>nofunction(s, "_aggfunc")).(names(series)))
  rename!(series, :assets=>:total_assets)

  #repeat, but this time only for alt funds
  sfunds = view(funds, funds.alt, [:date, :assets, :alt])
  sfundss::GroupedDataFrame = groupby(view(sfunds, :, [:date, :assets]), :date)
  seriesalts = combine(sfundss, valuecols(sfundss) .=> aggfunc)
  rename!(seriesalts, (s::String-> s=>nofunction(s, "_aggfunc")).(names(seriesalts)))
  rename!(seriesalts, :assets=>:alt_assets)

  #join and melt the two aggregatations
  series = leftjoin(series, seriesalts, on=:date)
  series = stack(series, Not(:date))
  #println(describe(series))

  return series
end

#makes a scatterplot of fund assets
function graphscatterfunds(
  funds::AbstractDataFrame;
  outputfolder::String = PARAM[:figurepath],
  styleidx::Dict = error("styleidx is required"),
  Fx=:l10assets,
  Fy=:error("Fy is required"),
  Fgroup=:variable,
  graphname::String = error("graph name is required"),
  yaxisname::String = error("y-axis name is required"))

  #println(series)

  panel = @vlplot() +
    @vlplot( #first part contains the line and circle dots
      data = funds,
      width=styleidx[:widthscatter],
      height=styleidx[:heightscatter],
      title=nothing,
      mark={:circle,
      size=styleidx[:pointsize]},
      x={Fx,
        axis={title=styleidx[:xaxisscattername],
          grid=false,
          titleFontSize=styleidx[:textsize],
          #tickCount=11,
          titleFontWeight=:normal,
          labels=true},
        type=:quantitative,
        scale={zero=false}
        },
      y={Fy,
        axis={title=yaxisname,
            grid=false,
#            tickCount=4,
            titleFontSize=styleidx[:textsize],
            titleFontWeight=:normal},
          type=:quantitative,
        },
      )

  save("$outputfolder\\$graphname.png", panel)
end

max_stars_repo_name: clintonTE/CCA

max_issues_repo_name: clintonTE/CCA

max_forks_repo_name: clintonTE/CCA


text:
# Playing Cards: Module Definition
module PlayingCards

export Suit,   ♣,       ♢,      ♡,      ♠
export       Clubs, Diamonds, Hearts, Spades
export       clubs, diamonds, hearts, spades

export Rank, ace, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king
export       Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King

export Card, name
export Deck, Hand, shuffle, deal

include("card.jl")
include("deck.jl")
include("hand.jl")

end # module

max_stars_repo_name: Joshua-Robison/PlayingCards

max_issues_repo_name: Joshua-Robison/PlayingCards

max_forks_repo_name: Joshua-Robison/PlayingCards


text:
Base.@kwdef mutable struct FileDialogModel <: AbstractDialogModel
    confirmed_path::Path = Path(pwd(), "")
    unconfirmed_path::Path = Path(pwd(), "")
end

function get_path(model::FileDialogModel, status::ConfirmedStatus)
    model.confirmed_path
end

function get_path(model::FileDialogModel, status::UnconfirmedStatus)
    model.unconfirmed_path
end

function set_path!(model::FileDialogModel, path::Path, status::ConfirmedStatus)
    model.confirmed_path = path
end

function set_path!(model::FileDialogModel, path::Path, status::UnconfirmedStatus)
    model.unconfirmed_path = path
end


text:
using GeometricFlux
using Flux
using Flux: onehotbatch, onecold, logitcrossentropy, throttle
using Flux: @epochs
using JLD2
using Statistics
using SparseArrays
using Graphs.SimpleGraphs
using CUDA
using Random

Random.seed!([0x6044b4da, 0xd873e4f9, 0x59d90c0a, 0xde01aa81])

@load "data/cora_features.jld2" features
@load "data/cora_labels.jld2" labels
@load "data/cora_graph.jld2" g

num_nodes = 2708
num_features = 1433
hidden = 16
target_catg = 7
epochs = 100

## Preprocessing data
train_X = Matrix{Float32}(features) |> gpu  # dim: num_features * num_nodes
train_y = Matrix{Float32}(labels) |> gpu  # dim: target_catg * num_nodes
fg = FeaturedGraph(g) |> gpu

## Model
model = Chain(GCNConv(fg, num_features=>hidden, relu),
              Dropout(0.5),
              GCNConv(fg, hidden=>target_catg),
              ) |> gpu

## Loss
loss(x, y) = logitcrossentropy(model(x), y)
accuracy(x, y) = mean(onecold(softmax(cpu(model(x)))) .== onecold(cpu(y)))

## Training
ps = Flux.params(model)
train_data = [(train_X, train_y)]
opt = ADAM(0.01)
evalcb() = @show(accuracy(train_X, train_y))

@epochs epochs Flux.train!(loss, ps, train_data, opt, cb=throttle(evalcb, 10))


text:
@testset "5.3.2 (d x)^m (a+b arctan(c x^n))^p" begin
    (a, b, c, d, m, n, p, x, ) = @variables a b c d m n p x

    #= ::Package:: =#

    #= ::Title:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^n))^p=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^1))^p=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*(a+b*atan(c*x))^p=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x^5*(a + b*atan(c*x)), x, 4, -(b*x)/(6*c^5) + (b*x^3)/(18*c^3) - (b*x^5)/(30*c) + (b*atan(c*x))/(6*c^6) + (x^6*(a + b*atan(c*x)))/6]
    @test_int [x^4*(a + b*atan(c*x)), x, 4, (b*x^2)/(10*c^3) - (b*x^4)/(20*c) + (x^5*(a + b*atan(c*x)))/5 - (b*log(1 + c^2*x^2))/(10*c^5)]
    @test_int [x^3*(a + b*atan(c*x)), x, 4, (b*x)/(4*c^3) - (b*x^3)/(12*c) - (b*atan(c*x))/(4*c^4) + (x^4*(a + b*atan(c*x)))/4]
    @test_int [x^2*(a + b*atan(c*x)), x, 4, -(b*x^2)/(6*c) + (x^3*(a + b*atan(c*x)))/3 + (b*log(1 + c^2*x^2))/(6*c^3)]
    @test_int [x^1*(a + b*atan(c*x)), x, 3, -(b*x)/(2*c) + (b*atan(c*x))/(2*c^2) + (x^2*(a + b*atan(c*x)))/2]
    @test_int [x^0*(a + b*atan(c*x)), x, 3, a*x + b*x*atan(c*x) - (b*log(1 + c^2*x^2))/(2*c)]
    @test_int [(a + b*atan(c*x))/x^1, x, 3, a*log(x) + (im/2)*b*PolyLog(2, (-im)*c*x) - (im/2)*b*PolyLog(2, im*c*x)]
    @test_int [(a + b*atan(c*x))/x^2, x, 5, -((a + b*atan(c*x))/x) + b*c*log(x) - (b*c*log(1 + c^2*x^2))/2]
    @test_int [(a + b*atan(c*x))/x^3, x, 3, -(b*c)/(2*x) - (b*c^2*atan(c*x))/2 - (a + b*atan(c*x))/(2*x^2)]
    @test_int [(a + b*atan(c*x))/x^4, x, 4, -(b*c)/(6*x^2) - (a + b*atan(c*x))/(3*x^3) - (b*c^3*log(x))/3 + (b*c^3*log(1 + c^2*x^2))/6]
    @test_int [(a + b*atan(c*x))/x^5, x, 4, -(b*c)/(12*x^3) + (b*c^3)/(4*x) + (b*c^4*atan(c*x))/4 - (a + b*atan(c*x))/(4*x^4)]
    @test_int [(a + b*atan(c*x))/x^6, x, 4, -(b*c)/(20*x^4) + (b*c^3)/(10*x^2) - (a + b*atan(c*x))/(5*x^5) + (b*c^5*log(x))/5 - (b*c^5*log(1 + c^2*x^2))/10]

    @test_int [x^5*(a + b*atan(c*x))^2, x, 16, -(a*b*x)/(3*c^5) - (4*b^2*x^2)/(45*c^4) + (b^2*x^4)/(60*c^2) - (b^2*x*atan(c*x))/(3*c^5) + (b*x^3*(a + b*atan(c*x)))/(9*c^3) - (b*x^5*(a + b*atan(c*x)))/(15*c) + (a + b*atan(c*x))^2/(6*c^6) + (x^6*(a + b*atan(c*x))^2)/6 + (23*b^2*log(1 + c^2*x^2))/(90*c^6)]
    @test_int [x^4*(a + b*atan(c*x))^2, x, 14, (-3*b^2*x)/(10*c^4) + (b^2*x^3)/(30*c^2) + (3*b^2*atan(c*x))/(10*c^5) + (b*x^2*(a + b*atan(c*x)))/(5*c^3) - (b*x^4*(a + b*atan(c*x)))/(10*c) + ((im/5)*(a + b*atan(c*x))^2)/c^5 + (x^5*(a + b*atan(c*x))^2)/5 + (2*b*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/(5*c^5) + ((im/5)*b^2*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^5]
    @test_int [x^3*(a + b*atan(c*x))^2, x, 11, (a*b*x)/(2*c^3) + (b^2*x^2)/(12*c^2) + (b^2*x*atan(c*x))/(2*c^3) - (b*x^3*(a + b*atan(c*x)))/(6*c) - (a + b*atan(c*x))^2/(4*c^4) + (x^4*(a + b*atan(c*x))^2)/4 - (b^2*log(1 + c^2*x^2))/(3*c^4)]
    @test_int [x^2*(a + b*atan(c*x))^2, x, 9, (b^2*x)/(3*c^2) - (b^2*atan(c*x))/(3*c^3) - (b*x^2*(a + b*atan(c*x)))/(3*c) - ((im/3)*(a + b*atan(c*x))^2)/c^3 + (x^3*(a + b*atan(c*x))^2)/3 - (2*b*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/(3*c^3) - ((im/3)*b^2*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^3]
    @test_int [x^1*(a + b*atan(c*x))^2, x, 6, -((a*b*x)/c) - (b^2*x*atan(c*x))/c + (a + b*atan(c*x))^2/(2*c^2) + (x^2*(a + b*atan(c*x))^2)/2 + (b^2*log(1 + c^2*x^2))/(2*c^2)]
    @test_int [x^0*(a + b*atan(c*x))^2, x, 5, (im*(a + b*atan(c*x))^2)/c + x*(a + b*atan(c*x))^2 + (2*b*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/c + (im*b^2*PolyLog(2, 1 - 2/(1 + im*c*x)))/c]
    @test_int [(a + b*atan(c*x))^2/x^1, x, 6, 2*(a + b*atan(c*x))^2*atanh(1 - 2/(1 + im*c*x)) - im*b*(a + b*atan(c*x))*PolyLog(2, 1 - 2/(1 + im*c*x)) + im*b*(a + b*atan(c*x))*PolyLog(2, -1 + 2/(1 + im*c*x)) - (b^2*PolyLog(3, 1 - 2/(1 + im*c*x)))/2 + (b^2*PolyLog(3, -1 + 2/(1 + im*c*x)))/2]
    @test_int [(a + b*atan(c*x))^2/x^2, x, 4, (-im)*c*(a + b*atan(c*x))^2 - (a + b*atan(c*x))^2/x + 2*b*c*(a + b*atan(c*x))*log(2 - 2/(1 - im*c*x)) - im*b^2*c*PolyLog(2, -1 + 2/(1 - im*c*x))]
    @test_int [(a + b*atan(c*x))^2/x^3, x, 8, -((b*c*(a + b*atan(c*x)))/x) - (c^2*(a + b*atan(c*x))^2)/2 - (a + b*atan(c*x))^2/(2*x^2) + b^2*c^2*log(x) - (b^2*c^2*log(1 + c^2*x^2))/2]
    @test_int [(a + b*atan(c*x))^2/x^4, x, 8, -(b^2*c^2)/(3*x) - (b^2*c^3*atan(c*x))/3 - (b*c*(a + b*atan(c*x)))/(3*x^2) + (im/3)*c^3*(a + b*atan(c*x))^2 - (a + b*atan(c*x))^2/(3*x^3) - (2*b*c^3*(a + b*atan(c*x))*log(2 - 2/(1 - im*c*x)))/3 + (im/3)*b^2*c^3*PolyLog(2, -1 + 2/(1 - im*c*x))]
    @test_int [(a + b*atan(c*x))^2/x^5, x, 13, -(b^2*c^2)/(12*x^2) - (b*c*(a + b*atan(c*x)))/(6*x^3) + (b*c^3*(a + b*atan(c*x)))/(2*x) + (c^4*(a + b*atan(c*x))^2)/4 - (a + b*atan(c*x))^2/(4*x^4) - (2*b^2*c^4*log(x))/3 + (b^2*c^4*log(1 + c^2*x^2))/3]

    @test_int [x^5*(a + b*atan(c*x))^3, x, 33, (19*b^3*x)/(60*c^5) - (b^3*x^3)/(60*c^3) - (19*b^3*atan(c*x))/(60*c^6) - (4*b^2*x^2*(a + b*atan(c*x)))/(15*c^4) + (b^2*x^4*(a + b*atan(c*x)))/(20*c^2) - (((23*im)/30)*b*(a + b*atan(c*x))^2)/c^6 - (b*x*(a + b*atan(c*x))^2)/(2*c^5) + (b*x^3*(a + b*atan(c*x))^2)/(6*c^3) - (b*x^5*(a + b*atan(c*x))^2)/(10*c) + (a + b*atan(c*x))^3/(6*c^6) + (x^6*(a + b*atan(c*x))^3)/6 - (23*b^2*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/(15*c^6) - (((23*im)/30)*b^3*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^6]
    @test_int [x^4*(a + b*atan(c*x))^3, x, 24, (-9*a*b^2*x)/(10*c^4) - (b^3*x^2)/(20*c^3) - (9*b^3*x*atan(c*x))/(10*c^4) + (b^2*x^3*(a + b*atan(c*x)))/(10*c^2) + (9*b*(a + b*atan(c*x))^2)/(20*c^5) + (3*b*x^2*(a + b*atan(c*x))^2)/(10*c^3) - (3*b*x^4*(a + b*atan(c*x))^2)/(20*c) + ((im/5)*(a + b*atan(c*x))^3)/c^5 + (x^5*(a + b*atan(c*x))^3)/5 + (3*b*(a + b*atan(c*x))^2*log(2/(1 + im*c*x)))/(5*c^5) + (b^3*log(1 + c^2*x^2))/(2*c^5) + (((3*im)/5)*b^2*(a + b*atan(c*x))*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^5 + (3*b^3*PolyLog(3, 1 - 2/(1 + im*c*x)))/(10*c^5)]
    @test_int [x^3*(a + b*atan(c*x))^3, x, 18, -(b^3*x)/(4*c^3) + (b^3*atan(c*x))/(4*c^4) + (b^2*x^2*(a + b*atan(c*x)))/(4*c^2) + (im*b*(a + b*atan(c*x))^2)/c^4 + (3*b*x*(a + b*atan(c*x))^2)/(4*c^3) - (b*x^3*(a + b*atan(c*x))^2)/(4*c) - (a + b*atan(c*x))^3/(4*c^4) + (x^4*(a + b*atan(c*x))^3)/4 + (2*b^2*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/c^4 + (im*b^3*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^4]
    @test_int [x^2*(a + b*atan(c*x))^3, x, 12, (a*b^2*x)/c^2 + (b^3*x*atan(c*x))/c^2 - (b*(a + b*atan(c*x))^2)/(2*c^3) - (b*x^2*(a + b*atan(c*x))^2)/(2*c) - ((im/3)*(a + b*atan(c*x))^3)/c^3 + (x^3*(a + b*atan(c*x))^3)/3 - (b*(a + b*atan(c*x))^2*log(2/(1 + im*c*x)))/c^3 - (b^3*log(1 + c^2*x^2))/(2*c^3) - (im*b^2*(a + b*atan(c*x))*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^3 - (b^3*PolyLog(3, 1 - 2/(1 + im*c*x)))/(2*c^3)]
    @test_int [x^1*(a + b*atan(c*x))^3, x, 8, (((-3*im)/2)*b*(a + b*atan(c*x))^2)/c^2 - (3*b*x*(a + b*atan(c*x))^2)/(2*c) + (a + b*atan(c*x))^3/(2*c^2) + (x^2*(a + b*atan(c*x))^3)/2 - (3*b^2*(a + b*atan(c*x))*log(2/(1 + im*c*x)))/c^2 - (((3*im)/2)*b^3*PolyLog(2, 1 - 2/(1 + im*c*x)))/c^2]
    @test_int [x^0*(a + b*atan(c*x))^3, x, 5, (im*(a + b*atan(c*x))^3)/c + x*(a + b*atan(c*x))^3 + (3*b*(a + b*atan(c*x))^2*log(2/(1 + im*c*x)))/c + ((3*im)*b^2*(a + b*atan(c*x))*PolyLog(2, 1 - 2/(1 + im*c*x)))/c + (3*b^3*PolyLog(3, 1 - 2/(1 + im*c*x)))/(2*c)]
    @test_int [(a + b*atan(c*x))^3/x^1, x, 8, 2*(a + b*atan(c*x))^3*atanh(1 - 2/(1 + im*c*x)) - ((3*im)/2)*b*(a + b*atan(c*x))^2*PolyLog(2, 1 - 2/(1 + im*c*x)) + ((3*im)/2)*b*(a + b*atan(c*x))^2*PolyLog(2, -1 + 2/(1 + im*c*x)) - (3*b^2*(a + b*atan(c*x))*PolyLog(3, 1 - 2/(1 + im*c*x)))/2 + (3*b^2*(a + b*atan(c*x))*PolyLog(3, -1 + 2/(1 + im*c*x)))/2 + ((3*im)/4)*b^3*PolyLog(4, 1 - 2/(1 + im*c*x)) - ((3*im)/4)*b^3*PolyLog(4, -1 + 2/(1 + im*c*x))]
    @test_int [(a + b*atan(c*x))^3/x^2, x, 5, (-im)*c*(a + b*atan(c*x))^3 - (a + b*atan(c*x))^3/x + 3*b*c*(a + b*atan(c*x))^2*log(2 - 2/(1 - im*c*x)) - (3*im)*b^2*c*(a + b*atan(c*x))*PolyLog(2, -1 + 2/(1 - im*c*x)) + (3*b^3*c*PolyLog(3, -1 + 2/(1 - im*c*x)))/2]
    @test_int [(a + b*atan(c*x))^3/x^3, x, 7, ((-3*im)/2)*b*c^2*(a + b*atan(c*x))^2 - (3*b*c*(a + b*atan(c*x))^2)/(2*x) - (c^2*(a + b*atan(c*x))^3)/2 - (a + b*atan(c*x))^3/(2*x^2) + 3*b^2*c^2*(a + b*atan(c*x))*log(2 - 2/(1 - im*c*x)) - ((3*im)/2)*b^3*c^2*PolyLog(2, -1 + 2/(1 - im*c*x))]
    @test_int [(a + b*atan(c*x))^3/x^4, x, 14, -((b^2*c^2*(a + b*atan(c*x)))/x) - (b*c^3*(a + b*atan(c*x))^2)/2 - (b*c*(a + b*atan(c*x))^2)/(2*x^2) + (im/3)*c^3*(a + b*atan(c*x))^3 - (a + b*atan(c*x))^3/(3*x^3) + b^3*c^3*log(x) - (b^3*c^3*log(1 + c^2*x^2))/2 - b*c^3*(a + b*atan(c*x))^2*log(2 - 2/(1 - im*c*x)) + im*b^2*c^3*(a + b*atan(c*x))*PolyLog(2, -1 + 2/(1 - im*c*x)) - (b^3*c^3*PolyLog(3, -1 + 2/(1 - im*c*x)))/2]
    @test_int [(a + b*atan(c*x))^3/x^5, x, 16, -(b^3*c^3)/(4*x) - (b^3*c^4*atan(c*x))/4 - (b^2*c^2*(a + b*atan(c*x)))/(4*x^2) + im*b*c^4*(a + b*atan(c*x))^2 - (b*c*(a + b*atan(c*x))^2)/(4*x^3) + (3*b*c^3*(a + b*atan(c*x))^2)/(4*x) + (c^4*(a + b*atan(c*x))^3)/4 - (a + b*atan(c*x))^3/(4*x^4) - 2*b^2*c^4*(a + b*atan(c*x))*log(2 - 2/(1 - im*c*x)) + im*b^3*c^4*PolyLog(2, -1 + 2/(1 - im*c*x))]

    #= ::Subsubsection::Closed:: =#
    #=p<0=#

    @test_int [x^1/atan(a*x), x, 0, Unintegrable(x/atan(a*x), x)]
    @test_int [x^0/atan(a*x), x, 0, Unintegrable(1/atan(a*x), x)]
    @test_int [1/(x^1*atan(a*x)), x, 0, Unintegrable(1/(x*atan(a*x)), x)]

    @test_int [x^1/atan(a*x)^2, x, 0, Unintegrable(x/atan(a*x)^2, x)]
    @test_int [x^0/atan(a*x)^2, x, 0, Unintegrable(1/atan(a*x)^2, x)]
    @test_int [1/(x^1*atan(a*x)^2), x, 0, Unintegrable(1/(x*atan(a*x)^2), x)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*(a+b*atan(c*x))^(p/2)=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x*sqrt(atan(a*x)), x, 0, Unintegrable(x*sqrt(atan(a*x)), x)]
    @test_int [sqrt(atan(a*x)), x, 0, Unintegrable(sqrt(atan(a*x)), x)]
    @test_int [sqrt(atan(a*x))/x, x, 0, Unintegrable(sqrt(atan(a*x))/x, x)]

    @test_int [x*atan(a*x)^(3/2), x, 0, Unintegrable(x*atan(a*x)^(3/2), x)]
    @test_int [atan(a*x)^(3/2), x, 0, Unintegrable(atan(a*x)^(3/2), x)]
    @test_int [atan(a*x)^(3/2)/x, x, 0, Unintegrable(atan(a*x)^(3/2)/x, x)]

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x/sqrt(atan(a*x)), x, 0, Unintegrable(x/sqrt(atan(a*x)), x)]
    @test_int [1/sqrt(atan(a*x)), x, 0, Unintegrable(1/sqrt(atan(a*x)), x)]
    @test_int [1/(x*sqrt(atan(a*x))), x, 0, Unintegrable(1/(x*sqrt(atan(a*x))), x)]

    @test_int [x/atan(a*x)^(3/2), x, 0, Unintegrable(x/atan(a*x)^(3/2), x)]
    @test_int [1/atan(a*x)^(3/2), x, 0, Unintegrable(atan(a*x)^(-3/2), x)]
    @test_int [1/(x*atan(a*x)^(3/2)), x, 0, Unintegrable(1/(x*atan(a*x)^(3/2)), x)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d*x)^(m/2)*(a+b*atan(c*x))^p=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [sqrt(x)*atan(x), x, 12, -((4*sqrt(x))/3) - (1/3)*sqrt(2)*atan(1 - sqrt(2)*sqrt(x)) + (1/3)*sqrt(2)*atan(1 + sqrt(2)*sqrt(x)) + (2/3)*x^(3/2)*atan(x) - log(1 - sqrt(2)*sqrt(x) + x)/(3*sqrt(2)) + log(1 + sqrt(2)*sqrt(x) + x)/(3*sqrt(2))]

    #= ::Subsubsection:: =#
    #=p<0=#

    #= ::Subsection:: =#
    #=Integrands*of*the*form*(d*x)^(m/2)*(a+b*atan(c*x))^(p/2)=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x))^p*with*m*symbolic=#

    @test_int [(d*x)^m*(a + b*atan(c*x))^3, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x))^3, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x))^2, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x))^2, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x))^1, x, 2, ((d*x)^(1 + m)*(a + b*atan(c*x)))/(d*(1 + m)) - (b*c*(d*x)^(2 + m)*HypergeometricFunctions._₂F₁(1, (2 + m)/2, (4 + m)/2, (-c^2)*x^2))/(d^2*(1 + m)*(2 + m))]
    @test_int [(d*x)^m/(a + b*atan(c*x))^1, x, 0, Unintegrable((d*x)^m/(a + b*atan(c*x)), x)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x))^p*with*p*symbolic=#

    @test_int [(a + b*atan(c*x))^p, x, 0, Unintegrable((a + b*atan(c*x))^p, x)]

    @test_int [(d*x)^m*(a + b*atan(c*x))^p, x, 0, Unintegrable((d*x)^m*(a + b* atan(c*x))^p, x)]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^2))^p=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*(a+b*atan(c*x^2))^p=#

    @test_int [x^7*(a + b*atan(c*x^2)), x, 5, (b*x^2)/(8*c^3) - (b*x^6)/(24*c) - (b*atan(c*x^2))/(8*c^4) + (1/8)*x^8*(a + b*atan(c*x^2))]
    @test_int [x^5*(a + b*atan(c*x^2)), x, 4, -((b*x^4)/(12*c)) + (1/6)*x^6*(a + b*atan(c*x^2)) + (b*log(1 + c^2*x^4))/(12*c^3)]
    @test_int [x^3*(a + b*atan(c*x^2)), x, 4, -((b*x^2)/(4*c)) + (b*atan(c*x^2))/(4*c^2) + (1/4)*x^4*(a + b*atan(c*x^2))]
    @test_int [x^1*(a + b*atan(c*x^2)), x, 2, (1/2)*x^2*(a + b*atan(c*x^2)) - (b*log(1 + c^2*x^4))/(4*c)]
    @test_int [(a + b*atan(c*x^2))/x^1, x, 4, a*log(x) + (1/4)*im*b*PolyLog(2, (-im)*c*x^2) - (1/4)*im*b*PolyLog(2, im*c*x^2)]
    @test_int [(a + b*atan(c*x^2))/x^3, x, 5, -((a + b*atan(c*x^2))/(2*x^2)) + b*c*log(x) - (1/4)*b*c*log(1 + c^2*x^4)]
    @test_int [(a + b*atan(c*x^2))/x^5, x, 4, -((b*c)/(4*x^2)) - (1/4)*b*c^2*atan(c*x^2) - (a + b*atan(c*x^2))/(4*x^4)]
    @test_int [(a + b*atan(c*x^2))/x^7, x, 4, -((b*c)/(12*x^4)) - (a + b*atan(c*x^2))/(6*x^6) - (1/3)*b*c^3*log(x) + (1/12)*b*c^3*log(1 + c^2*x^4)]

    @test_int [x^4*(a + b*atan(c*x^2)), x, 11, -((2*b*x^3)/(15*c)) + (1/5)*x^5*(a + b*atan(c*x^2)) - (b*atan(1 - sqrt(2)*sqrt(c)*x))/(5*sqrt(2)*c^(5/2)) + (b*atan(1 + sqrt(2)*sqrt(c)*x))/(5*sqrt(2)*c^(5/2)) + (b*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(10*sqrt(2)*c^(5/2)) - (b*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(10*sqrt(2)*c^(5/2))]
    @test_int [x^2*(a + b*atan(c*x^2)), x, 11, -((2*b*x)/(3*c)) + (1/3)*x^3*(a + b*atan(c*x^2)) - (b*atan(1 - sqrt(2)*sqrt(c)*x))/(3*sqrt(2)*c^(3/2)) + (b*atan(1 + sqrt(2)*sqrt(c)*x))/(3*sqrt(2)*c^(3/2)) - (b*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(6*sqrt(2)*c^(3/2)) + (b*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(6*sqrt(2)*c^(3/2))]
    @test_int [x^0*(a + b*atan(c*x^2)), x, 11, a*x + b*x*atan(c*x^2) + (b*atan(1 - sqrt(2)*sqrt(c)*x))/(sqrt(2)*sqrt(c)) - (b*atan(1 + sqrt(2)*sqrt(c)*x))/(sqrt(2)*sqrt(c)) - (b*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(2*sqrt(2)*sqrt(c)) + (b*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(2*sqrt(2)*sqrt(c))]
    @test_int [(a + b*atan(c*x^2))/x^2, x, 10, -((a + b*atan(c*x^2))/x) - (b*sqrt(c)*atan(1 - sqrt(2)*sqrt(c)*x))/sqrt(2) + (b*sqrt(c)*atan(1 + sqrt(2)*sqrt(c)*x))/sqrt(2) - (b*sqrt(c)*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(2*sqrt(2)) + (b*sqrt(c)*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(2*sqrt(2))]
    @test_int [(a + b*atan(c*x^2))/x^4, x, 11, -((2*b*c)/(3*x)) - (a + b*atan(c*x^2))/(3*x^3) + (b*c^(3/2)*atan(1 - sqrt(2)*sqrt(c)*x))/(3*sqrt(2)) - (b*c^(3/2)*atan(1 + sqrt(2)*sqrt(c)*x))/(3*sqrt(2)) - (b*c^(3/2)*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(6*sqrt(2)) + (b*c^(3/2)*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(6*sqrt(2))]
    @test_int [(a + b*atan(c*x^2))/x^6, x, 11, -((2*b*c)/(15*x^3)) - (a + b*atan(c*x^2))/(5*x^5) + (b*c^(5/2)*atan(1 - sqrt(2)*sqrt(c)*x))/(5*sqrt(2)) - (b*c^(5/2)*atan(1 + sqrt(2)*sqrt(c)*x))/(5*sqrt(2)) + (b*c^(5/2)*log(1 - sqrt(2)*sqrt(c)*x + c*x^2))/(10*sqrt(2)) - (b*c^(5/2)*log(1 + sqrt(2)*sqrt(c)*x + c*x^2))/(10*sqrt(2))]

    @test_int [x^7*(a + b*atan(c*x^2))^2, x, 12, (a*b*x^2)/(4*c^3) + (b^2*x^4)/(24*c^2) + (b^2*x^2*atan(c*x^2))/(4*c^3) - (b*x^6*(a + b*atan(c*x^2)))/(12*c) - (a + b*atan(c*x^2))^2/(8*c^4) + (1/8)*x^8*(a + b*atan(c*x^2))^2 - (b^2*log(1 + c^2*x^4))/(6*c^4)]
    @test_int [x^5*(a + b*atan(c*x^2))^2, x, 10, (b^2*x^2)/(6*c^2) - (b^2*atan(c*x^2))/(6*c^3) - (b*x^4*(a + b*atan(c*x^2)))/(6*c) - (im*(a + b*atan(c*x^2))^2)/(6*c^3) + (1/6)*x^6*(a + b*atan(c*x^2))^2 - (b*(a + b*atan(c*x^2))*log(2/(1 + im*c*x^2)))/(3*c^3) - (im*b^2*PolyLog(2, 1 - 2/(1 + im*c*x^2)))/(6*c^3)]
    @test_int [x^3*(a + b*atan(c*x^2))^2, x, 7, -((a*b*x^2)/(2*c)) - (b^2*x^2*atan(c*x^2))/(2*c) + (a + b*atan(c*x^2))^2/(4*c^2) + (1/4)*x^4*(a + b*atan(c*x^2))^2 + (b^2*log(1 + c^2*x^4))/(4*c^2)]
    @test_int [x^1*(a + b*atan(c*x^2))^2, x, 6, (im*(a + b*atan(c*x^2))^2)/(2*c) + (1/2)*x^2*(a + b*atan(c*x^2))^2 + (b*(a + b*atan(c*x^2))*log(2/(1 + im*c*x^2)))/c + (im*b^2*PolyLog(2, 1 - 2/(1 + im*c*x^2)))/(2*c)]
    @test_int [(a + b*atan(c*x^2))^2/x^1, x, 7, (a + b*atan(c*x^2))^2*atanh(1 - 2/(1 + im*c*x^2)) - (1/2)*im*b*(a + b*atan(c*x^2))*PolyLog(2, 1 - 2/(1 + im*c*x^2)) + (1/2)*im*b*(a + b*atan(c*x^2))*PolyLog(2, -1 + 2/(1 + im*c*x^2)) - (1/4)*b^2*PolyLog(3, 1 - 2/(1 + im*c*x^2)) + (1/4)*b^2*PolyLog(3, -1 + 2/(1 + im*c*x^2))]
    @test_int [(a + b*atan(c*x^2))^2/x^3, x, 5, (-(1/2))*im*c*(a + b*atan(c*x^2))^2 - (a + b*atan(c*x^2))^2/(2*x^2) + b*c*(a + b*atan(c*x^2))*log(2 - 2/(1 - im*c*x^2)) - (1/2)*im*b^2*c*PolyLog(2, -1 + 2/(1 - im*c*x^2))]
    @test_int [(a + b*atan(c*x^2))^2/x^5, x, 9, -((b*c*(a + b*atan(c*x^2)))/(2*x^2)) - (1/4)*c^2*(a + b*atan(c*x^2))^2 - (a + b*atan(c*x^2))^2/(4*x^4) + b^2*c^2*log(x) - (1/4)*b^2*c^2*log(1 + c^2*x^4)]

    @test_int [x^2*(a + b*atan(c*x^2))^2, x, 86, -((4*a*b*x)/(3*c)) + (2/9)*im*a*b*x^3 + (4*(-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x))/(3*c^(3/2)) + ((-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)^2)/(3*c^(3/2)) - (2*(-1)^(1/4)*a*b*atanh((-1)^(3/4)*sqrt(c)*x))/(3*c^(3/2)) - (4*(-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x))/(3*c^(3/2)) - ((-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)^2)/(3*c^(3/2)) - (2*(-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) + (2*(-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) - ((-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log((sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) + (2*(-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(3/4)*sqrt(c)*x)))/(3*c^(3/2)) - (2*(-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(3/4)*sqrt(c)*x)))/(3*c^(3/2)) + ((-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(-((sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x))))/(3*c^(3/2)) + ((-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/(3*c^(3/2)) - ((-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) - (2*im*b^2*x*log(1 - im*c*x^2))/(3*c) - (1/9)*b^2*x^3*log(1 - im*c*x^2) - ((-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2))/(3*c^(3/2)) - (1/9)*im*b*x^3*(2*a + im*b*log(1 - im*c*x^2)) - ((-1)^(1/4)*b*atan((-1)^(3/4)*sqrt(c)*x)*(2*a + im*b*log(1 - im*c*x^2)))/(3*c^(3/2)) + (1/12)*x^3*(2*a + im*b*log(1 - im*c*x^2))^2 + (2*im*b^2*x*log(1 + im*c*x^2))/(3*c) - (1/3)*im*a*b*x^3*log(1 + im*c*x^2) + ((-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2))/(3*c^(3/2)) + ((-1)^(3/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2))/(3*c^(3/2)) + (1/6)*b^2*x^3*log(1 - im*c*x^2)*log(1 + im*c*x^2) - (1/12)*b^2*x^3*log(1 + im*c*x^2)^2 + ((-1)^(1/4)*b^2*PolyLog(2, 1 - 2/(1 - (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) + ((-1)^(1/4)*b^2*PolyLog(2, 1 - 2/(1 + (-1)^(1/4)*sqrt(c)*x)))/(3*c^(3/2)) - ((-1)^(1/4)*b^2*PolyLog(2, 1 - (sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(6*c^(3/2)) + ((-1)^(3/4)*b^2*PolyLog(2, 1 - 2/(1 - (-1)^(3/4)*sqrt(c)*x)))/(3*c^(3/2)) + ((-1)^(3/4)*b^2*PolyLog(2, 1 - 2/(1 + (-1)^(3/4)*sqrt(c)*x)))/(3*c^(3/2)) - ((-1)^(3/4)*b^2*PolyLog(2, 1 + (sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/(6*c^(3/2)) - ((-1)^(3/4)*b^2*PolyLog(2, 1 - ((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/(6*c^(3/2)) - ((-1)^(1/4)*b^2*PolyLog(2, 1 - ((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(6*c^(3/2))]
    @test_int [x^0*(a + b*atan(c*x^2))^2, x, 69, a^2*x - (2*(-1)^(3/4)*a*b*atan((-1)^(3/4)*sqrt(c)*x))/sqrt(c) + ((-1)^(3/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)^2)/sqrt(c) + (2*(-1)^(3/4)*a*b*atanh((-1)^(3/4)*sqrt(c)*x))/sqrt(c) - ((-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)^2)/sqrt(c) + (2*(-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) - (2*(-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) + ((-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log((sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) + (2*(-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(3/4)*sqrt(c)*x)))/sqrt(c) - (2*(-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(3/4)*sqrt(c)*x)))/sqrt(c) + ((-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(-((sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x))))/sqrt(c) + ((-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/sqrt(c) + ((-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) + im*a*b*x*log(1 - im*c*x^2) + ((-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2))/sqrt(c) - ((-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2))/sqrt(c) - (1/4)*b^2*x*log(1 - im*c*x^2)^2 - im*a*b*x*log(1 + im*c*x^2) - ((-1)^(1/4)*b^2*atan((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2))/sqrt(c) + ((-1)^(1/4)*b^2*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2))/sqrt(c) + (1/2)*b^2*x*log(1 - im*c*x^2)*log(1 + im*c*x^2) - (1/4)*b^2*x*log(1 + im*c*x^2)^2 + ((-1)^(3/4)*b^2*PolyLog(2, 1 - 2/(1 - (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) + ((-1)^(3/4)*b^2*PolyLog(2, 1 - 2/(1 + (-1)^(1/4)*sqrt(c)*x)))/sqrt(c) - ((-1)^(3/4)*b^2*PolyLog(2, 1 - (sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(2*sqrt(c)) + ((-1)^(1/4)*b^2*PolyLog(2, 1 - 2/(1 - (-1)^(3/4)*sqrt(c)*x)))/sqrt(c) + ((-1)^(1/4)*b^2*PolyLog(2, 1 - 2/(1 + (-1)^(3/4)*sqrt(c)*x)))/sqrt(c) - ((-1)^(1/4)*b^2*PolyLog(2, 1 + (sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/(2*sqrt(c)) - ((-1)^(1/4)*b^2*PolyLog(2, 1 - ((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)))/(2*sqrt(c)) - ((-1)^(3/4)*b^2*PolyLog(2, 1 - ((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)))/(2*sqrt(c))]
    @test_int [(a + b*atan(c*x^2))^2/x^2, x, 47, (-1)^(1/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)^2 - 2*(-1)^(1/4)*a*b*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x) - (-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)^2 - 2*(-1)^(3/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(1/4)*sqrt(c)*x)) + 2*(-1)^(3/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(1/4)*sqrt(c)*x)) - (-1)^(3/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*log((sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) + 2*(-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(3/4)*sqrt(c)*x)) - 2*(-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(3/4)*sqrt(c)*x)) + (-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(-((sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x))) + (-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) - (-1)^(3/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*log(((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) - (-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2) - (-1)^(1/4)*b*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*(2*a + im*b*log(1 - im*c*x^2)) - (2*a + im*b*log(1 - im*c*x^2))^2/(4*x) + (im*a*b*log(1 + im*c*x^2))/x + (-1)^(3/4)*b^2*sqrt(c)*atan((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) + (-1)^(3/4)*b^2*sqrt(c)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) - (b^2*log(1 - im*c*x^2)*log(1 + im*c*x^2))/(2*x) + (b^2*log(1 + im*c*x^2)^2)/(4*x) + (-1)^(1/4)*b^2*sqrt(c)*PolyLog(2, 1 - 2/(1 - (-1)^(1/4)*sqrt(c)*x)) + (-1)^(1/4)*b^2*sqrt(c)*PolyLog(2, 1 - 2/(1 + (-1)^(1/4)*sqrt(c)*x)) - (1/2)*(-1)^(1/4)*b^2*sqrt(c)*PolyLog(2, 1 - (sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) + (-1)^(3/4)*b^2*sqrt(c)*PolyLog(2, 1 - 2/(1 - (-1)^(3/4)*sqrt(c)*x)) + (-1)^(3/4)*b^2*sqrt(c)*PolyLog(2, 1 - 2/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/2)*(-1)^(3/4)*b^2*sqrt(c)*PolyLog(2, 1 + (sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/2)*(-1)^(3/4)*b^2*sqrt(c)*PolyLog(2, 1 - ((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/2)*(-1)^(1/4)*b^2*sqrt(c)*PolyLog(2, 1 - ((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x))]
    @test_int [(a + b*atan(c*x^2))^2/x^4, x, 64, -((2*a*b*c)/(3*x)) - (4/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x) + (1/3)*(-1)^(3/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)^2 + (2/3)*(-1)^(3/4)*a*b*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x) - (4/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x) - (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)^2 + (2/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(1/4)*sqrt(c)*x)) - (2/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(1/4)*sqrt(c)*x)) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*log((sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) + (2/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(3/4)*sqrt(c)*x)) - (2/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(-((sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x))) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) - (im*b^2*c*log(1 - im*c*x^2))/(3*x) - (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2) - (b*c*(2*a + im*b*log(1 - im*c*x^2)))/(3*x) - (1/3)*(-1)^(3/4)*b*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*(2*a + im*b*log(1 - im*c*x^2)) - (2*a + im*b*log(1 - im*c*x^2))^2/(12*x^3) + (im*a*b*log(1 + im*c*x^2))/(3*x^3) + (2*im*b^2*c*log(1 + im*c*x^2))/(3*x) - (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) - (b^2*log(1 - im*c*x^2)*log(1 + im*c*x^2))/(6*x^3) + (b^2*log(1 + im*c*x^2)^2)/(12*x^3) + (1/3)*(-1)^(3/4)*b^2*c^(3/2)*PolyLog(2, 1 - 2/(1 - (-1)^(1/4)*sqrt(c)*x)) + (1/3)*(-1)^(3/4)*b^2*c^(3/2)*PolyLog(2, 1 - 2/(1 + (-1)^(1/4)*sqrt(c)*x)) - (1/6)*(-1)^(3/4)*b^2*c^(3/2)*PolyLog(2, 1 - (sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*PolyLog(2, 1 - 2/(1 - (-1)^(3/4)*sqrt(c)*x)) + (1/3)*(-1)^(1/4)*b^2*c^(3/2)*PolyLog(2, 1 - 2/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/6)*(-1)^(1/4)*b^2*c^(3/2)*PolyLog(2, 1 + (sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/6)*(-1)^(1/4)*b^2*c^(3/2)*PolyLog(2, 1 - ((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/6)*(-1)^(3/4)*b^2*c^(3/2)*PolyLog(2, 1 - ((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x))]
    @test_int [(a + b*atan(c*x^2))^2/x^6, x, 77, -((2*a*b*c)/(15*x^3)) + (2*im*a*b*c^2)/(5*x) - (8*b^2*c^2)/(15*x) - (4/15)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x) - (1/5)*(-1)^(1/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)^2 + (2/5)*(-1)^(1/4)*a*b*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x) + (4/15)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x) + (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)^2 + (2/5)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(1/4)*sqrt(c)*x)) - (2/5)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(1/4)*sqrt(c)*x)) + (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*log((sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) - (2/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 - (-1)^(3/4)*sqrt(c)*x)) + (2/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(2/(1 + (-1)^(3/4)*sqrt(c)*x)) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(-((sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x))) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) - (im*b^2*c*log(1 - im*c*x^2))/(15*x^3) - (b^2*c^2*log(1 - im*c*x^2))/(5*x) + (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 - im*c*x^2) - (b*c*(2*a + im*b*log(1 - im*c*x^2)))/(15*x^3) - (im*b*c^2*(2*a + im*b*log(1 - im*c*x^2)))/(5*x) + (1/5)*(-1)^(1/4)*b*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*(2*a + im*b*log(1 - im*c*x^2)) - (2*a + im*b*log(1 - im*c*x^2))^2/(20*x^5) + (im*a*b*log(1 + im*c*x^2))/(5*x^5) + (2*im*b^2*c*log(1 + im*c*x^2))/(15*x^3) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atan((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*atanh((-1)^(3/4)*sqrt(c)*x)*log(1 + im*c*x^2) - (b^2*log(1 - im*c*x^2)*log(1 + im*c*x^2))/(10*x^5) + (b^2*log(1 + im*c*x^2)^2)/(20*x^5) - (1/5)*(-1)^(1/4)*b^2*c^(5/2)*PolyLog(2, 1 - 2/(1 - (-1)^(1/4)*sqrt(c)*x)) - (1/5)*(-1)^(1/4)*b^2*c^(5/2)*PolyLog(2, 1 - 2/(1 + (-1)^(1/4)*sqrt(c)*x)) + (1/10)*(-1)^(1/4)*b^2*c^(5/2)*PolyLog(2, 1 - (sqrt(2)*((-1)^(1/4) + sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x)) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*PolyLog(2, 1 - 2/(1 - (-1)^(3/4)*sqrt(c)*x)) - (1/5)*(-1)^(3/4)*b^2*c^(5/2)*PolyLog(2, 1 - 2/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/10)*(-1)^(3/4)*b^2*c^(5/2)*PolyLog(2, 1 + (sqrt(2)*((-1)^(3/4) + sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/10)*(-1)^(3/4)*b^2*c^(5/2)*PolyLog(2, 1 - ((1 + im)*(1 + (-1)^(1/4)*sqrt(c)*x))/(1 + (-1)^(3/4)*sqrt(c)*x)) + (1/10)*(-1)^(1/4)*b^2*c^(5/2)*PolyLog(2, 1 - ((1 - im)*(1 + (-1)^(3/4)*sqrt(c)*x))/(1 + (-1)^(1/4)*sqrt(c)*x))]

    @test_int [x^3*(a + b*atan(c*x^2))^3, x, 9, -((3*im*b*(a + b*atan(c*x^2))^2)/(4*c^2)) - (3*b*x^2*(a + b*atan(c*x^2))^2)/(4*c) + (a + b*atan(c*x^2))^3/(4*c^2) + (1/4)*x^4*(a + b*atan(c*x^2))^3 - (3*b^2*(a + b*atan(c*x^2))*log(2/(1 + im*c*x^2)))/(2*c^2) - (3*im*b^3*PolyLog(2, 1 - 2/(1 + im*c*x^2)))/(4*c^2)]
    @test_int [x^1*(a + b*atan(c*x^2))^3, x, 6, (im*(a + b*atan(c*x^2))^3)/(2*c) + (1/2)*x^2*(a + b*atan(c*x^2))^3 + (3*b*(a + b*atan(c*x^2))^2*log(2/(1 + im*c*x^2)))/(2*c) + (3*im*b^2*(a + b*atan(c*x^2))*PolyLog(2, 1 - 2/(1 + im*c*x^2)))/(2*c) + (3*b^3*PolyLog(3, 1 - 2/(1 + im*c*x^2)))/(4*c)]
    @test_int [(a + b*atan(c*x^2))^3/x^1, x, 9, (a + b*atan(c*x^2))^3*atanh(1 - 2/(1 + im*c*x^2)) - (3/4)*im*b*(a + b*atan(c*x^2))^2*PolyLog(2, 1 - 2/(1 + im*c*x^2)) + (3/4)*im*b*(a + b*atan(c*x^2))^2*PolyLog(2, -1 + 2/(1 + im*c*x^2)) - (3/4)*b^2*(a + b*atan(c*x^2))*PolyLog(3, 1 - 2/(1 + im*c*x^2)) + (3/4)*b^2*(a + b*atan(c*x^2))*PolyLog(3, -1 + 2/(1 + im*c*x^2)) + (3/8)*im*b^3*PolyLog(4, 1 - 2/(1 + im*c*x^2)) - (3/8)*im*b^3*PolyLog(4, -1 + 2/(1 + im*c*x^2))]
    @test_int [(a + b*atan(c*x^2))^3/x^3, x, 6, (-(1/2))*im*c*(a + b*atan(c*x^2))^3 - (a + b*atan(c*x^2))^3/(2*x^2) + (3/2)*b*c*(a + b*atan(c*x^2))^2*log(2 - 2/(1 - im*c*x^2)) - (3/2)*im*b^2*c*(a + b*atan(c*x^2))*PolyLog(2, -1 + 2/(1 - im*c*x^2)) + (3/4)*b^3*c*PolyLog(3, -1 + 2/(1 - im*c*x^2))]
    @test_int [(a + b*atan(c*x^2))^3/x^5, x, 8, (-(3/4))*im*b*c^2*(a + b*atan(c*x^2))^2 - (3*b*c*(a + b*atan(c*x^2))^2)/(4*x^2) - (1/4)*c^2*(a + b*atan(c*x^2))^3 - (a + b*atan(c*x^2))^3/(4*x^4) + (3/2)*b^2*c^2*(a + b*atan(c*x^2))*log(2 - 2/(1 - im*c*x^2)) - (3/4)*im*b^3*c^2*PolyLog(2, -1 + 2/(1 - im*c*x^2))]

    #= [x^2*(a + b*atan(c*x^2))^3, x, 86, 0]
    @test_int [x^0*(a + b*atan(c*x^2))^3, x, 69, 0]
    @test_int [(a + b*atan(c*x^2))^3/x^2, x, 47, 0]
    @test_int [(a + b*atan(c*x^2))^3/x^4, x, 64, 0]
    @test_int [(a + b*atan(c*x^2))^3/x^6, x, 77, 0] =#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^2))^p*when*m*symbolic=#

    @test_int [(d*x)^m*(a + b*atan(c*x^2))^3, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x^2))^3, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x^2))^2, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x^2))^2, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x^2))^1, x, 2, ((d*x)^(1 + m)*(a + b*atan(c*x^2)))/(d*(1 + m)) - (2*b*c*(d*x)^(3 + m)*HypergeometricFunctions._₂F₁(1, (3 + m)/4, (7 + m)/4, (-c^2)*x^4))/(d^3*(1 + m)*(3 + m))]
    @test_int [(d*x)^m/(a + b*atan(c*x^2))^1, x, 0, Unintegrable((d*x)^m/(a + b*atan(c*x^2)), x)]
    @test_int [(d*x)^m/(a + b*atan(c*x^2))^2, x, 0, Unintegrable((d*x)^m/(a + b*atan(c*x^2))^2, x)]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^3))^p=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*(a+b*atan(c*x^3))^p=#

    @test_int [x^11*(a + b*atan(c*x^3)), x, 5, (b*x^3)/(12*c^3) - (b*x^9)/(36*c) - (b*atan(c*x^3))/(12*c^4) + (1/12)*x^12*(a + b*atan(c*x^3))]
    @test_int [x^8*(a + b*atan(c*x^3)), x, 4, -((b*x^6)/(18*c)) + (1/9)*x^9*(a + b*atan(c*x^3)) + (b*log(1 + c^2*x^6))/(18*c^3)]
    @test_int [x^5*(a + b*atan(c*x^3)), x, 4, -((b*x^3)/(6*c)) + (b*atan(c*x^3))/(6*c^2) + (1/6)*x^6*(a + b*atan(c*x^3))]
    @test_int [x^2*(a + b*atan(c*x^3)), x, 2, (1/3)*x^3*(a + b*atan(c*x^3)) - (b*log(1 + c^2*x^6))/(6*c)]
    @test_int [(a + b*atan(c*x^3))/x^1, x, 4, a*log(x) + (1/6)*im*b*PolyLog(2, (-im)*c*x^3) - (1/6)*im*b*PolyLog(2, im*c*x^3)]
    @test_int [(a + b*atan(c*x^3))/x^4, x, 5, -((a + b*atan(c*x^3))/(3*x^3)) + b*c*log(x) - (1/6)*b*c*log(1 + c^2*x^6)]
    @test_int [(a + b*atan(c*x^3))/x^7, x, 4, -((b*c)/(6*x^3)) - (1/6)*b*c^2*atan(c*x^3) - (a + b*atan(c*x^3))/(6*x^6)]
    @test_int [(a + b*atan(c*x^3))/x^10, x, 4, -((b*c)/(18*x^6)) - (a + b*atan(c*x^3))/(9*x^9) - (1/3)*b*c^3*log(x) + (1/18)*b*c^3*log(1 + c^2*x^6)]

    @test_int [x^3*(a + b*atan(c*x^3)), x, 12, -((3*b*x)/(4*c)) + (b*atan(c^(1/3)*x))/(4*c^(4/3)) + (1/4)*x^4*(a + b*atan(c*x^3)) - (b*atan(sqrt(3) - 2*c^(1/3)*x))/(8*c^(4/3)) + (b*atan(sqrt(3) + 2*c^(1/3)*x))/(8*c^(4/3)) - (sqrt(3)*b*log(1 - sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(16*c^(4/3)) + (sqrt(3)*b*log(1 + sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(16*c^(4/3))]
    @test_int [x^0*(a + b*atan(c*x^3)), x, 9, a*x + b*x*atan(c*x^3) + (sqrt(3)*b*atan((1 - 2*c^(2/3)*x^2)/sqrt(3)))/(2*c^(1/3)) + (b*log(1 + c^(2/3)*x^2))/(2*c^(1/3)) - (b*log(1 - c^(2/3)*x^2 + c^(4/3)*x^4))/(4*c^(1/3))]
    @test_int [(a + b*atan(c*x^3))/x^3, x, 11, (1/2)*b*c^(2/3)*atan(c^(1/3)*x) - (a + b*atan(c*x^3))/(2*x^2) - (1/4)*b*c^(2/3)*atan(sqrt(3) - 2*c^(1/3)*x) + (1/4)*b*c^(2/3)*atan(sqrt(3) + 2*c^(1/3)*x) - (1/8)*sqrt(3)*b*c^(2/3)*log(1 - sqrt(3)*c^(1/3)*x + c^(2/3)*x^2) + (1/8)*sqrt(3)*b*c^(2/3)*log(1 + sqrt(3)*c^(1/3)*x + c^(2/3)*x^2)]
    @test_int [(a + b*atan(c*x^3))/x^6, x, 9, -((3*b*c)/(10*x^2)) - (a + b*atan(c*x^3))/(5*x^5) + (1/10)*sqrt(3)*b*c^(5/3)*atan((1 - 2*c^(2/3)*x^2)/sqrt(3)) + (1/10)*b*c^(5/3)*log(1 + c^(2/3)*x^2) - (1/20)*b*c^(5/3)*log(1 - c^(2/3)*x^2 + c^(4/3)*x^4)]

    @test_int [x^7*(a + b*atan(c*x^3)), x, 12, -((3*b*x^5)/(40*c)) + (b*atan(c^(1/3)*x))/(8*c^(8/3)) + (1/8)*x^8*(a + b*atan(c*x^3)) - (b*atan(sqrt(3) - 2*c^(1/3)*x))/(16*c^(8/3)) + (b*atan(sqrt(3) + 2*c^(1/3)*x))/(16*c^(8/3)) + (sqrt(3)*b*log(1 - sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(32*c^(8/3)) - (sqrt(3)*b*log(1 + sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(32*c^(8/3))]
    @test_int [x^4*(a + b*atan(c*x^3)), x, 9, -((3*b*x^2)/(10*c)) + (1/5)*x^5*(a + b*atan(c*x^3)) - (sqrt(3)*b*atan((1 - 2*c^(2/3)*x^2)/sqrt(3)))/(10*c^(5/3)) + (b*log(1 + c^(2/3)*x^2))/(10*c^(5/3)) - (b*log(1 - c^(2/3)*x^2 + c^(4/3)*x^4))/(20*c^(5/3))]
    @test_int [x^1*(a + b*atan(c*x^3)), x, 11, -((b*atan(c^(1/3)*x))/(2*c^(2/3))) + (1/2)*x^2*(a + b*atan(c*x^3)) + (b*atan(sqrt(3) - 2*c^(1/3)*x))/(4*c^(2/3)) - (b*atan(sqrt(3) + 2*c^(1/3)*x))/(4*c^(2/3)) - (sqrt(3)*b*log(1 - sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(8*c^(2/3)) + (sqrt(3)*b*log(1 + sqrt(3)*c^(1/3)*x + c^(2/3)*x^2))/(8*c^(2/3))]
    @test_int [(a + b*atan(c*x^3))/x^2, x, 8, -((a + b*atan(c*x^3))/x) - (1/2)*sqrt(3)*b*c^(1/3)*atan((1 - 2*c^(2/3)*x^2)/sqrt(3)) + (1/2)*b*c^(1/3)*log(1 + c^(2/3)*x^2) - (1/4)*b*c^(1/3)*log(1 - c^(2/3)*x^2 + c^(4/3)*x^4)]
    @test_int [(a + b*atan(c*x^3))/x^5, x, 12, -((3*b*c)/(4*x)) - (1/4)*b*c^(4/3)*atan(c^(1/3)*x) - (a + b*atan(c*x^3))/(4*x^4) + (1/8)*b*c^(4/3)*atan(sqrt(3) - 2*c^(1/3)*x) - (1/8)*b*c^(4/3)*atan(sqrt(3) + 2*c^(1/3)*x) - (1/16)*sqrt(3)*b*c^(4/3)*log(1 - sqrt(3)*c^(1/3)*x + c^(2/3)*x^2) + (1/16)*sqrt(3)*b*c^(4/3)*log(1 + sqrt(3)*c^(1/3)*x + c^(2/3)*x^2)]

    @test_int [x^11*(a + b*atan(c*x^3))^2, x, 12, (a*b*x^3)/(6*c^3) + (b^2*x^6)/(36*c^2) + (b^2*x^3*atan(c*x^3))/(6*c^3) - (b*x^9*(a + b*atan(c*x^3)))/(18*c) - (a + b*atan(c*x^3))^2/(12*c^4) + (1/12)*x^12*(a + b*atan(c*x^3))^2 - (b^2*log(1 + c^2*x^6))/(9*c^4)]
    @test_int [x^8*(a + b*atan(c*x^3))^2, x, 10, (b^2*x^3)/(9*c^2) - (b^2*atan(c*x^3))/(9*c^3) - (b*x^6*(a + b*atan(c*x^3)))/(9*c) - (im*(a + b*atan(c*x^3))^2)/(9*c^3) + (1/9)*x^9*(a + b*atan(c*x^3))^2 - (2*b*(a + b*atan(c*x^3))*log(2/(1 + im*c*x^3)))/(9*c^3) - (im*b^2*PolyLog(2, 1 - 2/(1 + im*c*x^3)))/(9*c^3)]
    @test_int [x^5*(a + b*atan(c*x^3))^2, x, 7, -((a*b*x^3)/(3*c)) - (b^2*x^3*atan(c*x^3))/(3*c) + (a + b*atan(c*x^3))^2/(6*c^2) + (1/6)*x^6*(a + b*atan(c*x^3))^2 + (b^2*log(1 + c^2*x^6))/(6*c^2)]
    @test_int [x^2*(a + b*atan(c*x^3))^2, x, 6, (im*(a + b*atan(c*x^3))^2)/(3*c) + (1/3)*x^3*(a + b*atan(c*x^3))^2 + (2*b*(a + b*atan(c*x^3))*log(2/(1 + im*c*x^3)))/(3*c) + (im*b^2*PolyLog(2, 1 - 2/(1 + im*c*x^3)))/(3*c)]
    @test_int [(a + b*atan(c*x^3))^2/x^1, x, 7, (2/3)*(a + b*atan(c*x^3))^2*atanh(1 - 2/(1 + im*c*x^3)) - (1/3)*im*b*(a + b*atan(c*x^3))*PolyLog(2, 1 - 2/(1 + im*c*x^3)) + (1/3)*im*b*(a + b*atan(c*x^3))*PolyLog(2, -1 + 2/(1 + im*c*x^3)) - (1/6)*b^2*PolyLog(3, 1 - 2/(1 + im*c*x^3)) + (1/6)*b^2*PolyLog(3, -1 + 2/(1 + im*c*x^3))]
    @test_int [(a + b*atan(c*x^3))^2/x^4, x, 5, (-(1/3))*im*c*(a + b*atan(c*x^3))^2 - (a + b*atan(c*x^3))^2/(3*x^3) + (2/3)*b*c*(a + b*atan(c*x^3))*log(2 - 2/(1 - im*c*x^3)) - (1/3)*im*b^2*c*PolyLog(2, -1 + 2/(1 - im*c*x^3))]
    @test_int [(a + b*atan(c*x^3))^2/x^7, x, 9, -((b*c*(a + b*atan(c*x^3)))/(3*x^3)) - (1/6)*c^2*(a + b*atan(c*x^3))^2 - (a + b*atan(c*x^3))^2/(6*x^6) + b^2*c^2*log(x) - (1/6)*b^2*c^2*log(1 + c^2*x^6)]
    @test_int [(a + b*atan(c*x^3))^2/x^10, x, 9, -((b^2*c^2)/(9*x^3)) - (1/9)*b^2*c^3*atan(c*x^3) - (b*c*(a + b*atan(c*x^3)))/(9*x^6) + (1/9)*im*c^3*(a + b*atan(c*x^3))^2 - (a + b*atan(c*x^3))^2/(9*x^9) - (2/9)*b*c^3*(a + b*atan(c*x^3))*log(2 - 2/(1 - im*c*x^3)) + (1/9)*im*b^2*c^3*PolyLog(2, -1 + 2/(1 - im*c*x^3))]

    #= [x^3*(a + b*atan(c*x^3))^2, x, 44, 0]
    @test_int [x^0*(a + b*atan(c*x^3))^2, x, 69, 0]
    @test_int [(a + b*atan(c*x^3))^2/x^3, x, 24, 0]
    @test_int [(a + b*atan(c*x^3))^2/x^6, x, 77, 0]

    @test_int [x^1*(a + b*atan(c*x^3))^2, x, 28, 0]
    @test_int [(a + b*atan(c*x^3))^2/x^2, x, 47, 0]
    @test_int [(a + b*atan(c*x^3))^2/x^5, x, 46, 0] =#

    @test_int [x^8*(a + b*atan(c*x^3))^3, x, 13, (a*b^2*x^3)/(3*c^2) + (b^3*x^3*atan(c*x^3))/(3*c^2) - (b*(a + b*atan(c*x^3))^2)/(6*c^3) - (b*x^6*(a + b*atan(c*x^3))^2)/(6*c) - (im*(a + b*atan(c*x^3))^3)/(9*c^3) + (1/9)*x^9*(a + b*atan(c*x^3))^3 - (b*(a + b*atan(c*x^3))^2*log(2/(1 + im*c*x^3)))/(3*c^3) - (b^3*log(1 + c^2*x^6))/(6*c^3) - (im*b^2*(a + b*atan(c*x^3))*PolyLog(2, 1 - 2/(1 + im*c*x^3)))/(3*c^3) - (b^3*PolyLog(3, 1 - 2/(1 + im*c*x^3)))/(6*c^3)]
    @test_int [x^5*(a + b*atan(c*x^3))^3, x, 9, -((im*b*(a + b*atan(c*x^3))^2)/(2*c^2)) - (b*x^3*(a + b*atan(c*x^3))^2)/(2*c) + (a + b*atan(c*x^3))^3/(6*c^2) + (1/6)*x^6*(a + b*atan(c*x^3))^3 - (b^2*(a + b*atan(c*x^3))*log(2/(1 + im*c*x^3)))/c^2 - (im*b^3*PolyLog(2, 1 - 2/(1 + im*c*x^3)))/(2*c^2)]
    @test_int [x^2*(a + b*atan(c*x^3))^3, x, 6, (im*(a + b*atan(c*x^3))^3)/(3*c) + (1/3)*x^3*(a + b*atan(c*x^3))^3 + (b*(a + b*atan(c*x^3))^2*log(2/(1 + im*c*x^3)))/c + (im*b^2*(a + b*atan(c*x^3))*PolyLog(2, 1 - 2/(1 + im*c*x^3)))/c + (b^3*PolyLog(3, 1 - 2/(1 + im*c*x^3)))/(2*c)]
    @test_int [(a + b*atan(c*x^3))^3/x^1, x, 9, (2/3)*(a + b*atan(c*x^3))^3*atanh(1 - 2/(1 + im*c*x^3)) - (1/2)*im*b*(a + b*atan(c*x^3))^2*PolyLog(2, 1 - 2/(1 + im*c*x^3)) + (1/2)*im*b*(a + b*atan(c*x^3))^2*PolyLog(2, -1 + 2/(1 + im*c*x^3)) - (1/2)*b^2*(a + b*atan(c*x^3))*PolyLog(3, 1 - 2/(1 + im*c*x^3)) + (1/2)*b^2*(a + b*atan(c*x^3))*PolyLog(3, -1 + 2/(1 + im*c*x^3)) + (1/4)*im*b^3*PolyLog(4, 1 - 2/(1 + im*c*x^3)) - (1/4)*im*b^3*PolyLog(4, -1 + 2/(1 + im*c*x^3))]
    @test_int [(a + b*atan(c*x^3))^3/x^4, x, 6, (-(1/3))*im*c*(a + b*atan(c*x^3))^3 - (a + b*atan(c*x^3))^3/(3*x^3) + b*c*(a + b*atan(c*x^3))^2*log(2 - 2/(1 - im*c*x^3)) - im*b^2*c*(a + b*atan(c*x^3))*PolyLog(2, -1 + 2/(1 - im*c*x^3)) + (1/2)*b^3*c*PolyLog(3, -1 + 2/(1 - im*c*x^3))]
    @test_int [(a + b*atan(c*x^3))^3/x^7, x, 8, (-(1/2))*im*b*c^2*(a + b*atan(c*x^3))^2 - (b*c*(a + b*atan(c*x^3))^2)/(2*x^3) - (1/6)*c^2*(a + b*atan(c*x^3))^3 - (a + b*atan(c*x^3))^3/(6*x^6) + b^2*c^2*(a + b*atan(c*x^3))*log(2 - 2/(1 - im*c*x^3)) - (1/2)*im*b^3*c^2*PolyLog(2, -1 + 2/(1 - im*c*x^3))]

    #= [x^3*(a + b*atan(c*x^3))^3, x, 44, 0]
    @test_int [x^0*(a + b*atan(c*x^3))^3, x, 69, 0]
    @test_int [(a + b*atan(c*x^3))^3/x^3, x, 24, 0]
    @test_int [(a + b*atan(c*x^3))^3/x^6, x, 77, 0]

    @test_int [x^1*(a + b*atan(c*x^3))^3, x, 28, 0]
    @test_int [(a + b*atan(c*x^3))^3/x^2, x, 47, 0]
    @test_int [(a + b*atan(c*x^3))^3/x^5, x, 46, 0] =#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^3))^p*when*m*symbolic=#

    @test_int [(d*x)^m*(a + b*atan(c*x^3))^3, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x^3))^3, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x^3))^2, x, 0, Unintegrable((d*x)^m*(a + b*atan(c*x^3))^2, x)]
    @test_int [(d*x)^m*(a + b*atan(c*x^3))^1, x, 2, ((d*x)^(1 + m)*(a + b*atan(c*x^3)))/(d*(1 + m)) - (3*b*c*(d*x)^(4 + m)*HypergeometricFunctions._₂F₁(1, (4 + m)/6, (10 + m)/6, (-c^2)*x^6))/(d^4*(1 + m)*(4 + m))]
    @test_int [(d*x)^m/(a + b*atan(c*x^3))^1, x, 0, Unintegrable((d*x)^m/(a + b*atan(c*x^3)), x)]
    @test_int [(d*x)^m/(a + b*atan(c*x^3))^2, x, 0, Unintegrable((d*x)^m/(a + b*atan(c*x^3))^2, x)]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c/x^1))^p=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*(a+b*atan(c/x))^p=#

    @test_int [x^3*(a + b*atan(c/x)), x, 5, (-(1/4))*b*c^3*x + (1/12)*b*c*x^3 + (1/4)*x^4*(a + b*atan(c/x)) + (1/4)*b*c^4*atan(x/c)]
    @test_int [x^2*(a + b*atan(c/x)), x, 5, (1/6)*b*c*x^2 + (1/3)*x^3*(a + b*atan(c/x)) - (1/6)*b*c^3*log(c^2 + x^2)]
    @test_int [x^1*(a + b*atan(c/x)), x, 4, (b*c*x)/2 + (1/2)*x^2*(a + b*atan(c/x)) - (1/2)*b*c^2*atan(x/c)]
    @test_int [x^0*(a + b*atan(c/x)), x, 4, a*x + b*x*atan(c/x) + (1/2)*b*c*log(c^2 + x^2)]
    @test_int [(a + b*atan(c/x))/x^1, x, 4, a*log(x) - (1/2)*im*b*PolyLog(2, -((im*c)/x)) + (1/2)*im*b*PolyLog(2, (im*c)/x)]
    @test_int [(a + b*atan(c/x))/x^2, x, 2, -((a + b*atan(c/x))/x) + (b*log(1 + c^2/x^2))/(2*c)]
    @test_int [(a + b*atan(c/x))/x^3, x, 4, b/(2*c*x) - (a + b*atan(c/x))/(2*x^2) + (b*atan(x/c))/(2*c^2)]
    @test_int [(a + b*atan(c/x))/x^4, x, 5, b/(6*c*x^2) - (a + b*atan(c/x))/(3*x^3) + (b*log(x))/(3*c^3) - (b*log(c^2 + x^2))/(6*c^3)]

    @test_int [x^3*(a + b*atan(c/x))^2, x, 14, (1/12)*b^2*c^2*x^2 - (1/2)*b*c^3*x*(a + b*acot(x/c)) + (1/6)*b*c*x^3*(a + b*acot(x/c)) - (1/4)*c^4*(a + b*acot(x/c))^2 + (1/4)*x^4*(a + b*acot(x/c))^2 - (1/3)*b^2*c^4*log(1 + c^2/x^2) - (2/3)*b^2*c^4*log(x)]
    @test_int [x^2*(a + b*atan(c/x))^2, x, 9, (1/3)*b^2*c^2*x + (1/3)*b^2*c^3*acot(x/c) + (1/3)*b*c*x^2*(a + b*acot(x/c)) - (1/3)*im*c^3*(a + b*acot(x/c))^2 + (1/3)*x^3*(a + b*acot(x/c))^2 + (2/3)*b*c^3*(a + b*acot(x/c))*log(2 - 2/(1 - (im*c)/x)) - (1/3)*im*b^2*c^3*PolyLog(2, -1 + 2/(1 - (im*c)/x))]
    @test_int [x^1*(a + b*atan(c/x))^2, x, 9, b*c*x*(a + b*acot(x/c)) + (1/2)*c^2*(a + b*acot(x/c))^2 + (1/2)*x^2*(a + b*acot(x/c))^2 + (1/2)*b^2*c^2*log(1 + c^2/x^2) + b^2*c^2*log(x)]
    @test_int [x^0*(a + b*atan(c/x))^2, x, 6, im*c*(a + b*acot(x/c))^2 + x*(a + b*acot(x/c))^2 - 2*b*c*(a + b*acot(x/c))*log((2*c)/(c + im*x)) + im*b^2*c*PolyLog(2, 1 - (2*c)/(c + im*x))]
    @test_int [(a + b*atan(c/x))^2/x^1, x, 7, -2*(a + b*acot(x/c))^2*atanh(1 - 2/(1 + (im*c)/x)) + im*b*(a + b*acot(x/c))*PolyLog(2, 1 - 2/(1 + (im*c)/x)) - im*b*(a + b*acot(x/c))*PolyLog(2, -1 + 2/(1 + (im*c)/x)) + (1/2)*b^2*PolyLog(3, 1 - 2/(1 + (im*c)/x)) - (1/2)*b^2*PolyLog(3, -1 + 2/(1 + (im*c)/x))]
    @test_int [(a + b*atan(c/x))^2/x^2, x, 6, -((im*(a + b*acot(x/c))^2)/c) - (a + b*acot(x/c))^2/x - (2*b*(a + b*acot(x/c))*log(2/(1 + (im*c)/x)))/c - (im*b^2*PolyLog(2, 1 - 2/(1 + (im*c)/x)))/c]
    @test_int [(a + b*atan(c/x))^2/x^3, x, 7, (a*b)/(c*x) + (b^2*acot(x/c))/(c*x) - (a + b*acot(x/c))^2/(2*c^2) - (a + b*acot(x/c))^2/(2*x^2) - (b^2*log(1 + c^2/x^2))/(2*c^2)]

    @test_int [x^3*(a + b*atan(c/x))^3, x, 17, (1/4)*b^3*c^3*x + (1/4)*b^3*c^4*acot(x/c) + (1/4)*b^2*c^2*x^2*(a + b*acot(x/c)) - im*b*c^4*(a + b*acot(x/c))^2 - (3/4)*b*c^3*x*(a + b*acot(x/c))^2 + (1/4)*b*c*x^3*(a + b*acot(x/c))^2 - (1/4)*c^4*(a + b*acot(x/c))^3 + (1/4)*x^4*(a + b*acot(x/c))^3 + 2*b^2*c^4*(a + b*acot(x/c))*log(2 - 2/(1 - (im*c)/x)) - im*b^3*c^4*PolyLog(2, -1 + 2/(1 - (im*c)/x))]
    @test_int [x^2*(a + b*atan(c/x))^3, x, 15, b^2*c^2*x*(a + b*acot(x/c)) + (1/2)*b*c^3*(a + b*acot(x/c))^2 + (1/2)*b*c*x^2*(a + b*acot(x/c))^2 - (1/3)*im*c^3*(a + b*acot(x/c))^3 + (1/3)*x^3*(a + b*acot(x/c))^3 + b*c^3*(a + b*acot(x/c))^2*log(2 - 2/(1 - (im*c)/x)) + (1/2)*b^3*c^3*log(1 + c^2/x^2) + b^3*c^3*log(x) - im*b^2*c^3*(a + b*acot(x/c))*PolyLog(2, -1 + 2/(1 - (im*c)/x)) + (1/2)*b^3*c^3*PolyLog(3, -1 + 2/(1 - (im*c)/x))]
    @test_int [x^1*(a + b*atan(c/x))^3, x, 8, (3/2)*im*b*c^2*(a + b*acot(x/c))^2 + (3/2)*b*c*x*(a + b*acot(x/c))^2 + (1/2)*c^2*(a + b*acot(x/c))^3 + (1/2)*x^2*(a + b*acot(x/c))^3 - 3*b^2*c^2*(a + b*acot(x/c))*log(2 - 2/(1 - (im*c)/x)) + (3/2)*im*b^3*c^2*PolyLog(2, -1 + 2/(1 - (im*c)/x))]
    @test_int [x^0*(a + b*atan(c/x))^3, x, 6, im*c*(a + b*acot(x/c))^3 + x*(a + b*acot(x/c))^3 - 3*b*c*(a + b*acot(x/c))^2*log((2*c)/(c + im*x)) + 3*im*b^2*c*(a + b*acot(x/c))*PolyLog(2, 1 - (2*c)/(c + im*x)) - (3/2)*b^3*c*PolyLog(3, 1 - (2*c)/(c + im*x))]
    @test_int [(a + b*atan(c/x))^3/x^1, x, 9, -2*(a + b*acot(x/c))^3*atanh(1 - 2/(1 + (im*c)/x)) + (3/2)*im*b*(a + b*acot(x/c))^2*PolyLog(2, 1 - 2/(1 + (im*c)/x)) - (3/2)*im*b*(a + b*acot(x/c))^2*PolyLog(2, -1 + 2/(1 + (im*c)/x)) + (3/2)*b^2*(a + b*acot(x/c))*PolyLog(3, 1 - 2/(1 + (im*c)/x)) - (3/2)*b^2*(a + b*acot(x/c))*PolyLog(3, -1 + 2/(1 + (im*c)/x)) - (3/4)*im*b^3*PolyLog(4, 1 - 2/(1 + (im*c)/x)) + (3/4)*im*b^3*PolyLog(4, -1 + 2/(1 + (im*c)/x))]
    @test_int [(a + b*atan(c/x))^3/x^2, x, 6, -((im*(a + b*acot(x/c))^3)/c) - (a + b*acot(x/c))^3/x - (3*b*(a + b*acot(x/c))^2*log(2/(1 + (im*c)/x)))/c - (3*im*b^2*(a + b*acot(x/c))*PolyLog(2, 1 - 2/(1 + (im*c)/x)))/c - (3*b^3*PolyLog(3, 1 - 2/(1 + (im*c)/x)))/(2*c)]
    @test_int [(a + b*atan(c/x))^3/x^3, x, 9, (3*im*b*(a + b*acot(x/c))^2)/(2*c^2) + (3*b*(a + b*acot(x/c))^2)/(2*c*x) - (a + b*acot(x/c))^3/(2*c^2) - (a + b*acot(x/c))^3/(2*x^2) + (3*b^2*(a + b*acot(x/c))*log(2/(1 + (im*c)/x)))/c^2 + (3*im*b^3*PolyLog(2, 1 - 2/(1 + (im*c)/x)))/(2*c^2)]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^(n/2)))^p=#

    @test_int [x^2*atan(sqrt(x)), x, 6, -(sqrt(x)/3) + x^(3/2)/9 - x^(5/2)/15 + atan(sqrt(x))/3 + (1/3)*x^3*atan(sqrt(x))]
    @test_int [x^1*atan(sqrt(x)), x, 5, sqrt(x)/2 - x^(3/2)/6 - atan(sqrt(x))/2 + (1/2)*x^2*atan(sqrt(x))]
    @test_int [x^0*atan(sqrt(x)), x, 4, -sqrt(x) + atan(sqrt(x)) + x*atan(sqrt(x))]
    @test_int [atan(sqrt(x))/x^1, x, 4, im*PolyLog(2, (-im)*sqrt(x)) - im*PolyLog(2, im*sqrt(x))]
    @test_int [atan(sqrt(x))/x^2, x, 4, -(1/sqrt(x)) - atan(sqrt(x)) - atan(sqrt(x))/x]
    @test_int [atan(sqrt(x))/x^3, x, 5, -(1/(6*x^(3/2))) + 1/(2*sqrt(x)) + atan(sqrt(x))/2 - atan(sqrt(x))/(2*x^2)]

    @test_int [x^(3/2)*atan(sqrt(x)), x, 3, x/5 - x^2/10 + (2/5)*x^(5/2)*atan(sqrt(x)) - (1/5)*log(1 + x)]
    @test_int [x^(1/2)*atan(sqrt(x)), x, 3, -(x/3) + (2/3)*x^(3/2)*atan(sqrt(x)) + (1/3)*log(1 + x)]
    @test_int [atan(sqrt(x))/x^(1/2), x, 2, 2*sqrt(x)*atan(sqrt(x)) - log(1 + x)]
    @test_int [atan(sqrt(x))/x^(3/2), x, 4, -((2*atan(sqrt(x)))/sqrt(x)) + log(x) - log(1 + x)]
    @test_int [atan(sqrt(x))/x^(5/2), x, 3, -(1/(3*x)) - (2*atan(sqrt(x)))/(3*x^(3/2)) - log(x)/3 + (1/3)*log(1 + x)]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d*x)^m*(a+b*atan(c*x^n))^p=#

    @test_int [atan(a*x^5)/x, x, 4, (1/10)*im*PolyLog(2, (-im)*a*x^5) - (1/10)*im*PolyLog(2, im*a*x^5)]

    @test_int [atan(a*x^n)/x, x, 4, (im*PolyLog(2, (-im)*a*x^n))/(2*n) - (im*PolyLog(2, im*a*x^n))/(2*n)]
    end

max_stars_repo_path: test/5 Inverse trig functions/5.3 Inverse tangent/5.3.2 (d x)^m (a+b arctan(c x^n))^p.jl


text:
function kernel_invocations_syr2k(n)

  reps = parse(Int64, ENV["LAMP_REPS"])

  A = randn(n,n)
  B = randn(n,n)
  C = Symmetric(randn(n,n))

  Benchmarker.add_data(csv, "syr2k_implicit", Benchmarker.measure(reps, syr2k_implicit, A, B, C))
  Benchmarker.add_data(csv, "syr2k_implicit_compact", Benchmarker.measure(reps, syr2k_implicit_compact, A, B, C))
  Benchmarker.add_data(csv, "syr2k_explicit", Benchmarker.measure(reps, syr2k_explicit, A, B, C))
  Benchmarker.add_data(csv, "syr2k_implicit_noup", Benchmarker.measure(reps,syr2k_implicit_noup, A, B))
  Benchmarker.add_data(csv, "syr2k_explicit_noup", Benchmarker.measure(reps,syr2k_explicit_noup, A, B))

  @test(isapprox(syr2k_implicit(A,B,C)[2], Symmetric(syr2k_explicit(A,B,C)[2], :L)))
  @test(isapprox(syr2k_implicit(A,B,C)[2], syr2k_implicit_compact(A,B,C)[2]))
  @test(isapprox(syr2k_implicit_noup(A,B)[2], Symmetric(syr2k_explicit_noup(A,B)[2], :L)))
end

function syr2k_implicit(A::DenseArray{Float64, 2}, B::DenseArray{Float64, 2}, C::Symmetric{Float64})
  result = copy(C)
  start::Float64 = 0.0
  finish::Float64 = 0.0
  Benchmarker.cachescrub()
  Benchmarker.gcscrub()
  start = time_ns()

  result = A * transpose(B) + B * transpose(A) + result

  finish = time_ns()
  return ((finish-start)*1e-9, result)
end

function syr2k_implicit_noup(A::DenseArray{Float64, 2}, B::DenseArray{Float64, 2})
  result = zeros(size(A,1), size(B,1))
  start::Float64 = 0.0
  finish::Float64 = 0.0
  Benchmarker.cachescrub()
  Benchmarker.gcscrub()
  start = time_ns()

  result = A * transpose(B) + B * transpose(A)

  finish = time_ns()
  return ((finish-start)*1e-9, result)
end

function syr2k_implicit_compact(A::DenseArray{Float64, 2}, B::DenseArray{Float64, 2}, C::Symmetric{Float64})
  result = copy(C)
  start::Float64 = 0.0
  finish::Float64 = 0.0
  Benchmarker.cachescrub()
  Benchmarker.gcscrub()
  start = time_ns()

  result += A * transpose(B) + B * transpose(A)

  finish = time_ns()
  return ((finish-start)*1e-9, result)
end

function syr2k_explicit(A::DenseArray{Float64, 2}, B::DenseArray{Float64, 2}, C::Symmetric{Float64})
  result = Matrix(copy(C))
  start::Float64 = 0.0
  finish::Float64 = 0.0
  Benchmarker.cachescrub()
  Benchmarker.gcscrub()
  start = time_ns()

  LinearAlgebra.BLAS.syr2k!('L', 'N', 1.0, A, B, 1.0, result)

  finish = time_ns()
  return ((finish-start)*1e-9, result)
end

function syr2k_explicit_noup(A::DenseArray{Float64, 2}, B::DenseArray{Float64, 2})
  result = zeros(size(A,1), size(B,1))
  start::Float64 = 0.0
  finish::Float64 = 0.0
  Benchmarker.cachescrub()
  Benchmarker.gcscrub()
  start = time_ns()

  LinearAlgebra.BLAS.syr2k!('L', 'N', 1.0, A, B, 0.0, result)

  finish = time_ns()
  return ((finish-start)*1e-9, result)
end


text:
module Hapi

export FileDependency,
       FileDepGroup,
       path,
       params,
       glob_pattern,
       groupdeps,
       build_regex

using FilePaths
using FilePathsBase: /
using Dagger
using ClusterManagers
using ReTest
using Base.PCRE # remove for 1.7 - https://github.com/JuliaLang/julia/pull/37299

@testset "Module Test" begin
    @test true
end

include("filehandling.jl")
include("processhandling.jl")

end # module