Importing an InterpolatingFunction computed with option "LocationMethod" -> "StepBegin"

Bug introduced in 10.4.1 or earlier and fixed in 11.1.1

Apparent bug observed in MMA 11.0.0.0.

2016/11/10 Wolfram Support Team contacted.

2016//11/29 Passed along the report to developers for further diagnosis

The following code is just to generate the InterpolatingFunction of interest:

isPeriodic[vals_, ic_] := (Norm[vals - ic] < .02) && (t < -1 || t > 1)
vars = Array[s, 2];
varst = Through[vars[t]];
ic = {56.30672012303853, 1.9416110387254666};
sysDAE0 = {{0.2763932022500211 Sin[0.8090169943749473 (-s[1][t] + s[2][t])] Sin[
0.3090169943749473 (s[1][t] + s[2][t])] + 0.7236067977499788 Sin[0.3090169943749473 (-s[1][t] + s[2][t])]
Sin[0.8090169943749473 (s[1][t] + s[2][t])]} == {0},
Derivative[1][s[1]][t]^2 + Derivative[1][s[2]][t]^2 == 1., {s[1][0], s[2][0]} == ic,
{Derivative[1][s[1]][0], Derivative[1][s[2]][0]} == {-0.8903443552034469,
0.45528774325404187}};
isPeriodic[vals_, ci_] := (Norm[vals - ci] < .02) && (t < -1 || t > 1)
(*solves the system*)periodicQ = False;
{solDAE} = NDSolve[{sysDAE0,
WhenEvent[Evaluate@isPeriodic[varst, ic], periodicQ = True; "StopIntegration"],
WhenEvent[Positive[t] && periodicQ,"StopIntegration", "LocationMethod" -> "StepBegin"]},
vars, {t, -1000, 1000}]
sol[t_] := Through[(vars /. solDAE)[t]];
{tmin, tmax} = Flatten@solDAE[[1]][[2, 1]];


That works perfectly well, and sol[t] returns

Now, if I save sol[t] and import it back:

Export["temp.m", sol[t]]
sol2 = Import["temp.m"]


returns the InputForm of the function, instead of the nice compact one (StandardForm):

{InterpolatingFunction[{{-13.8905, 0.}}, {5, 3, 1, {583}, {4}, 0, 0,
0, 0, Automatic, {}, {},
False}, {{-13.8905, -13.8543, -13.8179, -13.7815, -13.7452, \
-13.7088, -13.6724, -13.636, -13.5997, -13.5633, -13.5269, -13.4905, \
-13.4724, -13.4542, -13.436, -13.4178, -13.3996, -13.3814, -13.3632, \
-13.345, -13.3269, -13.3063, -13.2858, -13.2652, -13.2447, -13.2241, \
-13.2036, -13.1808, -13.1579, -13.1326, -13.1072, -13.0819, -13.0565, \
...


Note that without WhenEvent[Positive[t] && periodicQ,"StopIntegration", "LocationMethod" -> "StepBegin"], the Import works perfectly: it gives the InterpolatingFunctions in the nice form.

What is happening and how to solve this issue?

Edit It appears to be somehow related to "LocationMethod" -> "StepBegin": when removed, the importation works well. But I don't see the point.

• That's a bug - please report this to Wolfram (support AT wolfram.com). Nov 10, 2016 at 9:15
• @user21 Done. Side question: how can you be sure it's a bug? Of course, I find it strange too, but some other things I found strange sometimes appeared to come from my misunderstandings. Nov 10, 2016 at 15:16
• The fact the the re-imported InterpolatingFunction did not evaluate to it's data structure InterpolatinngFunction[<..>] suggests that it did not evaluate; and that's a bug. In principal one could write by hand the content of an InteprolatingFunction[] ( in theory) and there has to be an internal check that whatever is entered is actually a valid InterpolationFunction data structure - that check, my guess, did not like something when it got re-inported and rejected the data structure to be a valid InterplatingFunction` data structure. Nov 10, 2016 at 17:03