<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding index in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617790#M186357</link>
    <description>&lt;P&gt;Still not clear!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the input (apart from the vector) is a value, not an index, but the output is an index, &lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;correct?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;So a new question arouses: &lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;What, if the&amp;nbsp; input value is a number which does &lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;not occur in the vector? What should the function return? Error message, NaN, ORIGIN-1 (an invalid index)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;I'm referring to&lt;/SPAN&gt;&lt;/SPAN&gt; my answers above now&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;What should be returned if no suitable value is found? Maybe ORIGIN-1 or maybe NaN?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This is the case, if the vector is [1;2;3;4;-5;6] and your input is 3. There is no sign change before the 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;If b), what should be the output when the input is a value which occurs multiple times? I in your example vector, what would be the out for -1? Should it be &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;the index of the &lt;/FONT&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;1 or &lt;/STRONG&gt;&lt;/EM&gt;&lt;FONT color="#000000"&gt;the index of the&lt;/FONT&gt;&lt;EM&gt;&lt;STRONG&gt; 3 or both in a result vector? What is the output if the input is 1?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/199037"&gt;@fahmed-2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yes, it is considered as a sign change.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, just to be sure: [4;0;5] is a vector without any sign changes and [-4;0;-5] is considered a vector with two sign changes, &lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#800000"&gt;correct?&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Till now, my array will have different signed numbers so it will not be a case&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This does not matter as the function to be written has to cope with all &lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;eventualities. And even if there are always values with different signs in your vector it might happen that there are no sign changes in front of a specific value as written above. Furthermore you may chose the very first element of the vector which has no predecessor and of course no sign change before. It must also be specified how the program should react in this case.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2019 23:04:24 GMT</pubDate>
    <dc:creator>Werner_E</dc:creator>
    <dc:date>2019-07-12T23:04:24Z</dc:date>
    <item>
      <title>Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617731#M186351</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with an array of positive and negative numbers. My logic involves such that it has to find the index value of a changed sign number immediately above. For example, in my array, if I work with "-4" it has to find the index number of "2", not "3". Similarly, if I work with "4" it has to find the index number of "-5", not "-4". Please help me with this problem. My version is Prime 4.0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Faisal&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 17:14:48 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617731#M186351</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-12T17:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617783#M186353</link>
      <description>&lt;P&gt;Whats the input (apart from the vector) of the function your a looking for and whats the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the output&lt;/P&gt;
&lt;P&gt;a) the value with a different sign right before the input&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;b) the index of the value with the different sign&lt;/P&gt;
&lt;P&gt;As I understand your description its b). What should be returned if no suitable value is found? Maybe ORIGIN-1 or maybe NaN?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its the input&lt;/P&gt;
&lt;P&gt;a) the index of a value in the vector&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;b) the value itself?&lt;/P&gt;
&lt;P&gt;If b), what should be the output when the input is a value which occurs multiple times? I in your example vector, what would be the out for -1? Should it be 1 or 3 or both in a result vector? What is the output if the input is 1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What about zeros? Do the count as changed sign or not?&lt;/P&gt;
&lt;P&gt;What if the input value is zero?&lt;/P&gt;
&lt;P&gt;What should be the output if no value with different sign is found above the input value?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 19:46:00 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617783#M186353</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2019-07-12T19:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617785#M186354</link>
      <description>&lt;P&gt;The input will be an array of positive and negative numbers. Yes, there can be zeros and that should be considered as a positive. The goal is to find the index of a changed sign number just immediately previous.&amp;nbsp;&lt;SPAN&gt;For example, in my array, if I work with "-4" it has to find the index number of "2", not "3". Similarly, if I work with "4" it has to find the index number of "-5", not "-4". Please help me with this problem. My version is Prime 4.0.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 19:52:50 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617785#M186354</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-12T19:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617787#M186355</link>
      <description>&lt;P&gt;You haven't answered the questions!&lt;/P&gt;
