Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

problem with ndsolve using interpolated functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131119] problem with ndsolve using interpolated functions
  • From: "Hagwood, Charles R" <charles.hagwood at nist.gov>
  • Date: Thu, 13 Jun 2013 02:35:35 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

I have the following problem I need help with: Thanks for any help.

I have two curves q0[t] and q1[t] : [0,1] --> R^2 parameterized by t and defined discretely by {{t_i,q0[i]}, i= 0,...,n} , {{t_i,q1[i]}, i= 0,...,=
m}.

Let the function f: R^3 --> R be defined by

f[t,v,v']=-2Sqrt[v'] <q0[t],q1'[v]> -(1/Sqrt[v'])<q1'[v],q1'[v]>

where <,> denotes the Euclidean inner product and q1' denotes the derivative of q1 with respect to t.

I want to solve the differential equation for v, ( v[t] : [0,1] -->  [0,1])

(partial f[t,v[t],v'[t]]/partial v ) +d/dt(partial f[t,v[t],v'[t]]/partial v'), v[0]=0,v[1]=1.

My attempt is given below:

In my case t_i=0,1/n,2/n,...,1. I first interpolated the data for q0 and q1, then set up the problem to use NDSolve.

min[q0_, q1_] :=
Module[{n, q0q0, p0,m, q1q1, p1, dp1,g1,g2 , sol,v },
n = Length[q0] - 1;
q0q0 = Append[Table[{(i - 1)/n, q0[[i]]}, {i, 1, n}], {1, q0[[n]]}];
p0 = Interpolation[q0q0, InterpolationOrder -> 3, Method -> "Spline"];
m = Length[q1] - 1;
q1q1 =
Append[Table[{(i - 1)/m, q1[[i]]}, {i, 1, m}], {1, q1[[m]]}];
p1 = Interpolation[q1q1, InterpolationOrder -> 3, Method -> "Spline"];
dp1[x_?NumericQ] = D[p1[x], x];
g1[t_?NumericQ, x_?NumericQ,
y_?NumericQ] := -2*Sqrt[y ]*p0[t].dp1[x] + y *dp1[x].dp1[x];
g2[t_?NumericQ, x_?NumericQ,
y_?NumericQ] := -Sqrt[y ]^(-1)*p0[t].p1[x] + y * p1[x].p1[x];
sol = NDSolve[{g1[t, v[t], v'[t]] + D[g2[t, v[t], v'[t]], t] == 0,
v[0] == 0 , v[1] == 1}, v, {t, 0, 1}]];
Plot[Evaluate[v[t] /. sol], {t, 0, 1}, PlotStyle -> Automatic]
]
min[q0,q1]

