0
$\begingroup$

The code below as written works fine. The problem I am having is that if a replace "dat22" in the line "lhsp = lhs - dat22[[i]];" by "aps" which is a list with the same numbers but obtained from importing from an excel file, the program does not longer work and show me the following error:

"FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances."

If the two list are the same, except that the one imported generate numbers with " " such as "1.9", how can I make the list of "aps" work?. I want "aps" to work because it is generated from a file rather than manually inputting it as the case for "dat22"

dat20 = Table[{0}, {i, 20}];
dat22 = {{1.9}, {0}, {1.864806867}, {0}, {1.721459227}, {0},{1.539055794}, {0}, {1.348927039}, {0}, {0.95794}, {0}, {0.493563},{0}, {0.223777}, {0}, {0.134205674}, {0}, {0.090772532}};
aps={{1.9}, 0, {1.86481}, 0, {1.72146}, 0, {1.53906}, 0, {1.34893}, 0,{0.95794}, 0, {0.493563}, 0, {0.223777}, 0, {0.134206}, 0,{0.0907725}};
Do[
 int1 = Interpolation[dat15[i], InterpolationOrder -> 2];
 lhs = -Integrate[int1[x], {x, 120, 50}];
 int2 = Interpolation[dat16[i], InterpolationOrder -> 2];
 lhsp = lhs - **dat22**[[i]];
 rhs = -Integrate[int2[x], {x, 120, Tf}];
 rhsp = rhs - dat20[[i]];
 Tf1 = Tf /. FindRoot[lhsp == rhsp, {Tf, 73}];
 res[[(i + 3)/2, 2]] = Tf1;
 res[[(i + 3)/2, 4]] = mod2[i][Tf1] - mod1[i][Tf1];, {i, 1, imax, 2}
 ]
$\endgroup$
  • 1
    $\begingroup$ When "dat22" and "aps" are displayed in mathematica, the first one says: "Assumming a matrix" while the second one says "Assumming a ragged array". I think perphaps the fact that they are read differently may be the cause of the problem. $\endgroup$ – John Apr 15 at 2:32
  • $\begingroup$ Lists dat22 and aps are not the same. Even visually the structure of the lists is principally different. May be you don't see an absence of brackets around some numbers in aps? $\endgroup$ – Rom38 Apr 15 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.