&lt;P&gt;You simply repeated what you had already written in your first post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally:&lt;/P&gt;
&lt;P&gt;If zero is considered positive, then 5;0;4 would mean no sign change, bit -5;0;-4 is considers a sign change. Correct?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 20:13:48 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617787#M186355</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2019-07-12T20:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617789#M186356</link>
      <description>&lt;P&gt;yes, it is considered as a sign change. Till now, my array will have different signed numbers so it will not be a case where all has the same sign numbers. The input will be the values itself but my task is to find the index numbers where I have a sign change as mentioned previously. Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 20:24:51 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617789#M186356</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-12T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617790#M186357</link>
      <description>&lt;P&gt;Still not clear!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the input (apart from the vector) is a value, not an index, but the output is an index, &lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;correct?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;So a new question arouses: &lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;What, if the&amp;nbsp; input value is a number which does &lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;not occur in the vector? What should the function return? Error message, NaN, ORIGIN-1 (an invalid index)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;I'm referring to&lt;/SPAN&gt;&lt;/SPAN&gt; my answers above now&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;What should be returned if no suitable value is found? Maybe ORIGIN-1 or maybe NaN?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This is the case, if the vector is [1;2;3;4;-5;6] and your input is 3. There is no sign change before the 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;If b), what should be the output when the input is a value which occurs multiple times? I in your example vector, what would be the out for -1? Should it be &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;the index of the &lt;/FONT&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;1 or &lt;/STRONG&gt;&lt;/EM&gt;&lt;FONT color="#000000"&gt;the index of the&lt;/FONT&gt;&lt;EM&gt;&lt;STRONG&gt; 3 or both in a result vector? What is the output if the input is 1?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/199037"&gt;@fahmed-2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yes, it is considered as a sign change.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, just to be sure: [4;0;5] is a vector without any sign changes and [-4;0;-5] is considered a vector with two sign changes, &lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#800000"&gt;correct?&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Till now, my array will have different signed numbers so it will not be a case&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This does not matter as the function to be written has to cope with all &lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;eventualities. And even if there are always values with different signs in your vector it might happen that there are no sign changes in front of a specific value as written above. Furthermore you may chose the very first element of the vector which has no predecessor and of course no sign change before. It must also be specified how the program should react in this case.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:04:24 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617790#M186357</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2019-07-12T23:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617798#M186358</link>
      <description>&lt;P&gt;I am sorry I did not explain clearly. The main focus of my problem is to determine the index number when it had experienced a sign change in the latest past.&amp;nbsp;&amp;nbsp;If the problem does not experience a sign change then I have a separate approach for that. In my analysis, I have encountered an array which had several positive numbers and several negative numbers together and I need to find the index number where it last experienced a sign change. That is why I have shown the attached example as, if I work with "-4" it has to find the index number of "2", &lt;STRONG&gt;not "3"&lt;/STRONG&gt;. Similarly, if I work with "4" it has to find the index number of "-5", &lt;STRONG&gt;not "-4".&lt;/STRONG&gt; If you are concerned about what if the input does not match the given array then please consider that the input is based on the given array, it will not input anything outside that. And "0" is considered as a positive number.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:34:03 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617798#M186358</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-12T23:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617804#M186359</link>
      <description>&lt;P&gt;So your example "array" contains the numbers 1,-1,3,-1,2,-2,-3,-4,1,-5,1 and 4.&lt;/P&gt;
