MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Two dimensional Splines

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109121] Two dimensional Splines
  • From: zosi <zosi at to.infn.it>
  • Date: Mon, 19 Apr 2010 04:06:53 -0400 (EDT)

After having sailed into Mathgroup and Help, we still face the
following problem.

Suppose we have a set of 3D points (x_i, y_j, f[x_i,y_j])
with i=1...N, j=1...M and we need to

a) interpolate the surface by **using**
<<Splines`  and SplineFit[...,cubic]
   a.1) plot the interpolating (spline) surface
   a.2) extract the coefficients of the bicubic polynomials
          over each sub-domain
b) calculate the integral of the interpolating spline.

In the following, we show the steps and the difficulties encountered

(* Begin:  Suppose we start with the trivial function *)

f[x_, y_] :=  Sin[x + y]^2

plotfxy =
  Plot3D[f[x, y] , { x, 0 , \[Pi] }, {y, 0, 2 \[Pi] }, PlotPoints -> 50 ]

(* For subsequent comparisons we calculate immediately the integral
    with 20 digits  *)

numintegral  =
   N[Integrate[f[x, y], {x, 0 , \[Pi]} , {y, 0 , 2 \[Pi]} ], 20]
(* Output 9.8696044010893586188 *)

(*  Here we create the grid, very coarse, only 25 points (5x5)
     for 16 sub-domains *)

grid3D =
  Flatten[Table[{x, y, f[x, y]}, {x, 0, \[Pi], \[Pi]/4}, {y, 0, 2 \[Pi], 
\[Pi]/2}], 1]

(* The following use of << Splines` is mandatory *)

<< Splines`

bicubic = SplineFit[grid3D, Cubic];
(* Output: SplineFunction[Cubic, {0., 24.},<>]  *)

First question (a.1): How can we plot the spline interpolating surface ?
Several trials using ParametricPlot3D[bicubic[s],....] have failed.

Second question (a.2): How do we extract the coefficients of the bicubic 
polynomials
                        over each of the 16 sub-domains ?
We have, first
coefpoly = InputForm[bicubic] // N;

Even when we try to extract the first List (containing three Lists),
     probably relevant to the bicubic polynomial  over the
     first (0,\Pi/4) x (0,\Pi/2) sub-domain, for  example:

coefpoly[[1, 4, 1]]
(* Output {{0., 0.00512628, 0., -0.00512628},
                  {0., 1.51953, 0., 0.0512628},
                  {0., 1.72638, 0., -0.726383}}
*)

we are not able to construct the relevant
bicubic(x,y) polynomial  and, obviously, the remaining polynomials.

Final question: Is there a single command to evaluate the integral
                      of  "bicubic"  over the domain [0,\Pi]x[0,2 \Pi] ?

Many thanks for your patience and help.

Gianfranco Zosi
Dip. Fisica Generale
Universita di Torino


  • Prev by Date: Re: Using package functions in Manipulate/DynamicModule
  • Next by Date: Re: if using Mathematica to solve an algebraic problem
  • Previous by thread: Re: Exporting Plot with Customized Legend to PDF
  • Next by thread: Easy way to label graphics grids?