My problem involves the following double summation
where are complex coefficients, and are positive constants. I think that I can apply the PolyVal2D function written by Mark Mikofski. However, as my coefficients are complex, I don't think the function will work with my code.
My first attempt involved truncating a double summation after computing a specified number of orders in the taylor expansion. In order to do this. I created the function below.
function val2 = test(unm)
Eps = 1e-6; Delta = 1e-4; Nx = 48; Nz = 32; N = 8; M = 8;
coeff = zeros(N+1,M+1);
u_approx = zeros(Nx,Nz+1);
coeff(:,:) = unm(j,ell+1,:,:);
val2 = u_approx;
(My code for how I form is omitted. I could provide the values of if necessary, it is a 2D array of complex doubles of dimension )
The above function references the function taylor_sum2
function [tsum] = taylorsum_2(c,Eps,Delta,N,M)
tsum = polyVal2D(c,Eps,Delta,N,M);
which then references the code written in polyVal2D. At line 31 of polyVal2D, code is written to check the input arguments of the coeffcients. It appears that the coefficients must be real for this code to work (my own testing returned odd results when this restriction was removed - all of the coefficients returned are greater than !)
'X and Y must be the same size.')
Through this analysis, I have the following questions:
- Does the above function ( polyVal2D) work with a 2D array of complex doubles for coefficients? I emailed the author since I was unsure about expected functionality. I'm not sure if I could adjust the code inside polyVal2D so that it will work with my 2D array of complex doubles.
- If that is the case, I think that my other option is shown inside the answers to this_question. The polyfit_n function was created to handle scenarios similar to mine. I don't know how to implement it, so I have instead tried to implement the polyVal2D function.