&lt;P&gt;What do you mean by: '&lt;FONT color="#FF6600"&gt;work with "-4"&lt;/FONT&gt; ', and how does that relate to the index numbers of "2" and "3"?&lt;/P&gt;
&lt;P&gt;Obviously "&lt;FONT color="#FF6600"&gt;-4&lt;/FONT&gt;" cannot be an index, but the value -4 occurs as 8th element in the array, that is at index position 7, because by default index starts numbering at 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to be MUCH more clear about what you want.&lt;/P&gt;
&lt;P&gt;Luc&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 17:59:56 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617804#M186359</guid>
      <dc:creator>LucMeekes</dc:creator>
      <dc:date>2019-07-13T17:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617809#M186360</link>
      <description>&lt;P&gt;Thank you for your answer. Let me start over again. I have an array that has a set of positive and negative numbers, not index values. The user will give an input that is within the given array of numbers. In the array, some positive and some negative numbers are placed side by side as attached in the example. The program is only meant to find the &lt;STRONG&gt;index number in the "earliest previous" within&lt;/STRONG&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;STRONG&gt;&amp;nbsp;the given array where it has an opposite sign.&lt;/STRONG&gt;&amp;nbsp;The word "work with" is meant to be "if the input is ".&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;For example, in my array, if the user inputs "-4" the program has to trace the index number of "2", &lt;STRONG&gt;not "3"&lt;/STRONG&gt;. Similarly, if the user input is "4" it has to trace the index number of "-5", &lt;STRONG&gt;not "-4"&lt;/STRONG&gt;. The program is not concerned what if there is no "sign" change. My version is Prime 4.0.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 21:03:58 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617809#M186360</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-13T21:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617810#M186361</link>
      <description>&lt;P&gt;I think I found a solution but I believe there is a much smarter and shorter way. Also, it does not do well if some numbers are repetitive. For example, I have two "-3" s and if I need to work with the later one, it will not give the right index value&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 22:00:01 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617810#M186361</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-13T22:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617811#M186362</link>
      <description>&lt;P&gt;Does this do the job?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Success!&lt;BR /&gt;Luc&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 22:36:00 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617811#M186362</guid>
      <dc:creator>LucMeekes</dc:creator>
      <dc:date>2019-07-13T22:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617812#M186363</link>
      <description>&lt;P&gt;No, it is giving me the number of the opposite sign but I need the index of that opposite sign number, not the number itself&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 23:17:29 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617812#M186363</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-13T23:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617813#M186364</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/199037"&gt;@fahmed-2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think I found a solution but I believe there is a much smarter and shorter way. Also, it does not do well if some numbers are repetitive. For example, I have two "-3" s and if I need to work with the later one, it will not give the right index value&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unfortunately you avoided to answer all of my questions, systematically one after the other.&lt;BR /&gt;The problem you experience with repetitive numbers was in fact already addressed by one of my questions - here is the question for the third time:&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;"If b), what should be the output when the input is a value which occurs multiple times? I in your example vector, what would be the out for -1? Should it be &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;the index of the &lt;/FONT&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;&lt;STRONG&gt;1 or &lt;/STRONG&gt;&lt;/EM&gt;&lt;FONT color="#000000"&gt;the index of the&lt;/FONT&gt;&lt;EM&gt;&lt;STRONG&gt; 3 or both in a result vector? What is the output if the input is 1?"&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;How should a program know which of the number -3's in your new example you would like to "work with" if you just provide the number -3 as input?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;I can think of different ways to deal with that situation:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;Always use the very first occurrence of the number and ignore the others (this is what Luc's approach and yours,too, are doing).&lt;BR /&gt;Given your remark it seems not to be what you want&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;Always use the very last occurrence of the number and ignore the others. I suspect this is also not what you want to happen.&lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;The program could return the result indices for ALL of the multiple numbers in a vector.&lt;BR /&gt;In your new example the result of input=-3 would be a vector with the elements 1 and 4, the indices of the second number 1 and number 2.&lt;BR /&gt;If this is what you like, you would further have to decide and say if you want the result be a vector in all cases or just when there are multiple results. &lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;Provide as input the index of the number you want to work with instead of the number itself. &lt;BR /&gt;For me this seems to be the most straightforward approach.&lt;/FONT&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Another unanswered question is the decision what you want to happen if no sign change is found. In your example this is the case when your input is 1. Your approach fails with an error and Lucs function returns NaN instead of an index number.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 23:34:44 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617813#M186364</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2019-07-13T23:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617814#M186365</link>
      <description>&lt;P&gt;Except the second one, I think I have addressed your questions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;1. What, if the input value is a number which does&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;not occur in the vector? What should the function return? Error message, NaN, ORIGIN-1 (an invalid index)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;My reply was:&amp;nbsp;&lt;SPAN&gt;If you are concerned about what if the input does not match the given array then please consider that the input is based on the given array, it will not input anything outside that&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;3.&amp;nbsp;What should be returned if no suitable value is found? Maybe ORIGIN-1 or maybe NaN?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;My reply was:&lt;SPAN&gt;&amp;nbsp;If the problem does not experience a sign change then I have a separate approach for that&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;Regarding number 2 problem, I think&amp;nbsp; your solution as "&lt;SPAN&gt;Always use the very last occurrence of the number and ignore the others" will fit my logic. Luc's approach is great but as I mentioned, I need the index number of the first occurrence of opposite sign number above,&amp;nbsp;not the number itself&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 23:46:02 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617814#M186365</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-13T23:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617819#M186366</link>
      <description>&lt;P&gt;If you want to ignore the first few values when you chose a value which occurs multiple times in your vector, then the attached file should help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concerning your answers: Sure the question about the value which occurs multiple times in the vector was the most important one and I am glad you realized yourself at last that this is a problematic situation.&lt;/P&gt;
