import GPLinearODEMaker.powers_of_negative_one

"""
    rq_kernel(hyperparameters, δ, dorder; shift_ind=0)

Created by kernel_coder(). Requires 2 hyperparameters.
Likely created using rq_kernel_base() as an input.
Use with include("src/kernels/rq_kernel.jl").

# Arguments
- `hyperparameters::Vector`: The hyperparameter values. For this kernel, they should be `["α", "μ"]`
- `δ::Real`: The difference between the inputs (e.g. `t1 - t2`)
- `dorder::Vector{<:Integer}`: How many times to differentiate with respect to the inputs and the `hyperparameters` (e.g. `dorder=[0, 1, 0, 2]` would correspond to differentiating once w.r.t the second input and twice w.r.t `hyperparameters[2]`)
- `shift_ind::Integer=0`: If changed, the index of which hyperparameter is the `δ` shifting one
"""
function rq_kernel(
    hyperparameters::Vector{<:Real},
    δ::Real,
    dorder::Vector{<:Integer};
    shift_ind::Integer=0)

    include_shift = shift_ind!=0
    @assert length(hyperparameters)==2+Int(include_shift) "hyperparameters is the wrong length"
    dorder_len = 4 + Int(include_shift)
    @assert length(dorder)==dorder_len "dorder is the wrong length"
    @assert maximum(dorder) < 3 "No more than two derivatives for each time or hyperparameter can be calculated"

    dorder2 = dorder[2]
    dorder[2] += dorder[1]

    if include_shift
        dorder[2] += dorder[shift_ind+2]
        δ += hyperparameters[shift_ind]
        hyperparameters_view = view(hyperparameters, 1:3 .!= shift_ind)
        dorder_view = view(dorder, 2:dorder_len)
        dorder_view = view(dorder_view, 1:(dorder_len-1) .!= (shift_ind+1))
    else
        hyperparameters_view = hyperparameters
        dorder_view = view(dorder, 2:dorder_len)
    end

    α = hyperparameters_view[1]
    μ = hyperparameters_view[2]

    if dorder_view==[6, 0, 2]
        func = -90*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 585*δ^2*μ^2*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-1935/4)*δ^4*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-465/4)*δ^6*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (-39/4)*δ^8*μ^5*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 + (-1/4)*δ^10*μ^6*(-6 - α)*(-7 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-8 - α)/α^7
    end

    if dorder_view==[5, 0, 2]
        func = -90*δ*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 165*δ^3*μ^2*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-255/4)*δ^5*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-15/2)*δ^7*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (-1/4)*δ^9*μ^5*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6
    end

    if dorder_view==[4, 0, 2]
        func = -6*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 42*δ^2*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-123/4)*δ^4*μ^2*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-11/2)*δ^6*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-1/4)*δ^8*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[3, 0, 2]
        func = -6*δ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 12*δ^3*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-15/4)*δ^5*μ^2*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-1/4)*δ^7*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[2, 0, 2]
        func = -3*δ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-9/4)*δ^4*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-1/4)*δ^6*μ^2*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[1, 0, 2]
        func = -δ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-1/4)*δ^5*μ*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2
    end

    if dorder_view==[0, 0, 2]
        func = (-1/4)*δ^4*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[6, 1, 1]
        func = 45*μ^2*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 45*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 90*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 45*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 15*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (375/2)*δ^2*μ^3*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (375/2)*δ^2*μ^3*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 180*δ^2*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 555*δ^2*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + (195/2)*δ^4*μ^4*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (195/2)*δ^4*μ^4*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (195/2)*δ^4*μ^4*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 75*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 180*δ^2*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-15/2)*δ^2*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (735/2)*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 + (27/2)*δ^6*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (27/2)*δ^6*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (27/2)*δ^6*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (27/2)*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 6*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 75*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-45/2)*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-5 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 60*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 + (1/2)*δ^8*μ^6*(-6 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 + (1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 + (1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 + (1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 + (1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6 - 6*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (-15/2)*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-6 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (5/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^7 + (-1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6
    end

    if dorder_view==[5, 1, 1]
        func = 45*δ*μ^2*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 45*δ*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 90*δ*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + (95/2)*δ^3*μ^3*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (95/2)*δ^3*μ^3*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 40*δ^3*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 45*δ*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 15*δ*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 135*δ^3*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + 10*δ^5*μ^4*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 10*δ^5*μ^4*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 10*δ^5*μ^4*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 5*δ^5*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 40*δ^3*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-15/2)*δ^3*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 35*δ^5*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 + (1/2)*δ^7*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (1/2)*δ^7*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (1/2)*δ^7*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (1/2)*δ^7*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 5*δ^5*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 5*δ^5*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-5 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 2*δ^7*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 + (-1/2)*δ^7*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[4, 1, 1]
        func = 6*μ*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 6*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 6*μ*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 3*μ^2*(-1 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (39/2)*δ^2*μ^2*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 18*δ^2*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (75/2)*δ^2*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + 7*δ^4*μ^3*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 7*δ^4*μ^3*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 4*δ^4*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 18*δ^2*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-3/2)*δ^2*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 6*δ^2*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 18*δ^4*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + (1/2)*δ^6*μ^4*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (1/2)*δ^6*μ^4*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (1/2)*δ^6*μ^4*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 4*δ^4*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 3*δ^4*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (3/2)*δ^6*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 + (-1/2)*δ^6*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[3, 1, 1]
        func = 6*δ*μ*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 6*δ*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 + (9/2)*δ^3*μ^2*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 3*δ^3*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 6*δ*μ*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 3*δ*μ^2*(-1 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (15/2)*δ^3*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + (1/2)*δ^5*μ^3*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (1/2)*δ^5*μ^3*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 3*δ^3*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-3/2)*δ^3*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - δ^3*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + δ^5*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + (-1/2)*δ^5*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[2, 1, 1]
        func = -((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-1 - α) - μ*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-1 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-1 - α) + 2*δ^2*μ*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 2*δ^2*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 + (1/2)*δ^4*μ^2*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 2*δ^2*μ*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-1/2)*δ^2*μ*(-1 - α)*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - δ^2*μ^2*(-1 - α)*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (1/2)*δ^4*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + (-1/2)*δ^4*μ^2*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2
    end

    if dorder_view==[1, 1, 1]
        func = -δ*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-1 - α) - δ*μ*((-1/2)*δ^2/(α*(1 + (1/2)*δ^2*μ/α)) + (-1/2)*δ^2*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) + (1/4)*δ^4*μ*(-1 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)^2))*(1 + (1/2)*δ^2*μ/α)^(-1 - α) + (-1/2)*δ^3*μ*(-1 - α)*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[0, 1, 1]
        func = (-1/2)*δ^2*(1 + (1/2)*δ^2*μ/α)^(-1 - α)*((1/2)*δ^2*μ/(α*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2
    end

    if dorder_view==[6, 0, 1]
        func = -45*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-375/2)*δ^2*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-195/2)*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-27/2)*δ^6*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + (-1/2)*δ^8*μ^6*(-6 - α)*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-7 - α)/α^6
    end

    if dorder_view==[5, 0, 1]
        func = -45*δ*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-95/2)*δ^3*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 10*δ^5*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + (-1/2)*δ^7*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[4, 0, 1]
        func = -6*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-39/2)*δ^2*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 7*δ^4*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + (-1/2)*δ^6*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[3, 0, 1]
        func = -6*δ*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-9/2)*δ^3*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + (-1/2)*δ^5*μ^3*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[2, 0, 1]
        func = (-5/2)*δ^2*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + (-1/2)*δ^4*μ^2*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - (1 + (1/2)*δ^2*μ/α)^(-1 - α)
    end

    if dorder_view==[1, 0, 1]
        func = -δ*(1 + (1/2)*δ^2*μ/α)^(-1 - α) + (-1/2)*δ^3*μ*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[0, 0, 1]
        func = (-1/2)*δ^2*(1 + (1/2)*δ^2*μ/α)^(-1 - α)
    end

    if dorder_view==[6, 2, 0]
        func = -30*μ^3*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 60*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 60*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 90*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^4 + 30*μ^3*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 30*μ^3*(-1 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 90*δ^2*μ^4*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 90*δ^2*μ^4*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 90*δ^2*μ^4*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 60*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 15*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-3 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^2 - 15*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 270*δ^2*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 270*δ^2*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 270*δ^2*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 30*δ^4*μ^5*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^4*μ^5*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^4*μ^5*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^4*μ^5*(-1 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^4*μ^5*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^4*μ^5*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 540*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^5 + 90*δ^2*μ^4*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 90*δ^2*μ^4*(-1 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 90*δ^2*μ^4*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 120*δ^4*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 120*δ^4*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 120*δ^4*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 120*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 2*δ^6*μ^6*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 270*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-4 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^3 - 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 300*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^6 + 30*δ^4*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 30*δ^4*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 30*δ^4*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 30*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 10*δ^6*μ^6*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - 10*δ^6*μ^6*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - 10*δ^6*μ^6*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - 10*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - 10*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 + 120*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-5 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-5 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^4 - 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 30*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^7 + 2*δ^6*μ^6*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 2*δ^6*μ^6*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 2*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + 10*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-6 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-6 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^5 - δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[5, 2, 0]
        func = -30*δ*μ^3*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 60*δ*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 60*δ*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 20*δ^3*μ^4*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 20*δ^3*μ^4*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 20*δ^3*μ^4*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 90*δ*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^4 + 30*δ*μ^3*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 30*δ*μ^3*(-1 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 60*δ^3*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 60*δ^3*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 60*δ^3*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 2*δ^5*μ^5*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 2*δ^5*μ^5*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 2*δ^5*μ^5*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 2*δ^5*μ^5*(-1 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 2*δ^5*μ^5*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 2*δ^5*μ^5*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 60*δ*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 15*δ*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-3 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^2 - 15*δ*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 120*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^5 + 20*δ^3*μ^4*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 20*δ^3*μ^4*(-1 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 20*δ^3*μ^4*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 8*δ^5*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 8*δ^5*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 8*δ^5*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - 8*δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 + 60*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-4 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^3 - 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 20*δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^6 + 2*δ^5*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 2*δ^5*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 2*δ^5*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 2*δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 8*δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-5 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-5 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^4 - δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[4, 2, 0]
        func = -6*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 6*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^3 + 6*μ^2*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 12*δ^2*μ^3*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 6*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 3*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-2 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α - 3*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 24*δ^2*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 24*δ^2*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 2*δ^4*μ^4*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 2*δ^4*μ^4*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 2*δ^4*μ^4*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 36*δ^2*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^4 + 12*δ^2*μ^3*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 12*δ^2*μ^3*(-1 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 6*δ^4*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 6*δ^4*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - 6*δ^4*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + 24*δ^2*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 6*δ^2*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-3 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^2 - 6*δ^2*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 12*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^5 + 2*δ^4*μ^4*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 2*δ^4*μ^4*(-1 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 2*δ^4*μ^4*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 6*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-4 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-4 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^3 - δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[3, 2, 0]
        func = -6*δ*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 2*δ^3*μ^3*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 6*δ*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^3 + 6*δ*μ^2*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 4*δ^3*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 4*δ^3*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + 6*δ*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 3*δ*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-2 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α - 3*δ*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 6*δ^3*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^4 + 2*δ^3*μ^3*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 2*δ^3*μ^3*(-1 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 4*δ^3*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - δ^3*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-3 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-3 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α^2 - δ^3*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2
    end

    if dorder_view==[2, 2, 0]
        func = -μ*(1 + (1/2)*δ^2*μ/α)^(-1 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-1 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-1 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2)) - μ*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-1 - α) - 2*δ^2*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 2*δ^2*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^3 + 2*δ^2*μ^2*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 2*δ^2*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - δ^2*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-2 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-2 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2))/α - δ^2*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[1, 2, 0]
        func = -δ*μ*(1 + (1/2)*δ^2*μ/α)^(-1 - α)*(δ^2*μ/(α^2*(1 + (1/2)*δ^2*μ/α)) + δ^2*μ*(-1 - α)/(α^3*(1 + (1/2)*δ^2*μ/α)) + (-1/4)*δ^4*μ^2*(-1 - α)/(α^4*(1 + (1/2)*δ^2*μ/α)^2)) - δ*μ*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2*(1 + (1/2)*δ^2*μ/α)^(-1 - α)
    end

    if dorder_view==[0, 2, 0]
        func = (1 + (1/2)*δ^2*μ/α)^(-α)*((1/2)*δ^2*μ/(α*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))^2 + (1/4)*δ^4*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^3
    end

    if dorder_view==[6, 1, 0]
        func = 15*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 15*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 30*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - 15*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 45*δ^2*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 45*δ^2*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 135*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + 15*δ^4*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 15*δ^4*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 60*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 + δ^6*μ^6*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + δ^6*μ^6*(-1 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + δ^6*μ^6*(-1 - α)*(-2 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 + δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5 - 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + 5*δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^6 - δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*((-1/2)*δ^2*μ*(-6 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[5, 1, 0]
        func = 15*δ*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 15*δ*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 30*δ*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + 10*δ^3*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 10*δ^3*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 15*δ*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 30*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 + δ^5*μ^5*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + δ^5*μ^5*(-1 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + δ^5*μ^5*(-1 - α)*(-2 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 + δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + 4*δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^5 - δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*((-1/2)*δ^2*μ*(-5 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[4, 1, 0]
        func = 3*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 3*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - 3*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 6*δ^2*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 6*δ^2*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 12*δ^2*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 + δ^4*μ^4*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + δ^4*μ^4*(-1 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 + δ^4*μ^4*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 6*δ^2*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + 3*δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^4 - δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*((-1/2)*δ^2*μ*(-4 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[3, 1, 0]
        func = 3*δ*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 3*δ*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 + δ^3*μ^3*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 + δ^3*μ^3*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 3*δ*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + 2*δ^3*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^3 - δ^3*μ^3*(-1 - α)*(-2 - α)*((-1/2)*δ^2*μ*(-3 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2
    end

    if dorder_view==[2, 1, 0]
        func = -μ*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-1 - α) + δ^2*μ^2*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α + δ^2*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α^2 - δ^2*μ^2*(-1 - α)*((-1/2)*δ^2*μ*(-2 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[1, 1, 0]
        func = -δ*μ*((-1/2)*δ^2*μ*(-1 - α)/(α^2*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))*(1 + (1/2)*δ^2*μ/α)^(-1 - α)
    end

    if dorder_view==[0, 1, 0]
        func = (1 + (1/2)*δ^2*μ/α)^(-α)*((1/2)*δ^2*μ/(α*(1 + (1/2)*δ^2*μ/α)) - log(1 + (1/2)*δ^2*μ/α))
    end

    if dorder_view==[6, 0, 0]
        func = -15*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 45*δ^2*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - 15*δ^4*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4 - δ^6*μ^6*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(-5 - α)*(1 + (1/2)*δ^2*μ/α)^(-6 - α)/α^5
    end

    if dorder_view==[5, 0, 0]
        func = -15*δ*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - 10*δ^3*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3 - δ^5*μ^5*(-1 - α)*(-2 - α)*(-3 - α)*(-4 - α)*(1 + (1/2)*δ^2*μ/α)^(-5 - α)/α^4
    end

    if dorder_view==[4, 0, 0]
        func = -3*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - 6*δ^2*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2 - δ^4*μ^4*(-1 - α)*(-2 - α)*(-3 - α)*(1 + (1/2)*δ^2*μ/α)^(-4 - α)/α^3
    end

    if dorder_view==[3, 0, 0]
        func = -3*δ*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α - δ^3*μ^3*(-1 - α)*(-2 - α)*(1 + (1/2)*δ^2*μ/α)^(-3 - α)/α^2
    end

    if dorder_view==[2, 0, 0]
        func = -μ*(1 + (1/2)*δ^2*μ/α)^(-1 - α) - δ^2*μ^2*(-1 - α)*(1 + (1/2)*δ^2*μ/α)^(-2 - α)/α
    end

    if dorder_view==[1, 0, 0]
        func = -δ*μ*(1 + (1/2)*δ^2*μ/α)^(-1 - α)
    end

    if dorder_view==[0, 0, 0]
        func = (1 + (1/2)*δ^2*μ/α)^(-α)
    end

    dorder[2] = dorder2  # resetting dorder[2]
    return powers_of_negative_one(dorder2) * float(func)  # correcting for amount of t2 derivatives

end


return rq_kernel, 2  # the function handle and the number of kernel hyperparameters
