#This code calculates the coefficients of the "starting" spline which is of degree 2k-2. # Yd is a matrix of dimension 2x(K/2) containing the derivatives of the (K-1)-integral of a two sided #Brownian motion (Y) + t^{2K} at the boundary points -C and C. It starts with the (K-2)th #derivative of Y at -C and C, (K-4)th,...,0. StartingSpline <- function(K,C,Yd){ C <- 2 K <- 4 Yd <- rbind(-1,2) if((K-2*floor(K/2))!=0){ print("Enter please an even K !") } #This part gives the coefficients when K=2. if(K==2){ Coef <- c(6*C^2,(Yd[2,1]-Yd[1,1])/(2*C),(Yd[2,1]+Yd[1,1])/2 - 6*C^4) } #This part of the code calculates the coefficients when K > 2 (and even). if(K > 2){ d <- 2*K-2 a.d <- (factorial(2*K)/factorial(2))*C^2 Coef <- a.d for(i in (d-1):0){ p <- 2*K-i if(p <= K){ if((p-2*floor(p/2))!=0){ Coef <- c(Coef,0) } else{ Coef <- c(Coef,(factorial(2*K)/factorial(2*i))*C^{2*i}-sum(Coef[Coef!=0]*(1/factorial(2*((i-1):1)))*C^{2*((i-1):1)})) } } if(p > K){ if((p-2*floor(p/2))!=0){ Coef <- c(Coef, (Yd[2,(p-K+1)/2]-Yd[1,(p-K+1)/2])/(2*C)) } else{ i <- p/2 Coef <- c(Coef,(Yd[2,(p-K)/2]+Yd[1,(p-K)/2])/2 - sum(Coef[2*((i-1):1)]*(1/factorial(2*((i-1):1)))*C^{2*((i-1):1)})) } } } } Coef <- Coef/factorial((2*K-2):0) Coef }