I get an error and no answer: NDSolve::ntdvdae: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system as differential-algebraic equations. >>
Below are the data for q0 and q1.
q0=
{{0.407794, -0.914771}, {0.418761, -0.909768}, {0.43678, -0.901288},
{0.449548, -0.894997}, {0.459851, -0.889752}, {0.468893, -0.88502},
{0.479953, -0.87906}, {0.49514, -0.870583}, {0.514865, -0.859036},
{0.539765, -0.843579}, {0.565669, -0.826449}, {0.589915, -0.809319},
{0.614915, -0.790473}, {0.635974, -0.773693}, {0.648186, -0.763528},
{0.651237, -0.760937}, {0.647735, -0.763918}, {0.651324, -0.760835},
{0.670449, -0.743941}, {0.698543, -0.717564}, {0.735591, -0.679243},
{0.788205, -0.616709}, {0.855968, -0.516891}, {0.931119, -0.359723},
{0.983564, -0.174797}, {1.00008, -0.0353931}, {1.00032,
0.0443894}, {0.998555, 0.0774794}, {0.998768, 0.0746021}, {1.00053,
0.0390166}, {0.999146, -0.0501113}, {0.987815, -0.160316},
{0.974509, -0.230537}, {0.971108, -0.24499}, {0.977451, -0.217811},
{0.985367, -0.178738}, {0.99317, -0.126578}, {0.999594, -0.0553745},
{1.00112, 0.0148096}, {0.998325, 0.0770045}, {0.992656,
0.131739}, {0.983185, 0.189214}, {0.966288, 0.261412}, {0.940251,
0.343228}, {0.904741, 0.427954}, {0.853954, 0.521222}, {0.778413,
0.627618}, {0.666174, 0.744222}, {0.463036, 0.879213}, {0.101998,
0.979842}, {-0.31051, 0.93917}, {-0.560332, 0.827523}, {-0.653772,
0.758236}, {-0.694761, 0.721251}, {-0.711436, 0.704975}, {-0.710067,
0.706345}, {-0.695899, 0.720224}, {-0.652058,
0.759356}, {-0.545828, 0.836998}, {-0.406784, 0.913414}, {-0.313203,
0.951015}, {-0.319396, 0.948827}, {-0.402311,
0.916162}, {-0.524542, 0.850531}, {-0.654748, 0.755436}, {-0.74446,
0.668892}, {-0.797526, 0.605258}, {-0.830301, 0.559847}, {-0.858862,
0.514642}, {-0.896129, 0.44576}, {-0.939058, 0.344497}, {-0.976635,
0.214593}, {-0.995787, 0.101626}, {-1.00066, 0.0397148}, {-1.00119,
0.0265708}, {-0.999956, 0.0541021}, {-0.993833,
0.119075}, {-0.975763, 0.22098}, {-0.950402, 0.314558}, {-0.931749,
0.367094}, {-0.924183, 0.386018}, {-0.925842, 0.382006}, {-0.929576,
0.372853}, {-0.935091, 0.358681}, {-0.946116,
0.328226}, {-0.959622, 0.286188}, {-0.972708, 0.237761}, {-0.98301,
0.191176}, {-0.99107, 0.142837}, {-0.998449,
0.0702924}, {-1.00014, -0.0298104}, {-0.990499, -0.141442},
{-0.971307, -0.241648}, {-0.94708, -0.324209}, {-0.917541,
-0.400221}, {-0.874384, -0.486353}, {-0.779042, -0.622202},
{-0.453156, -0.858708}, {0.124937, -0.961913}, {0.417441, -0.906136}}
q1=
{{0.985208, -0.233852}, {0.927525, -0.391843}, {0.813655, -0.605519},
{0.755789, -0.67903}, {0.706651, -0.728991}, {0.587302, -0.825138},
{0.433249, -0.916878}, {0.389253, -0.937811}, {0.715864, -0.412418},
{0.67376, 0.632839}, {0.465815, 0.903034}, {0.453364,
0.909452}, {0.465057, 0.903441}, {0.511763, 0.877366}, {0.608589,
0.811279}, {0.782259, 0.633859}, {0.947122, 0.342811}, {1.00846,
0.105679}, {1.01578, 0.0254997}, {1.01501, 0.0457921}, {0.992466,
0.188281}, {0.85786, 0.513032}, {0.663013, 0.765515}, {0.571929,
0.839736}, {0.557814, 0.849337}, {0.578337, 0.835455}, {0.600562,
0.819684}, {0.610471, 0.812381}, {0.621022, 0.804285}, {0.64811,
0.782474}, {0.688704, 0.746792}, {0.735192, 0.700997}, {0.779162,
0.65183}, {0.81868, 0.601456}, {0.855915, 0.547092}, {0.892599,
0.484728}, {0.927552, 0.413791}, {0.956598, 0.34157}, {0.976748,
0.27945}, {0.98799, 0.237392}, {0.994297, 0.209513}, {1.00062,
0.176431}, {1.00295, 0.161705}, {0.958662, 0.311149}, {0.77926,
0.628956}, {0.578076, 0.833308}, {0.498814, 0.88514}, {0.462805,
0.904565}, {0.426993, 0.921973}, {0.398404, 0.934796}, {0.400143,
0.902697}, {-0.384822, 0.555472}, {-0.910234, 0.285574}, {-0.7932,
0.634359}, {-0.773951, 0.658063}, {-0.540001, 0.815145}, {-0.415923,
0.204864}, {-0.292343, -0.890463}, {-0.445684, -0.913106},
{-0.469456, -0.90123}, {-0.480776, -0.895248}, {-0.500673,
-0.884186}, {-0.537657, -0.862055}, {-0.593938, -0.823855},
{-0.667705, -0.764893}, {-0.736061, -0.699793}, {-0.78428,
-0.645721}, {-0.812358, -0.610388}, {-0.827713, -0.589451},
{-0.830985, -0.584864}, {-0.819785, -0.600401}, {-0.81025,
-0.613293}, {-0.813126, -0.609444}, {-0.827782, -0.589262},
{-0.844876, -0.564554}, {-0.859572, -0.541889}, {-0.874578,
-0.517322}, {-0.886046, -0.497509}, {-0.890262, -0.489968},
{-0.887785, -0.49443}, {-0.883495, -0.502064}, {-0.87882, -0.510192},
{-0.873673, -0.518963}, {-0.870549, -0.524198}, {-0.872489,
-0.520945}, {-0.877201, -0.512979}, {-0.878711, -0.510399},
{-0.876871, -0.51355}, {-0.878864, -0.510092}, {-0.890806,
-0.488781}, {-0.910137, -0.45152}, {-0.938567, -0.387793},
{-0.973546, -0.287102}, {-0.999824, -0.176606}, {-1.01138,
-0.095808}, {-1.01498, -0.0470131}, {-1.01597, -0.0201307},
{-1.01354, -0.0555925}, {-0.791693, -0.224276}, {-0.446656,
-0.432954}}



  • Prev by Date: Re: Using manipulate with user entered variables and functions
  • Next by Date: Re: Re: a trivial task?
  • Previous by thread: Re: Using manipulate with user entered variables and functions
  • Next by thread: Removing list elements in x by list y