&lt;P&gt;But as with the others - stating that this or that problematic situation will not occur as you will never enter an input value which has no sign change before, does not help much. In my opinion when programming a function, i&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;t must always be exactly determined what should happen in every possible input case. So even though at the moment you do not intend to input an invalid value, it must be defined what the reaction of the program should be if one day you do. The reaction could be a customized error message, or a return value which signals that something unusual had happened (could be a NaN or an invalid index value).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;Here is a routine which copes with the most obvious errors and I decided that the function should fail with an appropriate error message without returning any result.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B1.png" style="width: 494px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/17761iD6BB9785FA2136C5/image-dimensions/494x222?v=v2" width="494" height="222" role="button" title="B1.png" alt="B1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;You can find a version which uses if-statements instead of the if functions in the attached sheet.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;Without any customized error messages it could be reduced to&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B2.png" style="width: 308px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/17764iA6C82F764FED556F/image-dimensions/308x117?v=v2" width="308" height="117" role="button" title="B2.png" alt="B2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class="" title=""&gt;and here is yet another, different approach (could be a 1-liner which also works in Prime Express if you don't mind typing "ORIGIN" instead of just "O" five times) - again without error handling (which I still regard as a bad design error):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B3.png" style="width: 673px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/17765i5B716D5976CE4EC3/image-dimensions/673x71?v=v2" width="673" height="71" role="button" title="B3.png" alt="B3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BTW, you claimed that Luc's approach would not return the index but the value itself. Thats not true! Luc's function "f" returns the index as you demanded. He just showed after calling his function which value would be addressed. His version avoids programming and implements the necessary loops via recursive calls of an if-function. That way his approach also works in Prime Express. Its quite easy to modify his version to fit the new conditions. Additionally I got rid of the function "Sign" and changed the order of the arguments to bring it in line with my functions.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B4.png" style="width: 492px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/17766i06C0D17CEDB89F95/image-dimensions/492x105?v=v2" width="492" height="105" role="button" title="B4.png" alt="B4.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So its up to you now to decide for one of the versions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 02:37:49 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617819#M186366</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2019-07-14T02:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Finding index</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617940#M186388</link>
      <description>&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 15:39:38 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Finding-index/m-p/617940#M186388</guid>
      <dc:creator>fahmed-2</dc:creator>
      <dc:date>2019-07-15T15:39:38Z</dc:date>
    </item>
  </channel>
</rss>

