text:
to = Systems.towel()
tr = trajectory(to, 5000; Ttr = 10)
u0 = tr[3000]

# With these boxes, in the first 5 steps, the trajectory enters the y and z range
# but not the x range. Therefore it should NOT enter the box. See figure!
εs = [
    SVector(0.05, 0.05, 0.125),
    SVector(0.005, 0.005, 0.025),
]

# Visual guidance
using PyPlot
tr0 = trajectory(to, 5, u0)
fig, axs = subplots(1,3)
comb = ((1, 2), (1, 3), (2, 3))
for i in 1:3
    j, k = comb[i]
    ax = axs[i]
    ax.scatter(tr[:, j], tr[:, k], s = 2, color = "C$(i-1)")
    ax.scatter([u0[j]], [u0[k]], s = 20, color = "k")
    ax.plot(tr0[:, j], tr0[:, k], color = "k")
    for l in 1:length(εs)
        rect = matplotlib.patches.Rectangle(
        u0[[j, k]] .- εs[l][[j, k]], 2εs[l][j], 2εs[l][k],
        alpha = 0.25, color = "k"
        )
        ax.add_artist(rect)
    end
end

ro = Systems.roessler()
u0 = SVector(
    4.705494942754781,
    -10.221120945130545,
    0.06186563933318555,
)

εs = [
    SVector(0.05, 0.05, 0.125),
    SVector(0.005, 0.005, 0.025),
]

εs = sort!(ℯ .^ (-3:0.5:0); rev = true)

using PyPlot
tr0 = trajectory(ro, 50, u0)
fig, axs = subplots(1,3)
comb = ((1, 2), (1, 3), (2, 3))
for i in 1:3
    j, k = comb[i]
    ax = axs[i]
    ax.plot(tr[:, j], tr[:, k], lw = 0.5, color = "C$(i-1)", alpha = 0.5)
    ax.scatter([u0[j]], [u0[k]], s = 20, color = "k")
    ax.plot(tr0[:, j], tr0[:, k], color = "k", lw = 1.0, ls = "--")
    if eltype(εs[1]) <: Vector
        for l in 1:length(εs)
            rect = matplotlib.patches.Rectangle(
            u0[[j, k]] .- εs[l][[j, k]], 2εs[l][j], 2εs[l][k],
            alpha = 0.25, color = "k"
            )
            ax.add_artist(rect)
        end
    else
        for l in 1:length(εs)
            circ = matplotlib.patches.Circle(
                u0[[j, k]], εs[l]; alpha = 0.25, color = "k"
            )
            ax.add_artist(circ)
        end
    end
end

max_stars_repo_name: Datseris/FractalDimension

max_issues_repo_name: Datseris/FractalDimension

max_forks_repo_name: Datseris/FractalDimension


text:
### A Pluto.jl notebook ###
# v0.12.21

using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
    quote
        local el = $(esc(element))
        global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
        el
    end
end

# ╔═╡ ee98f90e-7c5a-11eb-31bf-c396e378e6d9
using DataFrames, Dates, GeoJSON, GeoInterface, Glob, HTTP, JSON, NCDatasets, PlutoUI, PolygonOps, StatsPlots, Statistics

# ╔═╡ 04e64e8c-770d-11eb-200c-6b46ee645dc1
html"<button onclick=present()>Present</button>"

# ╔═╡ 6780f078-76dc-11eb-2e32-ed327bd5859d
md"# Case Study: Impact of the 2019 Midwest Flood on SIF over Illinois"

# ╔═╡ 795da832-76de-11eb-1731-078f75664e89
md"The US Midwest experienced a major flooding event in Spring 2019. Here, we will use TROPOMI and OCO-2 SIF to investigate how the seasonal cycle of photosynthesis has changed in response to the delayed planting.

Further reading:

