Firstly the (2 STEP) misses a comma
but that's not the only problem.If running the second step, have a close look to the iteration variable j
which is used as index too
Out[10]= {Interval[{2.35475, 2.84411}], Interval[{1.25677, 3.21293}],
Interval[{1.25677, 3.20553}], Interval[{1.25677, 3.25203}],
Interval[{5.511, 5.58272}]}
During evaluation of In[10]:= 1)Interval[{1.25677,3.25203},{5.511,5.58272}]
During evaluation of In[10]:= width of interval {1.25677,3.25203} : 1.99526
During evaluation of In[10]:= width of interval {5.511,5.58272} : 0.0717154
In[17]:= (*2 STEP*)myintervals2 =
Reap[For[j = Min[myint1[[1]]], j <= Max[myint1[[1]]], j++ ,
If[spfn[[j]]*spfn[[j + 1]] < 0 && spfw[[j]]*spfw[[j + 1]] < 0,
Sow[Interval[{Min[-spmn[[j]]/spkn[[j]], -spmw[[j]]/spkw[[j]]],
Max[-spmn[[j]]/spkn[[j]], -spmw[[j]]/spkw[[j]]]}]]]]][[2, 1]]
During evaluation of In[17]:= Part::pkspec1: The expression 1.2567695073246514` cannot be used as a part specification. >>
During evaluation of In[17]:= Part::pkspec1: The expression 2.2567695073246514` cannot be used as a part specification. >>
During evaluation of In[17]:= Part::pkspec1: The expression 1.2567695073246514` cannot be used as a part specification. >>
During evaluation of In[17]:= General::stop: Further output of Part::pkspec1 will be suppressed during this calculation. >>
During evaluation of In[17]:= Part::partw: Part 1 of {} does not exist. >>
Out[17]= {Null, {}}[[2, 1]]
Print["2)", myintervals2]
In[18]:= Min[myint1[[1]]]
Out[18]= 1.25677
In[19]:= Max[myint1[[1]]]
Out[19]= 3.25203
Do you see it? j
runs from real 1.25677
to real 3.25203
and is used as index to expressions. But expressions in Mathematica do not have real indices, see Part. Interestingly enough they do not state that Part
takes only integers or lists of integers but they seem to understand that by using symbols like i
, j
, ... usually meaning integers in mathematics and physics.
See Round, Floor, and Ceiling to make reals into integers.