[NY Times article](https://www.nytimes.com/interactive/2019/09/11/us/midwest-flooding.html)

[Caltech article](https://www.caltech.edu/about/news/flooding-stunted-2019-cropland-growing-season-resulting-more-atmospheric-cosub2sub)

[Yin et al. 2020](https://doi.org/10.1029/2019AV000140)

[Source](https://eric.clst.org/tech/usgeojson/) of the GeoJSON file of US states
"

# ╔═╡ 3bb15b3e-7703-11eb-2395-3760c8750a3a
md"
This notebook uses the functions from the first one with minor modifications.

> We follow the same procedure to load the data from files as in the first notebook, so it will take a moment to loop through all the files."

# ╔═╡ d716d466-770c-11eb-01c4-dda250d53312
md"# Load required packages"

# ╔═╡ beba0132-76f9-11eb-09c4-0f2c50b96500

# ╔═╡ cfe90be2-76f9-11eb-0065-c94a4adb1303
plotly()

# ╔═╡ 08830152-7705-11eb-3032-51b754b5f526
md"# Reading the boundary coordinates"

# ╔═╡ 82b7c122-7705-11eb-039b-d1d99194940c
md"Reading the shapefile containing all US states:"

# ╔═╡ 9f2e54a4-7711-11eb-2016-fbf66af577f0
US_states=GeoJSON.read(String(HTTP.get("https://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_040_00_20m.json").body))

# ╔═╡ 38a3d29a-76ff-11eb-19d3-33482fe4000d
#length(US_states.features)

# ╔═╡ dcc9d15c-76fe-11eb-398a-d5d431aee40e
md"Read the shape of Illinois:"

# ╔═╡ 2bbb67a4-76fe-11eb-2b30-4f7e4dbaab97
begin
	stateNames = []
	for i in 1:length(US_states.features)
		push!(stateNames,US_states.features[i].properties["NAME"])
	end
	#US_states.features[2].properties["NAME"]
	#idxIllinois =
	Illinois = US_states.features[findfirst(stateNames .== "Illinois")[1]].geometry
end

# ╔═╡ 6c7f69ec-76ff-11eb-0aa9-2767374c75ba
plot(Illinois)

# ╔═╡ b1175210-7c89-11eb-15dd-afdb7d469af7
IllinoisLonLat = Tuple.(Illinois.coordinates[1])

# ╔═╡ fe40fcf4-7706-11eb-02c9-e9f8e2e1d59e
md"# Reading Data for Illinois"

# ╔═╡ 3e1f7372-7c99-11eb-249f-bde291b5d012
md"> **The following cells contain slightly modified functions from the first notebook.**"

# ╔═╡ 3f8b6092-7c5b-11eb-39bc-f7e3291e6aac
begin
	getFiles = function(sensor="TROPOMI")
		## TROPOMI:
		if sensor == "TROPOMI"
			sifDataDir = "/net/fluo/data2/data/TROPOMI_SIF740nm/original"
			allFiles = glob("*.nc",sifDataDir)

			FilePattern = "TROPO_SIF_YYYY-MM-DD_*.nc"
			posY = findfirst("YYYY",FilePattern)
			posM = findfirst("MM",FilePattern)
			posD = findfirst("DD",FilePattern)

			allDates=Vector{Date}()
			for file in basename.(allFiles)
				push!(allDates,Date(file[posY]*file[posM]*file[posD], "yyyymmdd"))
			end

		## OCO-2:
		elseif sensor == "OCO-2"
			sifDataDir = "/net/fluo/data1/ftp/data/OCO2/sif_lite_B8100"
			allFiles = glob("*/*/*.nc4",sifDataDir)

			FilePattern = "oco2_LtSIF_YYMMDD*.nc4"
			posY = findfirst("YY",FilePattern)
			posM = findfirst("MM",FilePattern)
			posD = findfirst("DD",FilePattern)

			allDates=Vector{Date}()
			for file in basename.(allFiles)
				push!(allDates,Date("20"*file[posY]*file[posM]*file[posD], "yyyymmdd"))
			end
		end

		return(allFiles, allDates)

	end

	getFileIdx4Year = function(yyyy, allDates)
		startDate = Date(yyyy,1,1)
		stopDate  = Date(yyyy,12,31)
		FileInd = findall(x -> x >= startDate && x <= stopDate, allDates)
		return(FileInd)
	end

end

# ╔═╡ 251b84d0-7c5b-11eb-01eb-93007209c2e8
begin
	## Edited dictionary to load only necessary fields

	getBaseDict = function(sensor="TROPOMI")

		if sensor == "TROPOMI"

		baseDict = JSON.Parser.parse("""
    	    [{
				"basics": {
        		"lat": "lat",
        		"lon": "lon",
				"sif": "sif",
        		"time": "TIME"
				},
				"time_struc": "UTC, seconds since 1970-01-01 00:00:00"
			}]
		""")

		elseif sensor == "OCO-2"

		baseDict = JSON.Parser.parse("""
  	      [{
				"basics": {
  	 	    	"lat": "latitude",
      		  	"lon": "longitude",
				"sif": "SIF_757nm",
				"measurement_mode": "measurement_mode",
       		 	"time": "time"
				},
				"time_struc": "seconds since 1993-1-1 0:0:0"
			}]
		""")
		end

		return(baseDict[1]["basics"])
	end

end

# ╔═╡ d651f31a-7c5b-11eb-3432-21404096f38f
begin

numberNames = function(what::String,nWhat::Int)
	numNames = Vector()
	for x in string.(Vector(1:nWhat))
		push!(numNames,what*x)
	end
	return(numNames)
end

# now return DataFrame of filtered data:
readNCdata = function(NCFiles, baseDict, polyLonLat)

	## strategy:
	##			- collect data for a minimum boundary box
	##			- filter for soundings within polyLonLat and return a data frame

	lons = [x[1] for x in polyLonLat]
	lats = [x[2] for x in polyLonLat]

	##mbr format: lonmin,lonmax,latmin,latmax
	mbr = [minimum(lons),maximum(lons),minimum(lats),maximum(lats)]

	#idxKeys = findall(in(["lon","lat"]).(string.(keys(baseDict))) .== false)

	dfOut = DataFrame()

	for aFile in NCFiles

		dfTmp = DataFrame()
		## check first if the file has any soundings inside the mbr before reading the other variables (? -- TBD)
		#dfTmp.lon = Dataset(aFile)[baseDict["lon"]].var[:]
		#dfTmp.lat = Dataset(aFile)[baseDict["lat"]].var[:]
		#for aKey in string.(keys(baseDict))[idxKeys]

		for aKey in keys(baseDict)
			tmp = Dataset(aFile)[baseDict[aKey]].var[:]
			if length(size(tmp))==1
				dfTmp[!,aKey] = tmp
			else
				## check which dimension is sounding and lat/lon (different for TROPOMI and OCO-2!)
				if size(tmp)[2] > size(tmp)[1]
					extendedKeys=numberNames(aKey,size(tmp)[1])
					for iKey in 1:size(tmp)[1]
						dfTmp[!,extendedKeys[iKey]] = tmp[iKey,:]
					end
				else
					extendedKeys=numberNames(aKey,size(tmp)[2])
					for iKey in 1:size(tmp)[2]
						dfTmp[!,extendedKeys[iKey]] = tmp[:,iKey]
					end
				end
			end
		end

		# filtering:
		filter!("lon" => >=(mbr[1]), dfTmp)
		filter!("lon" => <=(mbr[2]), dfTmp)
		filter!("lat" => >=(mbr[3]), dfTmp)
		filter!("lat" => <=(mbr[4]), dfTmp)

		if size(dfTmp)!=(0,0)
			points = []
			for i in 1:length(dfTmp.lon)
				push!(points, (dfTmp.lon[i],dfTmp.lat[i]) )
			end

			dfTmp.inside = [inpolygon(p, polyLonLat; in=true, on=true, out=false) for p in points]

			filter!("inside" => .==(true), dfTmp)
			## drop	"inside" column:
			select!(dfTmp, Not("inside"))
		end

		# attach to output data frame:
		if size(dfTmp)!=(0,0)
			if size(dfOut)==(0,0)
				dfOut = dfTmp
			else
				append!(dfOut, dfTmp)
			end
		end

	end

	return(dfOut)

end

end

# ╔═╡ 2827c5b4-7c5c-11eb-1886-e323231c7c07
begin
	getOneYear = function(yyyy, polyLonLat::Array{Tuple{Float64,Float64},1}, sensor="TROPOMI")

		allFiles, allDates = getFiles(sensor)
		baseDict = getBaseDict(sensor)
		FileInd  = getFileIdx4Year(yyyy, allDates)

		df = readNCdata(allFiles[FileInd],baseDict,polyLonLat)

		############# Convert time strings to julia's date type
		# TROPOMI:
		if sensor == "TROPOMI"
			df.utc = unix2datetime.(df.time)
		# OCO-2:
		elseif sensor == "OCO-2"
			## Keep or filter the other measurement modes for OCO-2:
			#filter!("measurement_mode" => ==(0), df)
			timeOffset = datetime2unix(DateTime(1993,1,1, 0,0,0))
			df.utc = unix2datetime.(df.time .+ timeOffset)
		end

		# Add also a column with plain days:
		df.Date = Date.(df.utc)

		return(df)
	end

end

# ╔═╡ 72bc1716-770d-11eb-3f50-e91939e494b9
begin
		Illinois2018_TROPOMI = getOneYear(2018, IllinoisLonLat, "TROPOMI")
		Illinois2019_TROPOMI = getOneYear(2019, IllinoisLonLat, "TROPOMI")

		Illinois2018_OCO2 = getOneYear(2018, IllinoisLonLat, "OCO-2")
		Illinois2019_OCO2 = getOneYear(2019, IllinoisLonLat, "OCO-2")
end

# ╔═╡ ad1fecac-7c99-11eb-3033-cbf183d0cdd3
md" Reading two years of TROPOMI & OCO-2 data for Illinois took 163s for me, but it may take longer depending on the performance of your machine."

# ╔═╡ 9ea08f84-770c-11eb-31c7-850f3244c4ff
md"# Temporal Averaging"

# ╔═╡ bed15e68-770d-11eb-16ad-19c4dc89e4d8
md"> Now we see that the 2019 flood had a significant impact on the seasonality of photosynthesis over Illinois!"

# ╔═╡ 72dd46f6-7709-11eb-11e3-b7cccdda854b
begin
	time_slider= @bind n_weeks Slider(1:1:8; default=2)
	md"""
	**Averaging period (weeks):** $(time_slider)
	"""
end

# ╔═╡ 8c89d290-7709-11eb-2537-2db49c3d487b
md"**$(n_weeks) Week(s)** "

# ╔═╡ 46e18090-7708-11eb-0d74-f77ec2e38bc2
begin
#df.Date = Date.(df.utc)

## function returns temporal average (mean, std, n)
tempAv = function(df::DataFrame, nWeeks, what::String)

	# rename the column of interest
	subDF = select(df, what => "what", "Date" => "Date")

	# generate breaks:
	tBreaks = collect(minimum(subDF.Date):Week(nWeeks):maximum(subDF.Date)+Day(1))

	## initialize avTime column:
	subDF.avTime = Array{DateTime, 1}(undef,  size(subDF)[1])

	## populate avTime:
	for i in 1:(length(tBreaks)-1)
			subDF.avTime[findall((subDF.Date .>= tBreaks[i]) .& (subDF.Date .< tBreaks[i+1]))] .= DateTime(tBreaks[i]) .+ (DateTime(tBreaks[i+1]) - DateTime(tBreaks[i])) ./ 2
	end
	## clean-up incomplete time steps:
	filter!("avTime" => >(minimum(tBreaks)), subDF)
	filter!("avTime" => <(maximum(tBreaks)), subDF)

	## generate output
	outDF = combine(groupby(subDF, :avTime), :what => mean)
	rename!(outDF, :what_mean => :mean)
	outDF.sd = combine(groupby(subDF, :avTime), :what => std)[:,2]
	outDF.n   = combine(groupby(subDF, :avTime), :what => length)[:,2]
	#sort!(outDF, :avTime)
	return(outDF)
end

end

# ╔═╡ 0aca52ac-7709-11eb-0414-311256298017
begin
	av2018_TROPOMI = tempAv(Illinois2018_TROPOMI, n_weeks, "sif")
	av2019_TROPOMI = tempAv(Illinois2019_TROPOMI, n_weeks, "sif")

	av2018_OCO2 = tempAv(Illinois2018_OCO2, n_weeks, "sif")
	av2019_OCO2 = tempAv(Illinois2019_OCO2, n_weeks, "sif")

p1 =	plot(Dates.dayofyear.(av2018_TROPOMI.avTime),av2018_TROPOMI.mean; ribbon=av2018_TROPOMI.sd, linewidth=4, label=false, title="TROPOMI")
p1 =	plot!(Dates.dayofyear.(av2019_TROPOMI.avTime),av2019_TROPOMI.mean; ribbon=av2019_TROPOMI.sd, linewidth=4, label=false)

p2 =	plot(Dates.dayofyear.(av2018_OCO2.avTime),av2018_OCO2.mean; ribbon=av2018_OCO2.sd, linewidth=4, label= "2018 mean and sd ("*string(n_weeks)*" weeks)", title="OCO-2")
p2 =	plot!(Dates.dayofyear.(av2019_OCO2.avTime),av2019_OCO2.mean; ribbon=av2019_OCO2.sd, linewidth=4, label= "2019 mean and sd ("*string(n_weeks)*" weeks)")

	plot(p1, p2, layout= (1,2),legend=:top)

end

# ╔═╡ d55bdff0-7c7b-11eb-2017-6f417d68079e

# ╔═╡ Cell order:
# ╟─04e64e8c-770d-11eb-200c-6b46ee645dc1
# ╟─6780f078-76dc-11eb-2e32-ed327bd5859d
# ╟─795da832-76de-11eb-1731-078f75664e89
# ╟─3bb15b3e-7703-11eb-2395-3760c8750a3a
# ╟─d716d466-770c-11eb-01c4-dda250d53312
# ╟─beba0132-76f9-11eb-09c4-0f2c50b96500
# ╠═ee98f90e-7c5a-11eb-31bf-c396e378e6d9
# ╠═cfe90be2-76f9-11eb-0065-c94a4adb1303
# ╟─08830152-7705-11eb-3032-51b754b5f526
# ╟─82b7c122-7705-11eb-039b-d1d99194940c
# ╠═9f2e54a4-7711-11eb-2016-fbf66af577f0
# ╠═38a3d29a-76ff-11eb-19d3-33482fe4000d
# ╟─dcc9d15c-76fe-11eb-398a-d5d431aee40e
# ╠═2bbb67a4-76fe-11eb-2b30-4f7e4dbaab97
# ╠═6c7f69ec-76ff-11eb-0aa9-2767374c75ba
# ╠═b1175210-7c89-11eb-15dd-afdb7d469af7
# ╟─fe40fcf4-7706-11eb-02c9-e9f8e2e1d59e
# ╟─3e1f7372-7c99-11eb-249f-bde291b5d012
# ╟─3f8b6092-7c5b-11eb-39bc-f7e3291e6aac
# ╟─251b84d0-7c5b-11eb-01eb-93007209c2e8
# ╟─d651f31a-7c5b-11eb-3432-21404096f38f
# ╟─2827c5b4-7c5c-11eb-1886-e323231c7c07
# ╠═72bc1716-770d-11eb-3f50-e91939e494b9
# ╟─ad1fecac-7c99-11eb-3033-cbf183d0cdd3
# ╟─9ea08f84-770c-11eb-31c7-850f3244c4ff
# ╟─bed15e68-770d-11eb-16ad-19c4dc89e4d8
# ╟─8c89d290-7709-11eb-2537-2db49c3d487b
# ╟─72dd46f6-7709-11eb-11e3-b7cccdda854b
# ╠═0aca52ac-7709-11eb-0414-311256298017
# ╟─46e18090-7708-11eb-0d74-f77ec2e38bc2
# ╟─d55bdff0-7c7b-11eb-2017-6f417d68079e

ext: jl


text:
### A Pluto.jl notebook ###
# v0.14.1

using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
    quote
        local el = $(esc(element))
        global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
        el
    end
end

# ╔═╡ c743b90b-6514-428f-9db9-84b5e4c91ac2
using Plots

# ╔═╡ faf67a36-cc26-4d26-bccb-6a7021fa57a9
html"
Advection - the Heat Equation

First set N, the number of grid points:"

# ╔═╡ 7da260be-9ceb-11eb-1752-d7a413e34a8b
@bind N html"<input type='range' min='20' max='100' step='5' value='50'>"

# ╔═╡ b92aa438-05d0-4e8c-9e53-e337ffa56616
N

# ╔═╡ 16ee3ed7-fd6d-47b0-a16a-b60fe59256a6
html"Now τ, the time step (set first in ms then divided by 1000):"

# ╔═╡ c956df96-ab01-4e9d-9f93-154e718f7f1f
@bind ms html"<input type='range' min='2' max='20' step='1' value='10'>"

# ╔═╡ d5395ca5-747f-43b0-a815-590e9b407e4b
τ = ms/1000 # seconds

# ╔═╡ c1845d77-3edf-4026-a38f-99263878846b
html"Basic characteristics of the system:"

# ╔═╡ 1ac04409-845e-46e1-bbdb-6fc43e033df5
begin
L = 1.0 							# Size (length) of system
h = L/N 							# Grid spacing
x = -L/2:h:L/2						# Coordinates of grid points
c = 1.0 							# Wave speed
end

# ╔═╡ aba2b1ea-2789-41ef-8566-c92525ee2bb5
html"Setting up periodic boundary conditions:"

# ╔═╡ 19e4e286-141e-41d2-9e67-9818bf1c6ad1
begin
iₚ = cat(2:length(x), 1, dims=1) 				# offset indices in + direction
iₘ = cat(length(x), 1:(length(x)-1), dims=1) 	# offset in - direction
end

# ╔═╡ ce1f8f8a-9c9f-4c5f-8a6d-8eb730102153
html"Step function to perform one differential operation in-place:"

# ╔═╡ b4c6c1f4-1c2b-48ac-b0c4-ec4f5f8ba180
function advectstep!(v::AbstractVector, Δt::Float64=τ; method="lw")
	""" PARAMETERS:
	positional
		v  -> vector to step
		Δt -> time step
		N  -> number of grid points
	keyword
		method -> numerical method to use in step
	"""
	κ::Float64 = -c*Δt/2h
	κ_lw::Float64 = 2κ^2
	# Numerical methods:
	if method == "ftcs" 	# Forward in Time, Centered in Space
		v .= v .+ κ*(v[iₚ] .- v[iₘ])
	elseif method == "lax"  # Lax
		v .= .5*(v[iₚ] .+ v[iₘ]) .+ κ*(v[iₚ] .- v[iₘ])
	elseif method == "lw" 	# Lax-Wendorff
		v .= v .+ κ*(v[iₚ] .- v[iₘ]) .+ κ_lw*(v[iₚ] .+ v[iₘ] .- 2v)
	end
end

# ╔═╡ eed1bd3c-b528-4d2b-8abc-18706ba16f6f
html"Initializing system with a gaussian wavepacket, then plotting:"

# ╔═╡ a49a051a-c2bc-4764-aaea-2843b5db5fc9
begin
σ = 0.1 							# Width of the Gaussian plane
k = π/σ 							# Wave number
a = [cos(k*xᵢ) + ℯ^(-xᵢ^2 / 2σ^2) for xᵢ in x] 	# Initial Condition -> Gaussian
lims = (minimum(a), maximum(a)) 	# ylims for plotting
end

# ╔═╡ 482f0403-aaee-45b4-8183-aa78a8d19b3f
html"A helper function:"

# ╔═╡ 8e8ab513-eba0-45b4-98da-03429066afaf
function reset!(α::Vector)
	α[:] = [cos(k*xᵢ) + ℯ^(-xᵢ^2 / 2σ^2) for xᵢ in x]
end

# ╔═╡ fe1c07ae-700c-41d7-b54f-2b8ee3ea6006
@gif for i ∈ 1:500
	i == 1 && reset!(a)
	advectstep!(a; method="lax")
	plot(x, a, label="t=$(round(τ*i, digits=3)) s", lw=2, ylims=lims,
		title = "Advection of a Wave Packet", xlabel="x", ylabel="T")
end every 6

# ╔═╡ abb2a9f6-a503-4cf2-8e60-51ba1f33872e
html"Maybe we want to visualize this in 3d with time as one axis:"

# ╔═╡ eda18287-b390-48d4-a90c-90101132e8f5
let
a = [cos(k*xᵢ) + ℯ^(-xᵢ^2 / 2σ^2) for xᵢ in x]
# Setting up empty arrays which will be used for plotting
nplots = 100
aplot = zeros(length(x), nplots)
tplot = zeros(nplots)
maxstep = 800
plotstep = maxstep ÷ nplots # -> integer
iplot = 1
for i ∈ 1:maxstep
	if i%plotstep == 1
		aplot[:, iplot] = copy(a)
		tplot[iplot] = i*τ
		iplot += 1
	end
	advectstep!(a; method="lax")
end
surface(tplot, x, aplot, xlabel="Time (s)", ylabel="Position", zlabel="Temperature")
title!("Advection of a Gaussian Wave Packet")
end

# ╔═╡ Cell order:
# ╟─faf67a36-cc26-4d26-bccb-6a7021fa57a9
# ╟─7da260be-9ceb-11eb-1752-d7a413e34a8b
# ╠═b92aa438-05d0-4e8c-9e53-e337ffa56616
# ╟─16ee3ed7-fd6d-47b0-a16a-b60fe59256a6
# ╟─c956df96-ab01-4e9d-9f93-154e718f7f1f
# ╠═d5395ca5-747f-43b0-a815-590e9b407e4b
# ╟─c1845d77-3edf-4026-a38f-99263878846b
# ╠═1ac04409-845e-46e1-bbdb-6fc43e033df5
# ╟─aba2b1ea-2789-41ef-8566-c92525ee2bb5
# ╠═19e4e286-141e-41d2-9e67-9818bf1c6ad1
# ╟─ce1f8f8a-9c9f-4c5f-8a6d-8eb730102153
# ╠═b4c6c1f4-1c2b-48ac-b0c4-ec4f5f8ba180
# ╠═c743b90b-6514-428f-9db9-84b5e4c91ac2
# ╟─eed1bd3c-b528-4d2b-8abc-18706ba16f6f
# ╠═a49a051a-c2bc-4764-aaea-2843b5db5fc9
# ╟─482f0403-aaee-45b4-8183-aa78a8d19b3f
# ╠═8e8ab513-eba0-45b4-98da-03429066afaf
# ╠═fe1c07ae-700c-41d7-b54f-2b8ee3ea6006
# ╟─abb2a9f6-a503-4cf2-8e60-51ba1f33872e
# ╠═eda18287-b390-48d4-a90c-90101132e8f5

max_stars_repo_name: benharmonics/GeneralPhysics

max_issues_repo_name: benharmonics/GeneralPhysics

max_forks_repo_name: benharmonics/GeneralPhysics


text:
# This file is pat of RLinearAlgebra.jl
# 1. Specifies type
# 2. Implements rsubsolve function
# 3. Exports Type

#using LinearAlgebra

"""
    LinSysVecColProjPO <: LinSysVecColProjection

A mutable structure that represents the standard column projection method
    with orthogonalization of the current projection against a set of `m` previous
    projection directions, where `m` is specified by the user.

See Patel, Vivak, Mohammad Jahangoshahi, and Daniel Adrian Maldonado. "An Implicit
    Representation and Iterative Solution of Randomly Sketched Linear Systems."
    SIAM Journal on Matrix Analysis and Applications (2021) 42:2, 800-831.
    https://doi.org/10.1137/19M1259481

# Fields

- `α::Float64`, the relaxation parameter (usually between `0.0` and `2.0`)
- `m::Int64`, the number of previous directions against which to orthogonalize
- `Z::Union{Vector{Vector{Float64}}, Nothing}`, stores the `m` vectors against which the
    current projection is orthogonalized against

Calling `LinSysVecColProjPO()` defaults the relaxation parameter to `1.0`, the memory
    parameter `m` to `5`, and `Z` to `nothing`.
"""
mutable struct LinSysVecColProjPO <: LinSysVecColProjection
    α::Float64
    m::Int64
    Z::Union{Vector{Vector{Float64}}, Nothing}
end
LinSysVecColProjPO() = LinSysVecColProjPO(1.0, 5, nothing)

# Common rsubsolve interface for linear systems
function rsubsolve!(
    type::LinSysVecColProjPO,
    x::AbstractVector,
    samp::Tuple{U,V,W} where {U<:AbstractVector,V<:AbstractArray,W<:Real},
    iter::Int64,
)
    # samp[1] is the search direction
    # samp[2] is the coefficient matrix, A
    # samp[3] is a projection of the residual of normal system, samp[1]' * A' * (A * x - b)

    # Allocate space for orthogonalization set Z
    if iter == 1
        d = length(x)
        type.Z = Vector{Float64}[zeros(Float64, d) for i in 1:type.m]
    end

    # Compute orthogonal complement of A' * A * samp[1] using modified Gram-Schmidt
    u = samp[2]' * (samp[2] * samp[1])
    for z in type.Z
        u = u - dot(z, u) * z
    end

    # Check whether vector u is nearly zero
    nrmUsq = dot(u, u)
    if nrmUsq < eps() * length(x); return nothing; end

    # Otherwise, update iterate
    x .= x - u * (type.α * samp[3] / nrmUsq )

    # Update orthonormal set
    z = u / sqrt(nrmUsq)
    type.Z .= push!(type.Z[2:end], z)

    return nothing
end


text:
using LatticeQCD
using Documenter

makedocs(sitename="LatticeQCD.jl")


text:
function agent_step!(agent::Agents.AbstractAgent, model::Agents.ABM)
    move_agent_random!(agent, model)
    update_socialnorm!(agent, model)
    choose_strategy!(agent, model)
    litter!(agent, model)
    return agent
end

function move_agent_random!(agent::Agents.AbstractAgent, model::Agents.ABM)
    adjacent_places = node_neighbors(agent.pos, model)
    new_position = StatsBase.sample(adjacent_places)
    Agents.move_agent!(agent, new_position, model)
    return agent
end

function update_socialnorm!(agent::Agents.AbstractAgent, model::Agents.ABM)
    neighbor_behavior = [
        i.littering
        for i in Agents.get_node_agents(agent.pos, model)
        if !(i === agent)
    ]
    if length(neighbor_behavior) > 0
        agent.socialnorm = StatsBase.mean(neighbor_behavior)
    else
        agent.socialnorm = 1 - agent.conscientiousness
    end
    return agent
end

function choose_strategy!(agent::Agents.AbstractAgent, model::Agents.ABM)
    weight = compute_weight(agent, model)
    costmatrix = compute_costmatrix(weight, model)
    if (littering_is_dominant(costmatrix))
        agent.littering = true
    elseif (not_littering_is_dominant(costmatrix))
        agent.littering = false
    else
        agent.littering = biased_coin(weight)
    end
    return agent
end

function compute_weight(agent::Agents.AbstractAgent, model::Agents.ABM)
    weight = StatsBase.mean([
        agent.socialnorm,
        1 - agent.conscientiousness
    ])
    for i in 1:model.trash_in_spaces[agent.pos]
        weight = pump(weight)
    end
    return weight
end

function pump(x)
    return tanh(x) / tanh(1)
end

function compute_costmatrix(weight::Float64, model::Agents.ABM)
    costmatrix = (
        [(1 - weight) (1 - weight); weight weight]
        .* model.cost_matrix
    )
    return costmatrix
end

function littering_is_dominant(costmatrix::AbstractArray)
    is_dominant = (
        (costmatrix[1, 1] < costmatrix[2, 1])
        & (costmatrix[1, 2] < costmatrix[2, 2])
    )
    return is_dominant
end

function not_littering_is_dominant(costmatrix::AbstractArray)
    is_dominant = (
        (costmatrix[1, 1] > costmatrix[2, 1])
        & (costmatrix[1, 2] > costmatrix[2, 2])
    )
    return is_dominant
end

function biased_coin(weight::Float64)
    return Random.rand() < weight ? true : false
end

function litter!(agent::Agents.AbstractAgent, model::Agents.ABM)
    if agent.littering
        model.trash_in_spaces[agent.pos] += 1
    end
    return model
end


text:
using Random
using Distributions
outer(x) = x*x'
d = 5
Random.seed!(3)
μ = μ1 = 0.7randn(d)
μ2 = 0.7randn(d)
Σ1 = 0.1*outer(randn(d,d))
Σ2 = 0.2*outer(randn(d,d))
P = (;μ1=μ1, μ2=μ2, Σ1=Σ1 , Σ2=Σ2)

ℓ_(x, P)  = log(0.5pdf(MvNormal(P.μ1, P.Σ1), x)+0.5pdf(MvNormal(P.μ2, P.Σ2), x)) #+ randn()
ℓ(x, P) = ℓ_(x, P)
    # Set the number of samples to draw and warmup iterations
    n_samples, n_adapts = 8_000, 2_000
if true

    # Set the number of samples to draw and warmup iterations
    n_samples, n_adapts = 5_000, 1_500
    ℓ(x, P) = ℓ_(x[1:5], P) + ℓ_(x[6:10], P) +  ℓ_(x[11:15], P)
    μ = [μ1; μ1; μ1]
    d = 3d
end

using AdvancedHMC, Distributions, ForwardDiff

# Choose parameter dimensionality and initial parameter value
D = d; initial_θ = μ

# Define the target distribution
ℓπ(θ) = ℓ(θ, P)

# Define a Hamiltonian system
metric = DiagEuclideanMetric(D)
hamiltonian = Hamiltonian(metric, ℓπ, ForwardDiff)

# Define a leapfrog solver, with initial step size chosen heuristically
initial_ϵ = find_good_stepsize(hamiltonian, initial_θ)
integrator = Leapfrog(initial_ϵ)

# Define an HMC sampler, with the following components
#   - multinomial sampling scheme,
#   - generalised No-U-Turn criteria, and
#   - windowed adaption for step-size and diagonal mass matrix
proposal = AdvancedHMC.NUTS{MultinomialTS, GeneralisedNoUTurn}(integrator)
adaptor = StanHMCAdaptor(MassMatrixAdaptor(metric), StepSizeAdaptor(0.8, integrator))

# Run the sampler to draw samples from the specified Gaussian, where
#   - `samples` will store the samples
#   - `stats` will store diagnostic statistics for each sample
samples, stats = @time sample(hamiltonian, proposal, initial_θ, n_samples, adaptor, n_adapts; progress=true)
r = eachindex(samples)
t = 1:n_samples
x = samples
if true
    using GLMakie
    fig4 = Figure(resolution=(2000,2000))
    e = min(d, 5)
    for i in 1:min(d^2, e^2)
        u = CartesianIndices((e,e))[i]
        if u[1] == u[2]
            GLMakie.scatter(fig4[u[1],u[2]], t[r], getindex.(x, u[1])[r], markersize=0.5)
            lines!(fig4[u[1],u[2]], t[r], fill(μ1[u[1]], length(r)), color=:green)
            lines!(fig4[u[1],u[2]], t[r], fill(μ2[u[1]], length(r)), color=:green)

        else
            GLMakie.scatter(fig4[u[1],u[2]], getindex.(x, u[1])[r],  getindex.(x, u[2])[r], markersize=0.5)
            GLMakie.scatter!(fig4[u[1],u[2]], [
                    μ1[u[1]]
                    μ2[u[1]]
                    ],[
                    μ1[u[2]]
                    μ2[u[2]]
                    ], markersize=5.0, color=:lightgreen)
        end
    end
    display(fig4)
end


text:
module TestCollect

using Test
using LazyGroupBy

@testset begin
    @test collect.(grouped(isodd, [0, 7, 3, 1, 5, 9, 4, 3, 0, 5])) ==
          Dict(false => [0, 4, 0], true => [7, 3, 1, 5, 9, 3, 5])
end

end  # module


text:
module ADN_Coupled_assholes_threshold
export time_series_par
export time_series_eta
export time_series
using Statistics

function infected_c(
    agent_state_1,
    agent_state_2,
    activity_good,
    activity_asshole,
    m,
    mu,
    lambda,
    alpha,
    N_good,
    N_asshole,
    C_1,
    C_2
)

    N = N_good + N_asshole
    AgentStateNext_1 = zeros(Int, N_good)
    AgentStateNext_2 = zeros(Int, N_asshole)
    for k = 1:N_good
        AgentStateNext_1[k] = agent_state_1[k]
    end
    for k = 1:N_asshole
        AgentStateNext_2[k] = agent_state_2[k]
    end

    for k = 1:N_good
        if agent_state_1[k] == 1
            if rand() < mu
                AgentStateNext_1[k] = 2
            end
        end
    end

    for k = 1:N_asshole
        if agent_state_2[k] == 1
            if rand() < mu
                AgentStateNext_2[k] = 2
            end
        end
    end

    # loop over good agents
    for i = 1:N
        # if active
        # choose a random index
        if i <= N_good
            if rand() < activity_good[i]
                for j = 1:m
                    rInt = rand(1:N)

                    if rInt <= N_good

                        # the good active node gets the good neigbor sick
                        if agent_state_1[i] == 1
                            if (
                                (agent_state_1[rInt] == 0) &&
                                (rand() < alpha^2 * lambda)
                            )
                                AgentStateNext_1[rInt] = 1
                            end
                        else
                            # agent_state_1[i] == 0
                            # the good active node gets sick from the good neighbor node
                            if (
                                (agent_state_1[rInt] == 1) &&
                                (rand() < alpha^2 * lambda)
                            )
                                AgentStateNext_1[i] = 1
                            end
                        end
                    else
                        rInt = rInt - N_good
                        if agent_state_1[i] == 1
                            if (
                                (agent_state_2[rInt] == 0) &&
                                (rand() < alpha * lambda)
                            )
                                AgentStateNext_2[rInt] = 1
                            end
                        else
                            # agent_state_1[i] == 1
                            # the good active node gets sick from the good neighbor node
                            if (
                                (agent_state_2[rInt] == 1) &&
                                (rand() < alpha * lambda)
                            )
                                AgentStateNext_1[i] = 1
                            end
                        end

                    end
                end
            end
        else
            i = i - N_good
            if rand() < activity_asshole[i]
                for j = 1:m
                    rInt = rand(1:N)

                    if rInt <= N_good

                        # the good active node gets the good neigbor sick
                        if agent_state_2[i] == 1
                            if (
                                (agent_state_1[rInt] == 0) &&
                                (rand() < alpha * lambda)
                            )
                                AgentStateNext_1[rInt] = 1
                            end
                        else
                            # agent_state_2[i] == 0
                            # the good active node gets sick from the good neighbor node
                            if (
                                (agent_state_1[rInt] == 1) &&
                                (rand() < alpha * lambda)
                            )
                                AgentStateNext_2[i] = 1
                            end
                        end
                    else
                        rInt = rInt - N_good
                        if agent_state_2[i] == 1
                            if ((agent_state_2[rInt] == 0) && (rand() < lambda))
                                AgentStateNext_2[rInt] = 1
                            end
                        else
                            # agent_state_2[i] == 1
                            # the good active node gets sick from the good neighbor node
                            if ((agent_state_2[rInt] == 1) && (rand() < lambda))
                                AgentStateNext_2[i] = 1
                            end
                        end

                    end
                end
            end
        end
    end

    # if ((agent_state_2[rInt] == 0) && (rand() < alpha * lambda))
    #     AgentStateNext_2[rInt] = 1
    # end

    C_1 = C_1 .| .!iszero.(AgentStateNext_1)
    C_2 = C_2 .| .!iszero.(AgentStateNext_2)
    return AgentStateNext_1, AgentStateNext_2, C_1, C_2
end

    function infected_totals(
    tmax,
    activity_good,
    activity_asshole,
    m,
    mu,
    lambda,
    alpha,
    N_good,
    N_asshole,
)
    agent_state_1 = zeros(Int, N_good)
    agent_state_2 = zeros(Int, N_asshole)
    C_1 = agent_state_1
    C_2 = agent_state_2
    # Iend_1 = zeros(tmax)
    for k = 1:100
        agent_state_1[k] = 1
        agent_state_2[k] = 1
    end

    t_window = 0
    time = 0
    for i_time = 1:tmax
        agent_state_1, agent_state_2, C_1, C_2 = infected_c(
            agent_state_1,
            agent_state_2,
            activity_good,
            activity_asshole,
            m,
            mu,
            lambda,
            alpha,
            N_good,
            N_asshole,
            C_1,
            C_2
        )
        time = time + 1

        T = sum([a==1 for a in agent_state_1]) + sum([a==1 for a in  agent_state_2])
        L = (sum(C_1) + sum(C_2)) / (N_good + N_asshole)
        if T < 10 || L > .5
            break
        end
    end
    return time
end

    function parameter_sweep(n_trials, activity, grid)
    N = length(activity)
    proportion = grid[1]
    proportion = 1 - proportion
    # proportion =.1
    lambda = .1
    alpha = .75
    N_assholes = Int(ceil((proportion * N)))
    N_good = N - N_assholes
    activity_asshole = zeros(N_assholes)
    activity_good = zeros(N_good)

    for k = 1:N_good
        activity_good[k] = activity[k]
    end
    for k = 1:N_assholes
        activity_asshole[k] = activity[k + N_good]
    end

    eta_ratio = 1
    mu = 0.1
    # infection rate

    alpha_min = 0.0
    alpha_max = 1
    Lambda = range(alpha_min, stop = alpha_max, length = n_trials)
    Alpha = Lambda
    m = 5
    tmax = 3e3
    total_1 = 0.0
    total_2 = 0.0
    n = 5
    trials = zeros(n)
    for i in 1:n
        extinction = zeros(n_trials)
        for k in 1:n_trials
            extinction[k] = infected_totals(
            tmax,
            eta_ratio * 5 * activity_good,
            5 * activity_asshole,
            m,
            mu,
            Lambda[k],
            alpha,
            N_good,
            N_assholes,
        )

        end
        val, index =  findmax(extinction)
        trials[i] = Lambda[index]

        # if abs(mean(Lambda[end-20:end])-val)>10
        #     trials[i] = Lambda[index]
        # else
        #     trials[i]=n_trials
        # end
    end
    # for k = 1:n_trials
    #     infected_1, i_time = infected_totals(
    #         tmax,
    #         eta_ratio * 5 * activity_good,
    #         5 * activity_asshole,
    #         m,
    #         mu,
    #         lambda,
    #         alpha,
    #         N_good,
    #         N_assholes,
    #     )
    #     total_1 = total_1 + infected_1
    #     total_2 = total_2 + i_time

    # end
    return  mean(trials) # ,total_1 / n_trials
end

end


text:
using RegularizedRegression: ape, medape, describe_goodness_of_fit

@testset "Loss functions" begin

@testset "APE (Absolute Percentage Error)" begin
    @test ape([1.5, 2.0], [1.0, 1.0]) == [0.50, 1.0]
    @test ape([1.5, 2.0, 3.0], [1.0, 1.0, 1.0]) == [0.50, 1.0, 2.0]
end

@testset "MAPE (Mean Absolute Percentage Error)" begin
    @test mape([1.5, 2.0], [1.0, 1.0]) == mean([50.0, 100.0])
    @test mape([1.5, 2.0, 3.0], [1.0, 1.0, 1.0]) == mean([50.0, 100.0, 200.0])
    @test isapprox(mape([1.5, 2.0, 3.0], [1.0, 1.5, 2.0]), mean([50.0, 100.0/3, 50.0]))
end

@testset "MEDAPE (Median Absolute Percentage Error)" begin
    @test medape([1.5, 2.0], [1.0, 1.0]) == median([50.0, 100.0])
    @test medape([1.5, 2.0, 3.0], [1.0, 1.0, 1.0]) == median([50.0, 100.0, 200.0])
end

@testset "MASE (Mean Absolute Scaled Error)" begin
    @test mase([1.5, 2.0, 3.0], [1.0, 1.5, 2.0]) == (0.5+0.5+1.0)/(3.0/2.0 * (0.5 + 0.5))
end

#@testset "R2" begin
#    @test r2([1.5, 2.0, 3.0], [1.0, 1.5, 2.0]) == (1.0 - ()
#end

@testset "describe_goodness_of_fit" begin
    str = describe_goodness_of_fit([1.5, 2.0, 3.0], [1.0, 1.5, 2.0])
    @test typeof(str) <: AbstractString
    @test ismatch(r"MAPE = 44.44%", str)
    @test ismatch(r"MASE = 1.33", str)
    @test ismatch(r"R2 = ", str)

    str_w_adj = describe_goodness_of_fit([1.5, 2.0, 3.0], [1.0, 1.5, 2.0], 1)
    @test ismatch(r"R2adj = ", str_w_adj)
end

end


text:
@testset "4.2.0 (a cos)^m (b trg)^n" begin
    (a, b, c, d, e, f, m, n, p, x, ) = @variables a b c d e f m n p x

    #= ::Package:: =#

    #= ::Title:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x))^m=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x))^n=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*cos(c+d*x)^n=#

    @test_int [cos(a + b*x)^1, x, 1, sin(a + b*x)/b]
    @test_int [cos(a + b*x)^2, x, 2, x/2 + (cos(a + b*x)*sin(a + b*x))/(2*b)]
    @test_int [cos(a + b*x)^3, x, 2, sin(a + b*x)/b - sin(a + b*x)^3/(3*b)]
    @test_int [cos(a + b*x)^4, x, 3, (3*x)/8 + (3*cos(a + b*x)*sin(a + b*x))/(8*b) + (cos(a + b*x)^3*sin(a + b*x))/(4*b)]
    @test_int [cos(a + b*x)^5, x, 2, sin(a + b*x)/b - (2*sin(a + b*x)^3)/(3*b) + sin(a + b*x)^5/(5*b)]
    @test_int [cos(a + b*x)^6, x, 4, (5*x)/16 + (5*cos(a + b*x)*sin(a + b*x))/(16*b) + (5*cos(a + b*x)^3*sin(a + b*x))/(24*b) + (cos(a + b*x)^5*sin(a + b*x))/(6*b)]
    @test_int [cos(a + b*x)^7, x, 2, sin(a + b*x)/b - sin(a + b*x)^3/b + (3*sin(a + b*x)^5)/(5*b) - sin(a + b*x)^7/(7*b)]
    @test_int [cos(a + b*x)^8, x, 5, (35*x)/128 + (35*cos(a + b*x)*sin(a + b*x))/(128*b) + (35*cos(a + b*x)^3*sin(a + b*x))/(192*b) + (7*cos(a + b*x)^5*sin(a + b*x))/(48*b) + (cos(a + b*x)^7*sin(a + b*x))/(8*b)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x))^(n/2)=#

    @test_int [cos(a + b*x)^(7/2), x, 3, (10*Elliptic.F((1/2)*(a + b*x), 2))/(21*b) + (10*sqrt(cos(a + b*x))*sin(a + b*x))/(21*b) + (2*cos(a + b*x)^(5/2)*sin(a + b*x))/(7*b)]
    @test_int [cos(a + b*x)^(5/2), x, 2, (6*Elliptic.E((1/2)*(a + b*x), 2))/(5*b) + (2*cos(a + b*x)^(3/2)*sin(a + b*x))/(5*b)]
    @test_int [cos(a + b*x)^(3/2), x, 2, (2*Elliptic.F((1/2)*(a + b*x), 2))/(3*b) + (2*sqrt(cos(a + b*x))*sin(a + b*x))/(3*b)]
    @test_int [cos(a + b*x)^(1/2), x, 1, (2*Elliptic.E((1/2)*(a + b*x), 2))/b]
    @test_int [1/cos(a + b*x)^(1/2), x, 1, (2*Elliptic.F((1/2)*(a + b*x), 2))/b]
    @test_int [1/cos(a + b*x)^(3/2), x, 2, -((2*Elliptic.E((1/2)*(a + b*x), 2))/b) + (2*sin(a + b*x))/(b*sqrt(cos(a + b*x)))]
    @test_int [1/cos(a + b*x)^(5/2), x, 2, (2*Elliptic.F((1/2)*(a + b*x), 2))/(3*b) + (2*sin(a + b*x))/(3*b*cos(a + b*x)^(3/2))]
    @test_int [1/cos(a + b*x)^(7/2), x, 3, -((6*Elliptic.E((1/2)*(a + b*x), 2))/(5*b)) + (2*sin(a + b*x))/(5*b*cos(a + b*x)^(5/2)) + (6*sin(a + b*x))/(5*b*sqrt(cos(a + b*x)))]

    @test_int [(c*cos(a + b*x))^(7/2), x, 4, (10*c^4*sqrt(cos(a + b*x))*Elliptic.F((1/2)*(a + b*x), 2))/(21*b*sqrt(c*cos(a + b*x))) + (10*c^3*sqrt(c*cos(a + b*x))*sin(a + b*x))/(21*b) + (2*c*(c*cos(a + b*x))^(5/2)*sin(a + b*x))/(7*b)]
    @test_int [(c*cos(a + b*x))^(5/2), x, 3, (6*c^2*sqrt(c*cos(a + b*x))*Elliptic.E((1/2)*(a + b*x), 2))/(5*b*sqrt(cos(a + b*x))) + (2*c*(c*cos(a + b*x))^(3/2)*sin(a + b*x))/(5*b)]
    @test_int [(c*cos(a + b*x))^(3/2), x, 3, (2*c^2*sqrt(cos(a + b*x))*Elliptic.F((1/2)*(a + b*x), 2))/(3*b*sqrt(c*cos(a + b*x))) + (2*c*sqrt(c*cos(a + b*x))*sin(a + b*x))/(3*b)]
    @test_int [(c*cos(a + b*x))^(1/2), x, 2, (2*sqrt(c*cos(a + b*x))*Elliptic.E((1/2)*(a + b*x), 2))/(b*sqrt(cos(a + b*x)))]
    @test_int [1/(c*cos(a + b*x))^(1/2), x, 2, (2*sqrt(cos(a + b*x))*Elliptic.F((1/2)*(a + b*x), 2))/(b*sqrt(c*cos(a + b*x)))]
    @test_int [1/(c*cos(a + b*x))^(3/2), x, 3, -((2*sqrt(c*cos(a + b*x))*Elliptic.E((1/2)*(a + b*x), 2))/(b*c^2*sqrt(cos(a + b*x)))) + (2*sin(a + b*x))/(b*c*sqrt(c*cos(a + b*x)))]
    @test_int [1/(c*cos(a + b*x))^(5/2), x, 3, (2*sqrt(cos(a + b*x))*Elliptic.F((1/2)*(a + b*x), 2))/(3*b*c^2*sqrt(c*cos(a + b*x))) + (2*sin(a + b*x))/(3*b*c*(c*cos(a + b*x))^(3/2))]
    @test_int [1/(c*cos(a + b*x))^(7/2), x, 4, -((6*sqrt(c*cos(a + b*x))*Elliptic.E((1/2)*(a + b*x), 2))/(5*b*c^4*sqrt(cos(a + b*x)))) + (2*sin(a + b*x))/(5*b*c*(c*cos(a + b*x))^(5/2)) + (6*sin(a + b*x))/(5*b*c^3*sqrt(c*cos(a + b*x)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x))^(n/3)=#

    @test_int [cos(a + b*x)^(4/3), x, 1, -((3*cos(a + b*x)^(7/3)*HypergeometricFunctions._₂F₁(1/2, 7/6, 13/6, cos(a + b*x)^2)*sin(a + b*x))/(7*b*sqrt(sin(a + b*x)^2)))]
    @test_int [cos(a + b*x)^(2/3), x, 1, -((3*cos(a + b*x)^(5/3)*HypergeometricFunctions._₂F₁(1/2, 5/6, 11/6, cos(a + b*x)^2)*sin(a + b*x))/(5*b*sqrt(sin(a + b*x)^2)))]
    @test_int [cos(a + b*x)^(1/3), x, 1, -((3*cos(a + b*x)^(4/3)*HypergeometricFunctions._₂F₁(1/2, 2/3, 5/3, cos(a + b*x)^2)*sin(a + b*x))/(4*b*sqrt(sin(a + b*x)^2)))]
    @test_int [1/cos(a + b*x)^(1/3), x, 1, -((3*cos(a + b*x)^(2/3)*HypergeometricFunctions._₂F₁(1/3, 1/2, 4/3, cos(a + b*x)^2)*sin(a + b*x))/(2*b*sqrt(sin(a + b*x)^2)))]
    @test_int [1/cos(a + b*x)^(2/3), x, 1, -((3*cos(a + b*x)^(1/3)*HypergeometricFunctions._₂F₁(1/6, 1/2, 7/6, cos(a + b*x)^2)*sin(a + b*x))/(b*sqrt(sin(a + b*x)^2)))]
    @test_int [1/cos(a + b*x)^(4/3), x, 1, (3*HypergeometricFunctions._₂F₁(-(1/6), 1/2, 5/6, cos(a + b*x)^2)*sin(a + b*x))/(b*cos(a + b*x)^(1/3)*sqrt(sin(a + b*x)^2))]

    @test_int [(c*cos(a + b*x))^(4/3), x, 1, -((3*(c*cos(a + b*x))^(7/3)*HypergeometricFunctions._₂F₁(1/2, 7/6, 13/6, cos(a + b*x)^2)*sin(a + b*x))/(7*b*c*sqrt(sin(a + b*x)^2)))]
    @test_int [(c*cos(a + b*x))^(2/3), x, 1, -((3*(c*cos(a + b*x))^(5/3)*HypergeometricFunctions._₂F₁(1/2, 5/6, 11/6, cos(a + b*x)^2)*sin(a + b*x))/(5*b*c*sqrt(sin(a + b*x)^2)))]
    @test_int [(c*cos(a + b*x))^(1/3), x, 1, -((3*(c*cos(a + b*x))^(4/3)*HypergeometricFunctions._₂F₁(1/2, 2/3, 5/3, cos(a + b*x)^2)*sin(a + b*x))/(4*b*c*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x))^(1/3), x, 1, -((3*(c*cos(a + b*x))^(2/3)*HypergeometricFunctions._₂F₁(1/3, 1/2, 4/3, cos(a + b*x)^2)*sin(a + b*x))/(2*b*c*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x))^(2/3), x, 1, -((3*(c*cos(a + b*x))^(1/3)*HypergeometricFunctions._₂F₁(1/6, 1/2, 7/6, cos(a + b*x)^2)*sin(a + b*x))/(b*c*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x))^(4/3), x, 1, (3*HypergeometricFunctions._₂F₁(-(1/6), 1/2, 5/6, cos(a + b*x)^2)*sin(a + b*x))/(b*c*(c*cos(a + b*x))^(1/3)*sqrt(sin(a + b*x)^2))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x))^n*with*n*symbolic=#

    @test_int [cos(a + b*x)^n, x, 1, -((cos(a + b*x)^(1 + n)*HypergeometricFunctions._₂F₁(1/2, (1 + n)/2, (3 + n)/2, cos(a + b*x)^2)*sin(a + b*x))/(b*(1 + n)*sqrt(sin(a + b*x)^2)))]
    @test_int [(c*cos(a + b*x))^n, x, 1, -(((c*cos(a + b*x))^(1 + n)*HypergeometricFunctions._₂F₁(1/2, (1 + n)/2, (3 + n)/2, cos(a + b*x)^2)*sin(a + b*x))/(b*c*(1 + n)*sqrt(sin(a + b*x)^2)))]

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

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x)^p)^(n/2)*with*p*positive*integer=#

    @test_int [(a*cos(x)^2)^(5/2),x, 4, (8/15)*a^2*sqrt(a*cos(x)^2)*tan(x) + (4/15)*a*(a*cos(x)^2)^(3/2)*tan(x) + (1/5)*(a*cos(x)^2)^(5/2)*tan(x)]
    @test_int [(a*cos(x)^2)^(3/2),x, 3, (2/3)*a*sqrt(a*cos(x)^2)*tan(x) + (1/3)*(a*cos(x)^2)^(3/2)*tan(x)]
    @test_int [(a*cos(x)^2)^(1/2), x, 2, sqrt(a*cos(x)^2)*tan(x)]
    @test_int [1/(a*cos(x)^2)^(1/2), x, 2, (atanh(sin(x))*cos(x))/sqrt(a*cos(x)^2)]
    @test_int [1/(a*cos(x)^2)^(3/2), x, 3, (atanh(sin(x))*cos(x))/(2*a*sqrt(a*cos(x)^2)) + tan(x)/(2*a*sqrt(a*cos(x)^2))]
    @test_int [1/(a*cos(x)^2)^(5/2), x, 4, (3*atanh(sin(x))*cos(x))/(8*a^2*sqrt(a*cos(x)^2)) + tan(x)/(4*a*(a*cos(x)^2)^(3/2)) + (3*tan(x))/(8*a^2*sqrt(a*cos(x)^2))]

    @test_int [(a*cos(x)^3)^(5/2),x, 6, (26*a^2*sqrt(a*cos(x)^3)*Elliptic.F(x/2, 2))/(77*cos(x)^(3/2)) + (78/385)*a^2*cos(x)*sqrt(a*cos(x)^3)*sin(x) + (26/165)*a^2*cos(x)^3*sqrt(a*cos(x)^3)*sin(x) + (2/15)*a^2*cos(x)^5*sqrt(a*cos(x)^3)*sin(x) + (26/77)*a^2*sqrt(a*cos(x)^3)*tan(x)]
    @test_int [(a*cos(x)^3)^(3/2),x, 4, (14*a*sqrt(a*cos(x)^3)*Elliptic.E(x/2, 2))/(15*cos(x)^(3/2)) + (14/45)*a*sqrt(a*cos(x)^3)*sin(x) + (2/9)*a*cos(x)^2*sqrt(a*cos(x)^3)*sin(x)]
    @test_int [(a*cos(x)^3)^(1/2), x, 3, (2*sqrt(a*cos(x)^3)*Elliptic.F(x/2, 2))/(3*cos(x)^(3/2)) + (2/3)*sqrt(a*cos(x)^3)*tan(x)]
    @test_int [1/(a*cos(x)^3)^(1/2), x, 3, -((2*cos(x)^(3/2)*Elliptic.E(x/2, 2))/sqrt(a*cos(x)^3)) + (2*cos(x)*sin(x))/sqrt(a*cos(x)^3)]
    @test_int [1/(a*cos(x)^3)^(3/2),x, 4, (10*cos(x)^(3/2)*Elliptic.F(x/2, 2))/(21*a*sqrt(a*cos(x)^3)) + (10*sin(x))/(21*a*sqrt(a*cos(x)^3)) + (2*sec(x)*tan(x))/(7*a*sqrt(a*cos(x)^3))]
    @test_int [1/(a*cos(x)^3)^(5/2),x, 6, -((154*cos(x)^(3/2)*Elliptic.E(x/2, 2))/(195*a^2*sqrt(a*cos(x)^3))) + (154*cos(x)*sin(x))/(195*a^2*sqrt(a*cos(x)^3)) + (154*tan(x))/(585*a^2*sqrt(a*cos(x)^3)) + (22*sec(x)^2*tan(x))/(117*a^2*sqrt(a*cos(x)^3)) + (2*sec(x)^4*tan(x))/(13*a^2*sqrt(a*cos(x)^3))]

    @test_int [(a*cos(x)^4)^(5/2),x, 7, (63/256)*a^2*x*sqrt(a*cos(x)^4)*sec(x)^2 + (21/128)*a^2*cos(x)*sqrt(a*cos(x)^4)*sin(x) + (21/160)*a^2*cos(x)^3*sqrt(a*cos(x)^4)*sin(x) + (9/80)*a^2*cos(x)^5*sqrt(a*cos(x)^4)*sin(x) + (1/10)*a^2*cos(x)^7*sqrt(a*cos(x)^4)*sin(x) + (63/256)*a^2*sqrt(a*cos(x)^4)*tan(x)]
    @test_int [(a*cos(x)^4)^(3/2),x, 5, (5/16)*a*x*sqrt(a*cos(x)^4)*sec(x)^2 + (5/24)*a*cos(x)*sqrt(a*cos(x)^4)*sin(x) + (1/6)*a*cos(x)^3*sqrt(a*cos(x)^4)*sin(x) + (5/16)*a*sqrt(a*cos(x)^4)*tan(x)]
    @test_int [(a*cos(x)^4)^(1/2), x, 3, (1/2)*x*sqrt(a*cos(x)^4)*sec(x)^2 + (1/2)*sqrt(a*cos(x)^4)*tan(x)]
    @test_int [1/(a*cos(x)^4)^(1/2), x, 3, (cos(x)*sin(x))/sqrt(a*cos(x)^4)]
    @test_int [1/(a*cos(x)^4)^(3/2),x, 3, (cos(x)*sin(x))/(a*sqrt(a*cos(x)^4)) + (2*sin(x)^2*tan(x))/(3*a*sqrt(a*cos(x)^4)) + (sin(x)^2*tan(x)^3)/(5*a*sqrt(a*cos(x)^4))]
    @test_int [1/(a*cos(x)^4)^(5/2),x, 3, (cos(x)*sin(x))/(a^2*sqrt(a*cos(x)^4)) + (4*sin(x)^2*tan(x))/(3*a^2*sqrt(a*cos(x)^4)) + (6*sin(x)^2*tan(x)^3)/(5*a^2*sqrt(a*cos(x)^4)) + (4*sin(x)^2*tan(x)^5)/(7*a^2*sqrt(a*cos(x)^4)) + (sin(x)^2*tan(x)^7)/(9*a^2*sqrt(a*cos(x)^4))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(b*cos(c+d*x)^p)^n=#

    @test_int [(b*cos(c + d*x)^m)^n, x, 2, -((cos(c + d*x)*(b*cos(c + d*x)^m)^n*HypergeometricFunctions._₂F₁(1/2, (1/2)*(1 + m*n), (1/2)*(3 + m*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(1 + m*n)*sqrt(sin(c + d*x)^2)))]

    @test_int [(c*cos(a + b*x)^m)^(5/2), x, 2, -((2*c^2*cos(a + b*x)^(1 + 2*m)*sqrt(c*cos(a + b*x)^m)*HypergeometricFunctions._₂F₁(1/2, (1/4)*(2 + 5*m), (1/4)*(6 + 5*m), cos(a + b*x)^2)*sin(a + b*x))/(b*(2 + 5*m)*sqrt(sin(a + b*x)^2)))]
    @test_int [(c*cos(a + b*x)^m)^(3/2), x, 2, -((2*c*cos(a + b*x)^(1 + m)*sqrt(c*cos(a + b*x)^m)*HypergeometricFunctions._₂F₁(1/2, (1/4)*(2 + 3*m), (3*(2 + m))/4, cos(a + b*x)^2)*sin(a + b*x))/(b*(2 + 3*m)*sqrt(sin(a + b*x)^2)))]
    @test_int [(c*cos(a + b*x)^m)^(1/2), x, 2, -((2*cos(a + b*x)*sqrt(c*cos(a + b*x)^m)*HypergeometricFunctions._₂F₁(1/2, (2 + m)/4, (6 + m)/4, cos(a + b*x)^2)*sin(a + b*x))/(b*(2 + m)*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x)^m)^(1/2), x, 2, -((2*cos(a + b*x)*HypergeometricFunctions._₂F₁(1/2, (2 - m)/4, (6 - m)/4, cos(a + b*x)^2)*sin(a + b*x))/(b*(2 - m)*sqrt(c*cos(a + b*x)^m)*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x)^m)^(3/2), x, 2, -((2*cos(a + b*x)^(1 - m)*HypergeometricFunctions._₂F₁(1/2, (1/4)*(2 - 3*m), (3*(2 - m))/4, cos(a + b*x)^2)*sin(a + b*x))/(b*c*(2 - 3*m)*sqrt(c*cos(a + b*x)^m)*sqrt(sin(a + b*x)^2)))]
    @test_int [1/(c*cos(a + b*x)^m)^(5/2), x, 2, -((2*cos(a + b*x)^(1 - 2*m)*HypergeometricFunctions._₂F₁(1/2, (1/4)*(2 - 5*m), (1/4)*(6 - 5*m), cos(a + b*x)^2)*sin(a + b*x))/(b*c^2*(2 - 5*m)*sqrt(c*cos(a + b*x)^m)*sqrt(sin(a + b*x)^2)))]

    @test_int [(c*cos(a + b*x)^m)^(1/m), x, 2, ((c*cos(a + b*x)^m)^(1/m)*tan(a + b*x))/b]

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

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

    @test_int [(a*(b*cos(c + d*x))^p)^n, x, 2, -((cos(c + d*x)*(a*(b*cos(c + d*x))^p)^n*HypergeometricFunctions._₂F₁(1/2, (1/2)*(1 + n*p), (1/2)*(3 + n*p), cos(c + d*x)^2)*sin(c + d*x))/(d*(1 + n*p)*sqrt(sin(c + d*x)^2)))]

    #= ::Title:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*Trg(e+f*x))^n=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*cos(e+f*x))^n=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*cos(e+f*x))^(n/2)=#

    #= ::Subsubsection::Closed:: =#
    #=n>0=#

    @test_int [cos(c + d*x)^5*sqrt(b*cos(c + d*x)), x, 6, (30*b*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*d*sqrt(b*cos(c + d*x))) + (30*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*b^2*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^4*d)]
    @test_int [cos(c + d*x)^4*sqrt(b*cos(c + d*x)), x, 5, (14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x))) + (14*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*b*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b^3*d)]
    @test_int [cos(c + d*x)^3*sqrt(b*cos(c + d*x)), x, 5, (10*b*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (10*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*b^2*d)]
    @test_int [cos(c + d*x)^2*sqrt(b*cos(c + d*x)), x, 4, (6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x))) + (2*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*b*d)]
    @test_int [cos(c + d*x)^1*sqrt(b*cos(c + d*x)), x, 4, (2*b*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*d)]
    @test_int [cos(c + d*x)^0*sqrt(b*cos(c + d*x)), x, 2, (2*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(d*sqrt(cos(c + d*x)))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^1, x, 3, (2*b*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^2, x, 4, -((2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(d*sqrt(cos(c + d*x)))) + (2*b*sin(c + d*x))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^3, x, 4, (2*b*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b^2*sin(c + d*x))/(3*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^4, x, 5, -((6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x)))) + (2*b^3*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*b*sin(c + d*x))/(5*d*sqrt(b*cos(c + d*x)))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^5, x, 5, (10*b*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (2*b^4*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*b^2*sin(c + d*x))/(21*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sqrt(b*cos(c + d*x))*sec(c + d*x)^6, x, 6, -((14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x)))) + (2*b^5*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*b^3*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*b*sin(c + d*x))/(15*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^4*(b*cos(c + d*x))^(3/2), x, 6, (30*b^2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*d*sqrt(b*cos(c + d*x))) + (30*b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*b*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^3*d)]
    @test_int [cos(c + d*x)^3*(b*cos(c + d*x))^(3/2), x, 5, (14*b*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x))) + (14*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b^2*d)]
    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^(3/2), x, 5, (10*b^2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (10*b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*b*d)]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^(3/2), x, 4, (6*b*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x))) + (2*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*d)]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(3/2), x, 3, (2*b^2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*d)]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^1, x, 3, (2*b*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(d*sqrt(cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^2, x, 3, (2*b^2*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^3, x, 4, -((2*b*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(d*sqrt(cos(c + d*x)))) + (2*b^2*sin(c + d*x))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^4, x, 4, (2*b^2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b^3*sin(c + d*x))/(3*d*(b*cos(c + d*x))^(3/2))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^5, x, 5, -((6*b*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x)))) + (2*b^4*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*b^2*sin(c + d*x))/(5*d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^6, x, 5, (10*b^2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (2*b^5*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*b^3*sin(c + d*x))/(21*d*(b*cos(c + d*x))^(3/2))]
    @test_int [(b*cos(c + d*x))^(3/2)*sec(c + d*x)^7, x, 6, -((14*b*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x)))) + (2*b^6*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*b^4*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*b^2*sin(c + d*x))/(15*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^3*(b*cos(c + d*x))^(5/2), x, 6, (30*b^3*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*d*sqrt(b*cos(c + d*x))) + (30*b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^2*d)]
    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^(5/2), x, 5, (14*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x))) + (14*b*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b*d)]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^(5/2), x, 5, (10*b^3*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (10*b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*d)]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(5/2), x, 3, (6*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x))) + (2*b*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*d)]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^1, x, 4, (2*b^3*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*d)]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^2, x, 3, (2*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(d*sqrt(cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^3, x, 3, (2*b^3*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^4, x, 4, -((2*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(d*sqrt(cos(c + d*x)))) + (2*b^3*sin(c + d*x))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^5, x, 4, (2*b^3*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b^4*sin(c + d*x))/(3*d*(b*cos(c + d*x))^(3/2))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^6, x, 5, -((6*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*d*sqrt(cos(c + d*x)))) + (2*b^5*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*b^3*sin(c + d*x))/(5*d*sqrt(b*cos(c + d*x)))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^7, x, 5, (10*b^3*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (2*b^6*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*b^4*sin(c + d*x))/(21*d*(b*cos(c + d*x))^(3/2))]
    @test_int [(b*cos(c + d*x))^(5/2)*sec(c + d*x)^8, x, 6, -((14*b^2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*d*sqrt(cos(c + d*x)))) + (2*b^7*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*b^5*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*b^3*sin(c + d*x))/(15*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(7/2), x, 4, (10*b^4*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (10*b^3*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*d) + (2*b*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*d)]

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [cos(c + d*x)^6/sqrt(b*cos(c + d*x)), x, 6, (30*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*d*sqrt(b*cos(c + d*x))) + (30*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*b*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*b^3*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^5*d)]
    @test_int [cos(c + d*x)^5/sqrt(b*cos(c + d*x)), x, 5, (14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b*d*sqrt(cos(c + d*x))) + (14*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*b^2*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b^4*d)]
    @test_int [cos(c + d*x)^4/sqrt(b*cos(c + d*x)), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (10*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*b*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*b^3*d)]
    @test_int [cos(c + d*x)^3/sqrt(b*cos(c + d*x)), x, 4, (6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b*d*sqrt(cos(c + d*x))) + (2*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*b^2*d)]
    @test_int [cos(c + d*x)^2/sqrt(b*cos(c + d*x)), x, 4, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*b*d)]
    @test_int [cos(c + d*x)^1/sqrt(b*cos(c + d*x)), x, 3, (2*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(b*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^0/sqrt(b*cos(c + d*x)), x, 2, (2*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^1/sqrt(b*cos(c + d*x)), x, 4, -((2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(b*d*sqrt(cos(c + d*x)))) + (2*sin(c + d*x))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^2/sqrt(b*cos(c + d*x)), x, 4, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*d*sqrt(b*cos(c + d*x))) + (2*b*sin(c + d*x))/(3*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^3/sqrt(b*cos(c + d*x)), x, 5, -((6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b*d*sqrt(cos(c + d*x)))) + (2*b^2*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*sin(c + d*x))/(5*d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^4/sqrt(b*cos(c + d*x)), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*d*sqrt(b*cos(c + d*x))) + (2*b^3*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*b*sin(c + d*x))/(21*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^5/sqrt(b*cos(c + d*x)), x, 6, -((14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b*d*sqrt(cos(c + d*x)))) + (2*b^4*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*b^2*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*sin(c + d*x))/(15*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^7/(b*cos(c + d*x))^(3/2), x, 6, (30*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*b*d*sqrt(b*cos(c + d*x))) + (30*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*b^2*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*b^4*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^6*d)]
    @test_int [cos(c + d*x)^6/(b*cos(c + d*x))^(3/2), x, 5, (14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b^2*d*sqrt(cos(c + d*x))) + (14*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*b^3*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b^5*d)]
    @test_int [cos(c + d*x)^5/(b*cos(c + d*x))^(3/2), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*b*d*sqrt(b*cos(c + d*x))) + (10*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*b^2*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*b^4*d)]
    @test_int [cos(c + d*x)^4/(b*cos(c + d*x))^(3/2), x, 4, (6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b^2*d*sqrt(cos(c + d*x))) + (2*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*b^3*d)]
    @test_int [cos(c + d*x)^3/(b*cos(c + d*x))^(3/2), x, 4, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*b*d*sqrt(b*cos(c + d*x))) + (2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*b^2*d)]
    @test_int [cos(c + d*x)^2/(b*cos(c + d*x))^(3/2), x, 3, (2*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(b^2*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^1/(b*cos(c + d*x))^(3/2), x, 3, (2*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(3/2), x, 3, -((2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(b^2*d*sqrt(cos(c + d*x)))) + (2*sin(c + d*x))/(b*d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^1/(b*cos(c + d*x))^(3/2), x, 4, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*b*d*sqrt(b*cos(c + d*x))) + (2*sin(c + d*x))/(3*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^2/(b*cos(c + d*x))^(3/2), x, 5, -((6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b^2*d*sqrt(cos(c + d*x)))) + (2*b*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*sin(c + d*x))/(5*b*d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^3/(b*cos(c + d*x))^(3/2), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*b*d*sqrt(b*cos(c + d*x))) + (2*b^2*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*sin(c + d*x))/(21*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^4/(b*cos(c + d*x))^(3/2), x, 6, -((14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b^2*d*sqrt(cos(c + d*x)))) + (2*b^3*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*b*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*sin(c + d*x))/(15*b*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^8/(b*cos(c + d*x))^(5/2), x, 6, (30*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(77*b^2*d*sqrt(b*cos(c + d*x))) + (30*sqrt(b*cos(c + d*x))*sin(c + d*x))/(77*b^3*d) + (18*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(77*b^5*d) + (2*(b*cos(c + d*x))^(9/2)*sin(c + d*x))/(11*b^7*d)]
    @test_int [cos(c + d*x)^7/(b*cos(c + d*x))^(5/2), x, 5, (14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b^3*d*sqrt(cos(c + d*x))) + (14*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(45*b^4*d) + (2*(b*cos(c + d*x))^(7/2)*sin(c + d*x))/(9*b^6*d)]
    @test_int [cos(c + d*x)^6/(b*cos(c + d*x))^(5/2), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*b^2*d*sqrt(b*cos(c + d*x))) + (10*sqrt(b*cos(c + d*x))*sin(c + d*x))/(21*b^3*d) + (2*(b*cos(c + d*x))^(5/2)*sin(c + d*x))/(7*b^5*d)]
    @test_int [cos(c + d*x)^5/(b*cos(c + d*x))^(5/2), x, 4, (6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b^3*d*sqrt(cos(c + d*x))) + (2*(b*cos(c + d*x))^(3/2)*sin(c + d*x))/(5*b^4*d)]
    @test_int [cos(c + d*x)^4/(b*cos(c + d*x))^(5/2), x, 4, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*b^2*d*sqrt(b*cos(c + d*x))) + (2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(3*b^3*d)]
    @test_int [cos(c + d*x)^3/(b*cos(c + d*x))^(5/2), x, 3, (2*sqrt(b*cos(c + d*x))*Elliptic.E((c + d*x)/2, 2))/(b^3*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^2/(b*cos(c + d*x))^(5/2), x, 3, (2*sqrt(cos(c + d*x))*Elliptic.F((c + d*x)/2, 2))/(b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^1/(b*cos(c + d*x))^(5/2), x, 4, -((2*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(b^3*d*sqrt(cos(c + d*x)))) + (2*sin(c + d*x))/(b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(5/2), x, 3, (2*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(3*b^2*d*sqrt(b*cos(c + d*x))) + (2*sin(c + d*x))/(3*b*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^1/(b*cos(c + d*x))^(5/2), x, 5, -((6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b^3*d*sqrt(cos(c + d*x)))) + (2*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/2)) + (6*sin(c + d*x))/(5*b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [sec(c + d*x)^2/(b*cos(c + d*x))^(5/2), x, 5, (10*sqrt(cos(c + d*x))*Elliptic.F((1/2)*(c + d*x), 2))/(21*b^2*d*sqrt(b*cos(c + d*x))) + (2*b*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/2)) + (10*sin(c + d*x))/(21*b*d*(b*cos(c + d*x))^(3/2))]
    @test_int [sec(c + d*x)^3/(b*cos(c + d*x))^(5/2), x, 6, -((14*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(15*b^3*d*sqrt(cos(c + d*x)))) + (2*b^2*sin(c + d*x))/(9*d*(b*cos(c + d*x))^(9/2)) + (14*sin(c + d*x))/(45*d*(b*cos(c + d*x))^(5/2)) + (14*sin(c + d*x))/(15*b^2*d*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(7/2), x, 4, -((6*sqrt(b*cos(c + d*x))*Elliptic.E((1/2)*(c + d*x), 2))/(5*b^4*d*sqrt(cos(c + d*x)))) + (2*sin(c + d*x))/(5*b*d*(b*cos(c + d*x))^(5/2)) + (6*sin(c + d*x))/(5*b^3*d*sqrt(b*cos(c + d*x)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^(m/2)*(b*cos(e+f*x))^(n/2)=#

    #= ::Subsubsection::Closed:: =#
    #=n>0=#

    @test_int [cos(c + d*x)^(7/2)*(b*cos(c + d*x))^(1/2), x, 4, (3*x*sqrt(b*cos(c + d*x)))/(8*sqrt(cos(c + d*x))) + (3*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d) + (cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d)]
    @test_int [cos(c + d*x)^(5/2)*(b*cos(c + d*x))^(1/2), x, 3, (sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x))) - (sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(3/2)*(b*cos(c + d*x))^(1/2), x, 3, (x*sqrt(b*cos(c + d*x)))/(2*sqrt(cos(c + d*x))) + (sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d)]
    @test_int [cos(c + d*x)^(1/2)*(b*cos(c + d*x))^(1/2), x, 2, (sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-1/2)*(b*cos(c + d*x))^(1/2), x, 2, (x*sqrt(b*cos(c + d*x)))/sqrt(cos(c + d*x))]
    @test_int [cos(c + d*x)^(-3/2)*(b*cos(c + d*x))^(1/2), x, 2, (atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-5/2)*(b*cos(c + d*x))^(1/2), x, 3, (sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2))]
    @test_int [cos(c + d*x)^(-7/2)*(b*cos(c + d*x))^(1/2), x, 3, (atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(2*d*sqrt(cos(c + d*x))) + (sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d*cos(c + d*x)^(5/2))]
    @test_int [cos(c + d*x)^(-9/2)*(b*cos(c + d*x))^(1/2), x, 3, (sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2)) + (sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*cos(c + d*x)^(7/2))]
    @test_int [cos(c + d*x)^(-11/2)*(b*cos(c + d*x))^(1/2), x, 4, (3*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(8*d*sqrt(cos(c + d*x))) + (sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d*cos(c + d*x)^(9/2)) + (3*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d*cos(c + d*x)^(5/2))]

    @test_int [cos(c + d*x)^(5/2)*(b*cos(c + d*x))^(3/2), x, 4, (3*b*x*sqrt(b*cos(c + d*x)))/(8*sqrt(cos(c + d*x))) + (3*b*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d) + (b*cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d)]
    @test_int [cos(c + d*x)^(3/2)*(b*cos(c + d*x))^(3/2), x, 3, (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x))) - (b*sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(1/2)*(b*cos(c + d*x))^(3/2), x, 3, (b*x*sqrt(b*cos(c + d*x)))/(2*sqrt(cos(c + d*x))) + (b*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d)]
    @test_int [cos(c + d*x)^(-1/2)*(b*cos(c + d*x))^(3/2), x, 2, (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-3/2)*(b*cos(c + d*x))^(3/2), x, 2, (b*x*sqrt(b*cos(c + d*x)))/sqrt(cos(c + d*x))]
    @test_int [cos(c + d*x)^(-5/2)*(b*cos(c + d*x))^(3/2), x, 2, (b*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-7/2)*(b*cos(c + d*x))^(3/2), x, 3, (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2))]
    @test_int [cos(c + d*x)^(-9/2)*(b*cos(c + d*x))^(3/2), x, 3, (b*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(2*d*sqrt(cos(c + d*x))) + (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d*cos(c + d*x)^(5/2))]
    @test_int [cos(c + d*x)^(-11/2)*(b*cos(c + d*x))^(3/2), x, 3, (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2)) + (b*sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*cos(c + d*x)^(7/2))]
    @test_int [cos(c + d*x)^(-13/2)*(b*cos(c + d*x))^(3/2), x, 4, (3*b*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(8*d*sqrt(cos(c + d*x))) + (b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d*cos(c + d*x)^(9/2)) + (3*b*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d*cos(c + d*x)^(5/2))]

    @test_int [cos(c + d*x)^(5/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x))) - (2*b^2*sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(cos(c + d*x))) + (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x)^5)/(5*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(3/2)*(b*cos(c + d*x))^(5/2), x, 4, (3*b^2*x*sqrt(b*cos(c + d*x)))/(8*sqrt(cos(c + d*x))) + (3*b^2*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d) + (b^2*cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d)]
    @test_int [cos(c + d*x)^(1/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x))) - (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-1/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*x*sqrt(b*cos(c + d*x)))/(2*sqrt(cos(c + d*x))) + (b^2*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d)]
    @test_int [cos(c + d*x)^(-3/2)*(b*cos(c + d*x))^(5/2), x, 2, (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-5/2)*(b*cos(c + d*x))^(5/2), x, 2, (b^2*x*sqrt(b*cos(c + d*x)))/sqrt(cos(c + d*x))]
    @test_int [cos(c + d*x)^(-7/2)*(b*cos(c + d*x))^(5/2), x, 2, (b^2*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(d*sqrt(cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-9/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2))]
    @test_int [cos(c + d*x)^(-11/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(2*d*sqrt(cos(c + d*x))) + (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(2*d*cos(c + d*x)^(5/2))]
    @test_int [cos(c + d*x)^(-13/2)*(b*cos(c + d*x))^(5/2), x, 3, (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(d*cos(c + d*x)^(3/2)) + (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x)^3)/(3*d*cos(c + d*x)^(7/2))]
    @test_int [cos(c + d*x)^(-15/2)*(b*cos(c + d*x))^(5/2), x, 4, (3*b^2*atanh(sin(c + d*x))*sqrt(b*cos(c + d*x)))/(8*d*sqrt(cos(c + d*x))) + (b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(4*d*cos(c + d*x)^(9/2)) + (3*b^2*sqrt(b*cos(c + d*x))*sin(c + d*x))/(8*d*cos(c + d*x)^(5/2))]

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [cos(c + d*x)^(11/2)/(b*cos(c + d*x))^(1/2), x, 3, (sqrt(cos(c + d*x))*sin(c + d*x))/(d*sqrt(b*cos(c + d*x))) - (2*sqrt(cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(b*cos(c + d*x))) + (sqrt(cos(c + d*x))*sin(c + d*x)^5)/(5*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(9/2)/(b*cos(c + d*x))^(1/2), x, 4, (3*x*sqrt(cos(c + d*x)))/(8*sqrt(b*cos(c + d*x))) + (3*cos(c + d*x)^(3/2)*sin(c + d*x))/(8*d*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(7/2)*sin(c + d*x))/(4*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(7/2)/(b*cos(c + d*x))^(1/2), x, 3, (sqrt(cos(c + d*x))*sin(c + d*x))/(d*sqrt(b*cos(c + d*x))) - (sqrt(cos(c + d*x))*sin(c + d*x)^3)/(3*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(5/2)/(b*cos(c + d*x))^(1/2), x, 3, (x*sqrt(cos(c + d*x)))/(2*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(3/2)*sin(c + d*x))/(2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(3/2)/(b*cos(c + d*x))^(1/2), x, 2, (sqrt(cos(c + d*x))*sin(c + d*x))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(1/2)/(b*cos(c + d*x))^(1/2), x, 2, (x*sqrt(cos(c + d*x)))/sqrt(b*cos(c + d*x))]
    @test_int [cos(c + d*x)^(-1/2)/(b*cos(c + d*x))^(1/2), x, 2, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-3/2)/(b*cos(c + d*x))^(1/2), x, 3, sin(c + d*x)/(d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-5/2)/(b*cos(c + d*x))^(1/2), x, 3, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(2*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(2*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-7/2)/(b*cos(c + d*x))^(1/2), x, 3, sin(c + d*x)/(d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))) + sin(c + d*x)^3/(3*d*cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-9/2)/(b*cos(c + d*x))^(1/2), x, 4, (3*atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(8*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(4*d*cos(c + d*x)^(7/2)*sqrt(b*cos(c + d*x))) + (3*sin(c + d*x))/(8*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^(11/2)/(b*cos(c + d*x))^(3/2), x, 4, (3*x*sqrt(cos(c + d*x)))/(8*b*sqrt(b*cos(c + d*x))) + (3*cos(c + d*x)^(3/2)*sin(c + d*x))/(8*b*d*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(7/2)*sin(c + d*x))/(4*b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(9/2)/(b*cos(c + d*x))^(3/2), x, 3, (sqrt(cos(c + d*x))*sin(c + d*x))/(b*d*sqrt(b*cos(c + d*x))) - (sqrt(cos(c + d*x))*sin(c + d*x)^3)/(3*b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(7/2)/(b*cos(c + d*x))^(3/2), x, 3, (x*sqrt(cos(c + d*x)))/(2*b*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(3/2)*sin(c + d*x))/(2*b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(5/2)/(b*cos(c + d*x))^(3/2), x, 2, (sqrt(cos(c + d*x))*sin(c + d*x))/(b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(3/2)/(b*cos(c + d*x))^(3/2), x, 2, (x*sqrt(cos(c + d*x)))/(b*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(1/2)/(b*cos(c + d*x))^(3/2), x, 2, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(b*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-1/2)/(b*cos(c + d*x))^(3/2), x, 3, sin(c + d*x)/(b*d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-3/2)/(b*cos(c + d*x))^(3/2), x, 3, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(2*b*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(2*b*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-5/2)/(b*cos(c + d*x))^(3/2), x, 3, sin(c + d*x)/(b*d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))) + sin(c + d*x)^3/(3*b*d*cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-7/2)/(b*cos(c + d*x))^(3/2), x, 4, (3*atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(8*b*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(4*b*d*cos(c + d*x)^(7/2)*sqrt(b*cos(c + d*x))) + (3*sin(c + d*x))/(8*b*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]

    @test_int [cos(c + d*x)^(13/2)/(b*cos(c + d*x))^(5/2), x, 4, (3*x*sqrt(cos(c + d*x)))/(8*b^2*sqrt(b*cos(c + d*x))) + (3*cos(c + d*x)^(3/2)*sin(c + d*x))/(8*b^2*d*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(7/2)*sin(c + d*x))/(4*b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(11/2)/(b*cos(c + d*x))^(5/2), x, 3, (sqrt(cos(c + d*x))*sin(c + d*x))/(b^2*d*sqrt(b*cos(c + d*x))) - (sqrt(cos(c + d*x))*sin(c + d*x)^3)/(3*b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(9/2)/(b*cos(c + d*x))^(5/2), x, 3, (x*sqrt(cos(c + d*x)))/(2*b^2*sqrt(b*cos(c + d*x))) + (cos(c + d*x)^(3/2)*sin(c + d*x))/(2*b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(7/2)/(b*cos(c + d*x))^(5/2), x, 2, (sqrt(cos(c + d*x))*sin(c + d*x))/(b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(5/2)/(b*cos(c + d*x))^(5/2), x, 2, (x*sqrt(cos(c + d*x)))/(b^2*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(3/2)/(b*cos(c + d*x))^(5/2), x, 2, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(b^2*d*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(1/2)/(b*cos(c + d*x))^(5/2), x, 3, sin(c + d*x)/(b^2*d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-1/2)/(b*cos(c + d*x))^(5/2), x, 3, (atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(2*b^2*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(2*b^2*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-3/2)/(b*cos(c + d*x))^(5/2), x, 3, sin(c + d*x)/(b^2*d*sqrt(cos(c + d*x))*sqrt(b*cos(c + d*x))) + sin(c + d*x)^3/(3*b^2*d*cos(c + d*x)^(5/2)*sqrt(b*cos(c + d*x)))]
    @test_int [cos(c + d*x)^(-5/2)/(b*cos(c + d*x))^(5/2), x, 4, (3*atanh(sin(c + d*x))*sqrt(cos(c + d*x)))/(8*b^2*d*sqrt(b*cos(c + d*x))) + sin(c + d*x)/(4*b^2*d*cos(c + d*x)^(7/2)*sqrt(b*cos(c + d*x))) + (3*sin(c + d*x))/(8*b^2*d*cos(c + d*x)^(3/2)*sqrt(b*cos(c + d*x)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*cos(e+f*x))^(n/3)=#

    #= ::Subsubsection::Closed:: =#
    #=n>0=#

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

    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^(1/3), x, 2, -((3*(b*cos(c + d*x))^(10/3)*HypergeometricFunctions._₂F₁(1/2, 5/3, 8/3, cos(c + d*x)^2)*sin(c + d*x))/(10*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^(1/3), x, 2, -((3*(b*cos(c + d*x))^(7/3)*HypergeometricFunctions._₂F₁(1/2, 7/6, 13/6, cos(c + d*x)^2)*sin(c + d*x))/(7*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(1/3), x, 1, -((3*(b*cos(c + d*x))^(4/3)*HypergeometricFunctions._₂F₁(1/2, 2/3, 5/3, cos(c + d*x)^2)*sin(c + d*x))/(4*b*d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(1/3)*sec(c + d*x)^1, x, 2, -((3*(b*cos(c + d*x))^(1/3)*HypergeometricFunctions._₂F₁(1/6, 1/2, 7/6, cos(c + d*x)^2)*sin(c + d*x))/(d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(1/3)*sec(c + d*x)^2, x, 2, (3*b*HypergeometricFunctions._₂F₁(-(1/3), 1/2, 2/3, cos(c + d*x)^2)*sin(c + d*x))/(2*d*(b*cos(c + d*x))^(2/3)*sqrt(sin(c + d*x)^2))]
    @test_int [(b*cos(c + d*x))^(1/3)*sec(c + d*x)^3, x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(5/6), 1/2, 1/6, cos(c + d*x)^2)*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/3)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^m*(b*cos(c + d*x))^(2/3), x, 2, -((3*cos(c + d*x)^(1 + m)*(b*cos(c + d*x))^(2/3)*HypergeometricFunctions._₂F₁(1/2, (1/6)*(5 + 3*m), (1/6)*(11 + 3*m), cos(c + d*x)^2)*sin(c + d*x))/(d*(5 + 3*m)*sqrt(sin(c + d*x)^2)))]

    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^(2/3), x, 2, -((3*(b*cos(c + d*x))^(11/3)*HypergeometricFunctions._₂F₁(1/2, 11/6, 17/6, cos(c + d*x)^2)*sin(c + d*x))/(11*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^(2/3), x, 2, -((3*(b*cos(c + d*x))^(8/3)*HypergeometricFunctions._₂F₁(1/2, 4/3, 7/3, cos(c + d*x)^2)*sin(c + d*x))/(8*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(2/3), x, 1, -((3*(b*cos(c + d*x))^(5/3)*HypergeometricFunctions._₂F₁(1/2, 5/6, 11/6, cos(c + d*x)^2)*sin(c + d*x))/(5*b*d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(2/3)*sec(c + d*x)^1, x, 2, -((3*(b*cos(c + d*x))^(2/3)*HypergeometricFunctions._₂F₁(1/3, 1/2, 4/3, cos(c + d*x)^2)*sin(c + d*x))/(2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(2/3)*sec(c + d*x)^2, x, 2, (3*b*HypergeometricFunctions._₂F₁(-(1/6), 1/2, 5/6, cos(c + d*x)^2)*sin(c + d*x))/(d*(b*cos(c + d*x))^(1/3)*sqrt(sin(c + d*x)^2))]
    @test_int [(b*cos(c + d*x))^(2/3)*sec(c + d*x)^3, x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(2/3), 1/2, 1/3, cos(c + d*x)^2)*sin(c + d*x))/(4*d*(b*cos(c + d*x))^(4/3)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^m*(b*cos(c + d*x))^(4/3), x, 2, -((3*b*cos(c + d*x)^(2 + m)*(b*cos(c + d*x))^(1/3)*HypergeometricFunctions._₂F₁(1/2, (1/6)*(7 + 3*m), (1/6)*(13 + 3*m), cos(c + d*x)^2)*sin(c + d*x))/(d*(7 + 3*m)*sqrt(sin(c + d*x)^2)))]

    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^(4/3), x, 2, -((3*(b*cos(c + d*x))^(13/3)*HypergeometricFunctions._₂F₁(1/2, 13/6, 19/6, cos(c + d*x)^2)*sin(c + d*x))/(13*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^(4/3), x, 2, -((3*(b*cos(c + d*x))^(10/3)*HypergeometricFunctions._₂F₁(1/2, 5/3, 8/3, cos(c + d*x)^2)*sin(c + d*x))/(10*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^(4/3), x, 1, -((3*(b*cos(c + d*x))^(7/3)*HypergeometricFunctions._₂F₁(1/2, 7/6, 13/6, cos(c + d*x)^2)*sin(c + d*x))/(7*b*d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(4/3)*sec(c + d*x)^1, x, 2, -((3*(b*cos(c + d*x))^(4/3)*HypergeometricFunctions._₂F₁(1/2, 2/3, 5/3, cos(c + d*x)^2)*sin(c + d*x))/(4*d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(4/3)*sec(c + d*x)^2, x, 2, -((3*b*(b*cos(c + d*x))^(1/3)*HypergeometricFunctions._₂F₁(1/6, 1/2, 7/6, cos(c + d*x)^2)*sin(c + d*x))/(d*sqrt(sin(c + d*x)^2)))]
    @test_int [(b*cos(c + d*x))^(4/3)*sec(c + d*x)^3, x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(1/3), 1/2, 2/3, cos(c + d*x)^2)*sin(c + d*x))/(2*d*(b*cos(c + d*x))^(2/3)*sqrt(sin(c + d*x)^2))]

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [cos(c + d*x)^m/(b*cos(c + d*x))^(1/3), x, 2, -((3*cos(c + d*x)^(1 + m)*HypergeometricFunctions._₂F₁(1/2, (1/6)*(2 + 3*m), (1/6)*(8 + 3*m), cos(c + d*x)^2)*sin(c + d*x))/(d*(2 + 3*m)*(b*cos(c + d*x))^(1/3)*sqrt(sin(c + d*x)^2)))]

    @test_int [cos(c + d*x)^2/(b*cos(c + d*x))^(1/3), x, 2, -((3*(b*cos(c + d*x))^(8/3)*HypergeometricFunctions._₂F₁(1/2, 4/3, 7/3, cos(c + d*x)^2)*sin(c + d*x))/(8*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1/(b*cos(c + d*x))^(1/3), x, 2, -((3*(b*cos(c + d*x))^(5/3)*HypergeometricFunctions._₂F₁(1/2, 5/6, 11/6, cos(c + d*x)^2)*sin(c + d*x))/(5*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(1/3), x, 1, -((3*(b*cos(c + d*x))^(2/3)*HypergeometricFunctions._₂F₁(1/3, 1/2, 4/3, cos(c + d*x)^2)*sin(c + d*x))/(2*b*d*sqrt(sin(c + d*x)^2)))]
    @test_int [sec(c + d*x)^1/(b*cos(c + d*x))^(1/3), x, 2, (3*HypergeometricFunctions._₂F₁(-(1/6), 1/2, 5/6, cos(c + d*x)^2)*sin(c + d*x))/(d*(b*cos(c + d*x))^(1/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^2/(b*cos(c + d*x))^(1/3), x, 2, (3*b*HypergeometricFunctions._₂F₁(-(2/3), 1/2, 1/3, cos(c + d*x)^2)*sin(c + d*x))/(4*d*(b*cos(c + d*x))^(4/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^3/(b*cos(c + d*x))^(1/3), x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(7/6), 1/2, -(1/6), cos(c + d*x)^2)*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/3)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^m/(b*cos(c + d*x))^(2/3), x, 2, -((3*cos(c + d*x)^(1 + m)*HypergeometricFunctions._₂F₁(1/2, (1/6)*(1 + 3*m), (1/6)*(7 + 3*m), cos(c + d*x)^2)*sin(c + d*x))/(d*(1 + 3*m)*(b*cos(c + d*x))^(2/3)*sqrt(sin(c + d*x)^2)))]

    @test_int [cos(c + d*x)^2/(b*cos(c + d*x))^(2/3), x, 2, -((3*(b*cos(c + d*x))^(7/3)*HypergeometricFunctions._₂F₁(1/2, 7/6, 13/6, cos(c + d*x)^2)*sin(c + d*x))/(7*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1/(b*cos(c + d*x))^(2/3), x, 2, -((3*(b*cos(c + d*x))^(4/3)*HypergeometricFunctions._₂F₁(1/2, 2/3, 5/3, cos(c + d*x)^2)*sin(c + d*x))/(4*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(2/3), x, 1, -((3*(b*cos(c + d*x))^(1/3)*HypergeometricFunctions._₂F₁(1/6, 1/2, 7/6, cos(c + d*x)^2)*sin(c + d*x))/(b*d*sqrt(sin(c + d*x)^2)))]
    @test_int [sec(c + d*x)^1/(b*cos(c + d*x))^(2/3), x, 2, (3*HypergeometricFunctions._₂F₁(-(1/3), 1/2, 2/3, cos(c + d*x)^2)*sin(c + d*x))/(2*d*(b*cos(c + d*x))^(2/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^2/(b*cos(c + d*x))^(2/3), x, 2, (3*b*HypergeometricFunctions._₂F₁(-(5/6), 1/2, 1/6, cos(c + d*x)^2)*sin(c + d*x))/(5*d*(b*cos(c + d*x))^(5/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^3/(b*cos(c + d*x))^(2/3), x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(4/3), 1/2, -(1/3), cos(c + d*x)^2)*sin(c + d*x))/(8*d*(b*cos(c + d*x))^(8/3)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^m/(b*cos(c + d*x))^(4/3), x, 2, (3*cos(c + d*x)^m*HypergeometricFunctions._₂F₁(1/2, (1/6)*(-1 + 3*m), (1/6)*(5 + 3*m), cos(c + d*x)^2)*sin(c + d*x))/(b*d*(1 - 3*m)*(b*cos(c + d*x))^(1/3)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^2/(b*cos(c + d*x))^(4/3), x, 2, -((3*(b*cos(c + d*x))^(5/3)*HypergeometricFunctions._₂F₁(1/2, 5/6, 11/6, cos(c + d*x)^2)*sin(c + d*x))/(5*b^3*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1/(b*cos(c + d*x))^(4/3), x, 2, -((3*(b*cos(c + d*x))^(2/3)*HypergeometricFunctions._₂F₁(1/3, 1/2, 4/3, cos(c + d*x)^2)*sin(c + d*x))/(2*b^2*d*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0/(b*cos(c + d*x))^(4/3), x, 1, (3*HypergeometricFunctions._₂F₁(-(1/6), 1/2, 5/6, cos(c + d*x)^2)*sin(c + d*x))/(b*d*(b*cos(c + d*x))^(1/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^1/(b*cos(c + d*x))^(4/3), x, 2, (3*HypergeometricFunctions._₂F₁(-(2/3), 1/2, 1/3, cos(c + d*x)^2)*sin(c + d*x))/(4*d*(b*cos(c + d*x))^(4/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^2/(b*cos(c + d*x))^(4/3), x, 2, (3*b*HypergeometricFunctions._₂F₁(-(7/6), 1/2, -(1/6), cos(c + d*x)^2)*sin(c + d*x))/(7*d*(b*cos(c + d*x))^(7/3)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^3/(b*cos(c + d*x))^(4/3), x, 2, (3*b^2*HypergeometricFunctions._₂F₁(-(5/3), 1/2, -(2/3), cos(c + d*x)^2)*sin(c + d*x))/(10*d*(b*cos(c + d*x))^(10/3)*sqrt(sin(c + d*x)^2))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*cos(e+f*x))^n*with*n*symbolic=#

    @test_int [(a*cos(e + f*x))^m*(b*cos(e + f*x))^n, x, 2, -(((a*cos(e + f*x))^(1 + m)*(b*cos(e + f*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/2)*(1 + m + n), (1/2)*(3 + m + n), cos(e + f*x)^2)*sin(e + f*x))/(a*f*(1 + m + n)*sqrt(sin(e + f*x)^2)))]

    @test_int [cos(c + d*x)^2*(b*cos(c + d*x))^n, x, 2, -(((b*cos(c + d*x))^(3 + n)*HypergeometricFunctions._₂F₁(1/2, (3 + n)/2, (5 + n)/2, cos(c + d*x)^2)*sin(c + d*x))/(b^3*d*(3 + n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^1*(b*cos(c + d*x))^n, x, 2, -(((b*cos(c + d*x))^(2 + n)*HypergeometricFunctions._₂F₁(1/2, (2 + n)/2, (4 + n)/2, cos(c + d*x)^2)*sin(c + d*x))/(b^2*d*(2 + n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^0*(b*cos(c + d*x))^n, x, 1, -(((b*cos(c + d*x))^(1 + n)*HypergeometricFunctions._₂F₁(1/2, (1 + n)/2, (3 + n)/2, cos(c + d*x)^2)*sin(c + d*x))/(b*d*(1 + n)*sqrt(sin(c + d*x)^2)))]
    @test_int [sec(c + d*x)^1*(b*cos(c + d*x))^n, x, 2, -(((b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, n/2, (2 + n)/2, cos(c + d*x)^2)*sin(c + d*x))/(d*n*sqrt(sin(c + d*x)^2)))]
    @test_int [sec(c + d*x)^2*(b*cos(c + d*x))^n, x, 2, (b*(b*cos(c + d*x))^(-1 + n)*HypergeometricFunctions._₂F₁(1/2, (1/2)*(-1 + n), (1 + n)/2, cos(c + d*x)^2)*sin(c + d*x))/(d*(1 - n)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^3*(b*cos(c + d*x))^n, x, 2, (b^2*(b*cos(c + d*x))^(-2 + n)*HypergeometricFunctions._₂F₁(1/2, (1/2)*(-2 + n), n/2, cos(c + d*x)^2)*sin(c + d*x))/(d*(2 - n)*sqrt(sin(c + d*x)^2))]
    @test_int [sec(c + d*x)^4*(b*cos(c + d*x))^n, x, 2, (b^3*(b*cos(c + d*x))^(-3 + n)*HypergeometricFunctions._₂F₁(1/2, (1/2)*(-3 + n), (1/2)*(-1 + n), cos(c + d*x)^2)*sin(c + d*x))/(d*(3 - n)*sqrt(sin(c + d*x)^2))]

    @test_int [cos(c + d*x)^(5/2)*(b*cos(c + d*x))^n, x, 2, -((2*cos(c + d*x)^(7/2)*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(7 + 2*n), (1/4)*(11 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(7 + 2*n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^(3/2)*(b*cos(c + d*x))^n, x, 2, -((2*cos(c + d*x)^(5/2)*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(5 + 2*n), (1/4)*(9 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(5 + 2*n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^(1/2)*(b*cos(c + d*x))^n, x, 2, -((2*cos(c + d*x)^(3/2)*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(3 + 2*n), (1/4)*(7 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(3 + 2*n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^(-1/2)*(b*cos(c + d*x))^n, x, 2, -((2*sqrt(cos(c + d*x))*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(1 + 2*n), (1/4)*(5 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(1 + 2*n)*sqrt(sin(c + d*x)^2)))]
    @test_int [cos(c + d*x)^(-3/2)*(b*cos(c + d*x))^n, x, 2, (2*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(-1 + 2*n), (1/4)*(3 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(1 - 2*n)*sqrt(cos(c + d*x))*sqrt(sin(c + d*x)^2))]
    @test_int [cos(c + d*x)^(-5/2)*(b*cos(c + d*x))^n, x, 2, (2*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(-3 + 2*n), (1/4)*(1 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(3 - 2*n)*cos(c + d*x)^(3/2)*sqrt(sin(c + d*x)^2))]
    @test_int [cos(c + d*x)^(-7/2)*(b*cos(c + d*x))^n, x, 2, (2*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(-5 + 2*n), (1/4)*(-1 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(5 - 2*n)*cos(c + d*x)^(5/2)*sqrt(sin(c + d*x)^2))]
    @test_int [cos(c + d*x)^(-9/2)*(b*cos(c + d*x))^n, x, 2, (2*(b*cos(c + d*x))^n*HypergeometricFunctions._₂F₁(1/2, (1/4)*(-7 + 2*n), (1/4)*(-3 + 2*n), cos(c + d*x)^2)*sin(c + d*x))/(d*(7 - 2*n)*cos(c + d*x)^(7/2)*sqrt(sin(c + d*x)^2))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*sec(e+f*x))^n=#

    @test_int [(a*cos(e + f*x))^m*(b*sec(e + f*x))^n, x, 2, -(((a*cos(e + f*x))^(1 + m)*HypergeometricFunctions._₂F₁(1/2, (1/2)*(1 + m - n), (1/2)*(3 + m - n), cos(e + f*x)^2)*(b*sec(e + f*x))^n*sin(e + f*x))/(a*f*(1 + m - n)*sqrt(sin(e + f*x)^2)))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*csc(e+f*x))^n=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*cos(e+f*x)^m*(b*csc(e+f*x))^(n/2)=#

    #= ::Subsubsection::Closed:: =#
    #=m>0=#

    @test_int [cos(a + b*x)^1*csc(a + b*x)^(1/2), x, 2, 2/(b*sqrt(csc(a + b*x)))]
    @test_int [cos(a + b*x)^1/csc(a + b*x)^(1/2), x, 2, 2/(3*b*csc(a + b*x)^(3/2))]

    @test_int [cos(a + b*x)^2*csc(a + b*x)^(1/2), x, 3, (2*cos(a + b*x))/(3*b*sqrt(csc(a + b*x))) + (4*sqrt(csc(a + b*x))*Elliptic.F((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(3*b)]
    @test_int [cos(a + b*x)^2/csc(a + b*x)^(1/2), x, 3, (2*cos(a + b*x))/(5*b*csc(a + b*x)^(3/2)) + (4*sqrt(csc(a + b*x))*Elliptic.E((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(5*b)]

    @test_int [cos(x)^3*csc(x)^(9/2), x, 3, (2/3)*csc(x)^(3/2) - (2/7)*csc(x)^(7/2)]
    @test_int [cos(a + b*x)^3*csc(a + b*x)^(1/2), x, 3, -(2/(5*b*csc(a + b*x)^(5/2))) + 2/(b*sqrt(csc(a + b*x)))]
    @test_int [cos(a + b*x)^3/csc(a + b*x)^(1/2), x, 3, -(2/(7*b*csc(a + b*x)^(7/2))) + 2/(3*b*csc(a + b*x)^(3/2))]

    @test_int [cos(a + b*x)^4*csc(a + b*x)^(1/2), x, 4, (4*cos(a + b*x))/(7*b*sqrt(csc(a + b*x))) + (2*cos(a + b*x)^3)/(7*b*sqrt(csc(a + b*x))) + (8*sqrt(csc(a + b*x))*Elliptic.F((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(7*b)]
    @test_int [cos(a + b*x)^4/csc(a + b*x)^(1/2), x, 4, (4*cos(a + b*x))/(15*b*csc(a + b*x)^(3/2)) + (2*cos(a + b*x)^3)/(9*b*csc(a + b*x)^(3/2)) + (8*sqrt(csc(a + b*x))*Elliptic.E((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(15*b)]

    @test_int [cos(x)*csc(x)^(7/3), x, 2, (-3*csc(x)^(4/3))/4]

    #= ::Subsubsection::Closed:: =#
    #=m<0=#

    @test_int [sec(a + b*x)^1*csc(a + b*x)^(1/2), x, 5, -(atan(sqrt(csc(a + b*x)))/b) + atanh(sqrt(csc(a + b*x)))/b]
    @test_int [sec(a + b*x)^1/csc(a + b*x)^(1/2), x, 5, atan(sqrt(csc(a + b*x)))/b + atanh(sqrt(csc(a + b*x)))/b]

    @test_int [sec(a + b*x)^2*csc(a + b*x)^(1/2), x, 3, sec(a + b*x)/(b*sqrt(csc(a + b*x))) + (sqrt(csc(a + b*x))*Elliptic.F((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/b]
    @test_int [sec(a + b*x)^2/csc(a + b*x)^(1/2), x, 3, sec(a + b*x)/(b*csc(a + b*x)^(3/2)) - (sqrt(csc(a + b*x))*Elliptic.E((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/b]

    @test_int [sec(a + b*x)^3*csc(a + b*x)^(1/2), x, 6, -((3*atan(sqrt(csc(a + b*x))))/(4*b)) + (3*atanh(sqrt(csc(a + b*x))))/(4*b) + sec(a + b*x)^2/(2*b*sqrt(csc(a + b*x)))]
    @test_int [sec(a + b*x)^3/csc(a + b*x)^(1/2), x, 6, atan(sqrt(csc(a + b*x)))/(4*b) + atanh(sqrt(csc(a + b*x)))/(4*b) + sec(a + b*x)^2/(2*b*csc(a + b*x)^(3/2))]

    @test_int [sec(a + b*x)^4*csc(a + b*x)^(1/2), x, 4, (5*sec(a + b*x))/(6*b*sqrt(csc(a + b*x))) + sec(a + b*x)^3/(3*b*sqrt(csc(a + b*x))) + (5*sqrt(csc(a + b*x))*Elliptic.F((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(6*b)]
    @test_int [sec(a + b*x)^4/csc(a + b*x)^(1/2), x, 4, sec(a + b*x)/(2*b*csc(a + b*x)^(3/2)) + sec(a + b*x)^3/(3*b*csc(a + b*x)^(3/2)) - (sqrt(csc(a + b*x))*Elliptic.E((1/2)*(a - pi/2 + b*x), 2)*sqrt(sin(a + b*x)))/(2*b)]

    #= ::Subsection:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^(m/2)*(b*csc(e+f*x))^(n/2)=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*csc(e+f*x))^n*with*n*symbolic=#

    @test_int [csc(a + b*x)^p*(d*cos(a + b*x))^(3/2), x, 2, (d*sqrt(d*cos(a + b*x))*csc(a + b*x)^(-1 + p)*HypergeometricFunctions._₂F₁(-(1/4), (1 - p)/2, (3 - p)/2, sin(a + b*x)^2))/(b*(1 - p)*(cos(a + b*x)^2)^(1/4))]
    @test_int [csc(a + b*x)^p*(d*cos(a + b*x))^(1/2), x, 2, (d*(cos(a + b*x)^2)^(1/4)*csc(a + b*x)^(-1 + p)*HypergeometricFunctions._₂F₁(1/4, (1 - p)/2, (3 - p)/2, sin(a + b*x)^2))/(b*(1 - p)*sqrt(d*cos(a + b*x)))]
    @test_int [csc(a + b*x)^p/(d*cos(a + b*x))^(1/2), x, 2, (d*(cos(a + b*x)^2)^(3/4)*csc(a + b*x)^(-1 + p)*HypergeometricFunctions._₂F₁(3/4, (1 - p)/2, (3 - p)/2, sin(a + b*x)^2))/(b*(1 - p)*(d*cos(a + b*x))^(3/2))]
    @test_int [csc(a + b*x)^p/(d*cos(a + b*x))^(3/2), x, 2, ((cos(a + b*x)^2)^(1/4)*csc(a + b*x)^(-1 + p)*HypergeometricFunctions._₂F₁(5/4, (1 - p)/2, (3 - p)/2, sin(a + b*x)^2))/(b*d*(1 - p)*sqrt(d*cos(a + b*x)))]
    @test_int [csc(a + b*x)^p/(d*cos(a + b*x))^(5/2), x, 2, ((cos(a + b*x)^2)^(3/4)*csc(a + b*x)^(-1 + p)*HypergeometricFunctions._₂F₁(7/4, (1 - p)/2, (3 - p)/2, sin(a + b*x)^2))/(b*d*(1 - p)*(d*cos(a + b*x))^(3/2))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(a*cos(e+f*x))^m*(b*csc(e+f*x))^n*with*m*symbolic=#

    @test_int [(cos(e + f*x))^m*(csc(e + f*x))^n, x, 2, (cos(e + f*x)^(-1 + m)*(cos(e + f*x)^2)^((1 - m)/2)*csc(e + f*x)^(-1 + n)*HypergeometricFunctions._₂F₁((1 - m)/2, (1 - n)/2, (3 - n)/2, sin(e + f*x)^2))/(f*(1 - n))]
    @test_int [(a*cos(e + f*x))^m*(csc(e + f*x))^n, x, 2, (a*(a*cos(e + f*x))^(-1 + m)*(cos(e + f*x)^2)^((1 - m)/2)*csc(e + f*x)^(-1 + n)*HypergeometricFunctions._₂F₁((1 - m)/2, (1 - n)/2, (3 - n)/2, sin(e + f*x)^2))/(f*(1 - n))]
    @test_int [(cos(e + f*x))^m*(b*csc(e + f*x))^n, x, 2, (b*cos(e + f*x)^(-1 + m)*(cos(e + f*x)^2)^((1 - m)/2)*(b*csc(e + f*x))^(-1 + n)*HypergeometricFunctions._₂F₁((1 - m)/2, (1 - n)/2, (3 - n)/2, sin(e + f*x)^2))/(f*(1 - n))]
    @test_int [(a*cos(e + f*x))^m*(b*csc(e + f*x))^n, x, 2, (a*b*(a*cos(e + f*x))^(-1 + m)*(cos(e + f*x)^2)^((1 - m)/2)*(b*csc(e + f*x))^(-1 + n)*HypergeometricFunctions._₂F₁((1 - m)/2, (1 - n)/2, (3 - n)/2, sin(e + f*x)^2))/(f*(1 - n))]

    @test_int [(a*cos(e + f*x))^m*(b*csc(e + f*x))^(7/2), x, 2, -((b^3*(a*cos(e + f*x))^(1 + m)*sqrt(b*csc(e + f*x))*HypergeometricFunctions._₂F₁(9/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(1/4))/(a*f*(1 + m))), -((b*(a*cos(e + f*x))^(1 + m)*(b*csc(e + f*x))^(5/2)*HypergeometricFunctions._₂F₁(9/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(5/4))/(a*f*(1 + m)))]
    @test_int [(a*cos(e + f*x))^m*(b*csc(e + f*x))^(5/2), x, 2, -((b*(a*cos(e + f*x))^(1 + m)*(b*csc(e + f*x))^(3/2)*HypergeometricFunctions._₂F₁(7/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(3/4))/(a*f*(1 + m)))]
    @test_int [(a*cos(e + f*x))^m*(b*csc(e + f*x))^(3/2), x, 2, -((b*(a*cos(e + f*x))^(1 + m)*sqrt(b*csc(e + f*x))*HypergeometricFunctions._₂F₁(5/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(1/4))/(a*f*(1 + m)))]
    @test_int [(a*cos(e + f*x))^m*(b*csc(e + f*x))^(1/2), x, 2, -(((a*cos(e + f*x))^(1 + m)*(b*csc(e + f*x))^(3/2)*HypergeometricFunctions._₂F₁(3/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(3/4))/(a*b*f*(1 + m)))]
    @test_int [(a*cos(e + f*x))^m/(b*csc(e + f*x))^(1/2), x, 2, -(((a*cos(e + f*x))^(1 + m)*sqrt(b*csc(e + f*x))*HypergeometricFunctions._₂F₁(1/4, (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(1/4))/(a*b*f*(1 + m)))]
    @test_int [(a*cos(e + f*x))^m/(b*csc(e + f*x))^(3/2), x, 2, -(((a*cos(e + f*x))^(1 + m)*HypergeometricFunctions._₂F₁(-(1/4), (1 + m)/2, (3 + m)/2, cos(e + f*x)^2))/(a*b*f*(1 + m)*sqrt(b*csc(e + f*x))*(sin(e + f*x)^2)^(1/4)))]
    @test_int [(a*cos(e + f*x))^m/(b*csc(e + f*x))^(5/2), x, 2, -(((a*cos(e + f*x))^(1 + m)*sqrt(b*csc(e + f*x))*HypergeometricFunctions._₂F₁(-(3/4), (1 + m)/2, (3 + m)/2, cos(e + f*x)^2)*(sin(e + f*x)^2)^(1/4))/(a*b^3*f*(1 + m))), -(((a*cos(e + f*x))^(1 + m)*HypergeometricFunctions._₂F₁(-(3/4), (1 + m)/2, (3 + m)/2, cos(e + f*x)^2))/(a*b*f*(1 + m)*(b*csc(e + f*x))^(3/2)*(sin(e + f*x)^2)^(3/4)))]
    end

max_stars_repo_path: test/4 Trig functions/4.2 Cosine/4.2.0 (a cos)^m (b trg)^n.jl


text:
__precompile__(true)
module Sugar

using Matcha, MacroTools, DataStructures

const AllFuncs = Union{Function, Core.Builtin, Core.IntrinsicFunction}
const IntrinsicFuncs = Union{Core.Builtin, Core.IntrinsicFunction}

# All kind of patterns for regex/matcha. Contains also matching isa functions
# include("patterns.jl")

# various tools to replace and work with asts
# TODO figure out what can be used from the great MacroTools
include("ast_tools.jl")
export normalize_ast
# Tools for extracting all kind of representations out of a method/function
include("lambdas.jl")
export slot_vector, get_lambda, clean_typed

# "Sugarcoats" tools to transform the unsightly representation returned by code_typed
# into something sweet and beautiful (namely an Expr tree closer to what you get
# from a macro)
include("sugarcoating.jl")
export remove_goto, sugared

include("show.jl")

# helper to work with methods
include("methods.jl")
include("pointer_tracking.jl")

export LazyMethod, getast!, getfunction, isfunction, istype, dependencies!, @lazymethod

end # module