[Question]
  [
Given a sorted array of unique positive integers \$A\$ \$(A\_0<A\_1<\cdots<A\_{n-1})\$, and an integer \$t\$, where \$A\_0\le t\le A\_{n-1}\$. Output the value \$i\$ such that:
* If \$t \in A\$, \$A\_i=t\$.
* If \$t \notin A\$, \$ \left(i-\left\lfloor i\right\rfloor\right)\cdot A\_{\left\lceil i\right\rceil} +\left(\left\lceil i\right\rceil - i\right)\cdot A\_{\left\lfloor i\right\rfloor} = t \$. In other words, linearly interpolate between the indices of the two elements of \$A\$ that most narrowly bound \$t\$.
In the above formula, \$\left\lfloor i\right\rfloor\$ means rounding \$i\$ down to integer; \$\left\lceil i\right\rceil\$ means rounding \$i\$ up to integer.
You may also choose 1-indexed array, though you need to adjust the formula and the test cases below accordingly.
## Rules
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest code in bytes wins.
* Floating point errors in output are allowed, but reasonable floating point precision is required. For testcases listed here, your output should be correct with at least 2 decimal places precision.
* Fraction output is allowed as long as fractions are reduced to their lowest terms.
* It is fine to use any built-ins in your language. But if built-ins trivialize the question, consider submitting a non-trivial one too.
## Testcases
```
[42], 42 -> 0
[24, 42], 24 -> 0
[24, 42], 42 -> 1
[1, 3, 5, 7, 8, 10, 12], 1 -> 0
[1, 3, 5, 7, 8, 10, 12], 7 -> 3
[1, 3, 5, 7, 8, 10, 12], 12 -> 6
[24, 42], 33 -> 0.5
[24, 42], 30 -> 0.3333333333333333
[1, 3, 5, 7, 8, 10, 12], 2 -> 0.5
[1, 3, 5, 7, 8, 10, 12], 9 -> 4.5
[100, 200, 400, 800], 128 -> 0.28
[100, 200, 400, 800], 228 -> 1.14
[100, 200, 400, 800], 428 -> 2.07
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), 59 bytes
```
f=lambda l,t,p=0:l<[t]and 1+f(l[1:],t,l[0])or(t-p)/(l[0]-p)
```
[Try it online!](https://tio.run/##fY7RboMgFIbvfYpzV0jRAdLpTN1T7M6ZBSNdTRgapev29N1Bu6Vp4kg44fz/x3/O8O2PvZOXQ/mK1@qPptVgmWdDyQu7r3ytXQtieyC2EkWNhq14TfuR@HigDyR0@Licj501IIoINIMGShj1@a1zw8kTmkyD7TzZQPwMGxphPDgkzKe2RGPfO4Noa75Mi/LLeDIReD2@G/9LNRS2t1gEo5nQxK0YHGyvPXEUk4axcz54DHQzkWtIHBQKexAm3l0qJWsGSoZteFRJFRpUpLpXFkZElWCQMtgxyBjkDATHGwBx/bHmZ8FP//k/D3i8GZmmc2Syu9X4oqV3Zz1X/oWsEU@BUDPBUZOhqFByzufF8iVC5iuEXAiRCLVCqIWQCc9@AA "Python 2 – Try It Online")
Outputs one-indexed. Recursively loops through the list element , each time adding `1` to the eventual index output, until reaching an element that's at least `t`. Then, outputs the fraction of the way `t` is between the current element and previous element `p`. This avoids needing to explicitly track which index we're at.
**62 bytes**
```
lambda l,t:sum(t>y or(t-x)/(y-x)for x,y in zip([0]+l,l)if x<t)
```
[Try it online!](https://tio.run/##fY7RboIwFIbveYpzZxsLa0udzKhPsTtmlhLLbFILgTphL89acIsxwSY9yfn/7/zn1L07VZYP5e5jMPJcHCUY4jbt5YzcvoeqQS7u8AvqfS2rBjrSg7bwo2uU08PSEIN1Cd3W4eF60kYB20QgCRSwg0ZeP7WtLw7hpK2NdmgB8R4WOPI7wHpCfUuDpO8rqzx6VJ06evm9uagInGy@lPujCgzLeyyCRrXeLJHPKk0lHbLYJ9WNti54BGTRoltIHBQMW2AqXg254AcCgodraJRzERqvcPGoTAyLckYgJbAisCaQEWDU/wCw28Scvw5@@mR@XPB6tzJNx8hkda/RSUsf3nwu/w@ZI94CIUaCeo2HIkLJKB0Py6YIns0QfCJYwsQMISaCJ3T9Cw "Python 2 – Try It Online")
One-indexed. Same idea as the 64-byte code below. Interprets the input as "intervals" `(x, y)` of two consecutive elements of the list, starting with left endpoint `0`. The output is the sum over each interval of the fraction of it that's less below `t`, which is `1` for intervals fully below `t` and `0` for those fully above it.
```
lambda l,t:sum(min(1,max(0,(t-x)/(y-x)))for x,y in zip([0]+l,l))
```
[Try it online!](https://tio.run/##fY7RboMgFIbvfYpzV0jRAeLqmnVPsTvXLJjiSoJolK52L@9Au6VpYkk4yfn/7/zntBd3bCwfq93HaGRdHiQY4rb9qUa1toiRWg6IEuTiAT@hi68YV00HA7mAtvCjW1TQ/doQg/F4PmqjgG0jkARK2EEnz5/atieHcNK3Rju0gvgNVjjyW8B6Qn1Lg6TvG6s8elCDOnj5vTupCJzsvpT7o0oM61ssgk713qyQz6pMIx2y2Ce1nbYueARk2aNrSBwUDK/AVJyNheB7AoKHa2hUcBEar3Bxr8wMiwpGICWQEdgQyAkw6n8A2HViyd8EP30wPy14vlmZplNkkt1qdNbSu7ecy/9DloiXQIiJoF7joYhQckqnw/I5gucLBJ8JljCxQIiZ4And/AI "Python 2 – Try It Online")
The summand is `(t-x)/(y-x)` clamped between 0 and 1.
[Answer]
# [Python](https://www.python.org) 3.10, ~~79~~ ~~75~~ ~~67~~ ~~65~~ 59 bytes
```
lambda a,t:(t-a[i:=sum(x<t for x in a)])/(a[i]-[0,*a][i])+i
```
[Attempt This Online!](https://staging.ato.pxeger.com/run?1=fZBBboMwEEXVbU4xyspODR0bp1AS9wTZdUlZOCqoSAQQOCQ9SzeRqvZO7WmKcVRFkaglj2b-vPlj-f2reTOvdXX6yNXz597kXvS9KvVu-6JBMxMT4-mkiFW335Hj2kBet3CEogJNU3pHhl7qJcgWOh0yelucLZ4st7Fc3WQVQRpnrFcbv2vKwpA5eI8wp6umLSpD2ljlZJH1uiQZpewQqzHvKdPbjrTega59RE6d9ennpkukSBlIYW1wlghpi0ER8lpxDJ8lnEHAYMkgZBAx4DhcC_DzxFQ_tP3gn_lxwf3FyiAYLf3lpYZOC67OtK_4M5kiHiwhRwIHTdggbYgQx4dFzkJEE4RwBPe5nCCkI4SPofv8Xw)
Needs Python 3.10 to use `:=` inside a subscript.
* `t-a[0]and` guards against the edge case where `a` has only one element
* `sum(x<t for x in a)` finds the index of the first item `x` where `x<t`
* `(t-a[i]/(a[i+1]-a[i])+i` just does the linear interpolation
-4 bytes thanks to Kevin Cruijssen
-6 bytes thanks to tsh
-6 bytes thanks to xnor
[Answer]
# [MATL](https://github.com/lmendo/MATL), 10 bytes
```
YYhtfi3$Yn
```
Inputs are *A*, then *t*. The output is 1-based.
[Try it online!](https://tio.run/##y00syfn/PzIyoyQt01glMu///2hDAwMdBSMQYQIiLAwMYrkMjSwA) Or [verify all test cases](https://tio.run/##y00syfmf8D8yMqMkLdNYJTLvv0vI/2gTo1guEyOuaCMTHQUQ28gEwQaJG@ooGOsomOoomOsoWOgoGBoAMVDKEKeMOW49SNYYGyOxDXBqwe0AS6CMAZBtBCJMQISFgQHIDgvsEka4JEyMLAA).
### Explanation
```
YY     % Push infinity
h      % Implicit input: row vector A, of length n. Concatenate. This attaches
       % infinity at the end of the vector. This is necessary because
       % interpolation requires a vector of at least 2 entries. The value
       % infinity is used so that it doesn't interfere with the interpolation
tf     % Duplicate, find. This gives the row vector [1 2 3 ... n+1]
i      % Input: integer number t.
3$Yn   % 3-input linear interpolation. Implicit display
```
[Answer]
# JavaScript (ES6), 45 bytes
Expects `(t)(A)`.
```
t=>g=([c,...a],p=0)=>t>c?1+g(a,c):(t-c)/(c-p)
```
[Try it online!](https://tio.run/##hdLBDsIgDAbgu0/BEWLHoKBDE@aDLB4W1EVjZHGLrz/ZdpIt0gRO/fKXhkf9qTv3vrd99vKX63CzQ2/LxtLKAee8PkNrBbNlX7qT3Da0BseOtM8cy6nLWjY4/@r888qfvqE3qpHRSuOZMbJSeU7E5hegDgA1kFW0AqaEf0BGQIZ@CUQB2QEpgBggUoQz85WEIgVUnID/RAD7CCiVejTfxUQkiYoq3nRyD4vQQ4roBZFoRiRCG46XHi8jxDz0lIImnixlJJd68Q0SBrkohi8 "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/) + numpy, 52 bytes
```
lambda a,t:interp(t,a,argsort(a))
from numpy import*
```
[Try it online!](https://tio.run/##fY5NbsMgEIX3PsUoK4ioxV9iN5F7gtzA7YK2uLWEAWFqKad3jYmqKJKLxKB58703@Gv8dlbMXfM6GzW8fypQJJ56G3XwKBJFVPgaXYhIYVx0wQ1gfwZ/hX7wi7qf83sT1QjWF50LcIHegvPaIopPmkzNpRy96SPawdML7PA5NB3a60kZpDE@@7BsRIFYXypjPowb9dKt4wljPLeSvxGQPJlp0XKZmkXh8lHJDCtaRkAQOBCoCNQEGF1uAtjNsTWv0lz8418XHO9WCrFGlod7jWZNPJztXP4XskU8J0KuBF00nopMpaZ0/VidI3i9QfBMsJLJDUJmgpe0@gU "Python 3 – Try It Online")
As `a`is sorted with no duplicates we can use `argsort` to save a byte over `r_[:len(a)]`. Note that the "no duplicates" is important because numpy doesn't use timsort by default but an unstable qsort.
# or (same length)
```
lambda a,t:interp(t,*unique(a,1))
from numpy import*
```
[Try it online!](https://tio.run/##fY7dasQgEIXv8xTDXmmwwb9t0l3SJ9g3SHthW0MDRq35gX36NMalLAup4Mic@c4Z/XX8dlYsbf22GNV/fClQZDx1dtTBo5Hkk@1@Jo0UYRhnbXA92Kn3V@h678KYL@m9iWoA67PWBbhAZ8F5bRHFJ03m@lIM3nQjOsDTKxzwOdQtyvWsDNIYn31YN6JArC@UMZ/GDXrttvGMMV4ayd8JSB7NNGu4jM2qcPmoJIZlDSMgCBwJlAQqAoyuNwLs5tibl3Eu/vFvC57vVgqxRRbHe40mTTyc/Vz@F7JHvERCbgRdNR6LjKWidPtYlSJ4tUPwRLCCyR1CJoIXtPwF "Python 3 – Try It Online")
This uses `numpy.unique` (which is a nop on `a` since `a` has sorted unique values) with the `return_index` switch set. This returns the indices of the unique values v in the input. As `a` has sorted unique values this returns 0,1,...,len(a)-1
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), ~~18~~ ~~17~~ ~~13~~ 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
-D¹¥/ā+s®›Ïθ
```
First input is the list \$A\$, second input is \$t\$. The output \$i\$ is 1-based.
-1 byte switching to the legacy version of 05AB1E, where `[1]/[]=[1]` instead of `[]`. In the new version of 05AB1E we therefore had to add a `1š` before the `θ` to account for single-item input-lists. Unfortunately, `d` was `is_int` instead of `>=0` in the legacy version, so we have to replace it with `®›` (`>-1`) instead, netting at -1 byte.
[Try it online](https://tio.run/##yy9OTMpM/f9f1@XQzkNL9Y80ahcfWveoYdfh/nM7/v@PNjQw0FEwAhEmIMLCwCCWy8TIAgA) or [verify all test cases](https://tio.run/##MzBNTDJM/V9Waa@k8KhtkoKSfWVCsUvof12XiENL9Y80ahcfWveoYdfh/nM7/utoxvyPjo42MYrVAWGF6GgjEzDLyASZB5Uz1DHWMdUx07HQMTTQMQSKGSIJmyOEzbELG6LYYGyMwjPArscIu7AlRNjAQEfBCESYgAgLAwOQJRY45YzwyJkA5WIB).
**Explanation:**
```
-             # Subtract each value in the first (implicit) input-list from the
              # second (implicit) input-integer
 D            # Duplicate this list
  ¹           # Push the first input-list again
   ¥          # Pop and push its deltas / forward differences
    /         # Divide the items at the same positions in the two lists
     ā        # Push a list in the range [1,length] (without popping)
      +       # Add that to each value in the list
       s      # Swap to get the duplicated list again
        ®›    # Check for each whether it's larger than -1 (non-negative)
          Ï   # Only keep the items at the truthy indices
           θ  # Pop and leave the last item
              # (after which the result is output implicitly)
```
[Answer]
# [R](https://www.r-project.org/), ~~57~~ 55 bytes
Or **[R](https://www.r-project.org/)>=4.1, 48 bytes** by replacing the word `function` with `\`.
*-2 bytes thanks to [@Dominic van Essen](https://codegolf.stackexchange.com/users/95126/dominic-van-essen).*
```
function(A,t,r=which(A>=t)[1])r-((A-t)/diff(c(0,A)))[r]
```
[Try it online!](https://tio.run/##fY7BCoMwEETv/YqFXhJYbbKJmB4U8h3iyRL00oKk9POtUQNVGgNZyMzLzI6Tqyb3fnZ@eD2ZRY9j9emHrme2rjxvZMvHjDGbeX57DM6xjgm0nPNmbKfw0sQR5nGFrAZ5CRLpRUEg/VeONC2yRFAIBUKJYBCkmG@g5O/fFFSukD5P2vrK/RpKbQ15cTBENNThnNbQPi6F3VesiJiYDQpDh2GEWDY2MYxMGqOIUS51GtMRU7kopy8 "R – Try It Online")
1-indexed.
I couldn't make any built-in linear approximation work, but ~~it doesn't mean that such solution doesn't exist~~ [@Dominic van Essen could](https://codegolf.stackexchange.com/a/237244/55372).
[Answer]
# [Haskell](https://www.haskell.org/), 42 bytes
```
q 0
q p(h:r)t|h<t=1+q h r t|d<-h-p=(t-p)/d
```
[Try it online!](https://tio.run/##fZDBDoIwEETvfsUcPJTYxlJqRAOf4BcgB6JijdUU2CPfbi3qRRN72MlOXiazWdMM15O1vi33voOcdXDMbPuERlNQmS46GPSg8VgII1zJSLhkefR0GmhAiYpVWtUcWiUcrFJ6WoNX@tt/eMqRcaw41hw5RyrDTDiN0nU8@1OdZT9eRuPxwzZvKoNXk@hJcilfvfl/qGJQB1jPbs3lHj54a9wOrr/cCXNULSwII5jloASFwOvTtX8cWtucBy8Ozj0B "Haskell – Try It Online")
Main function is `q 0`, outputs one-indexed.
**43 bytes**
```
l%t|let(h:r)?p|h<t=1+r?h|d<-h-p=(t-p)/d=l?0
```
[Try it online!](https://tio.run/##fZDBasMwEETv@Yo5JCARicqyStxi4S/oFxgfTGJHoUoQ9h797VXltJcEosMOOzyGWdb18/fgfYx@R4sfiLnPiTdhcTXZYj81bjnV0slgGcnA307WNyqOlu34hoaZZli0rDW6EzCaC7BWm3VNXptH/88LgVLgXeAgUAkUKs2Kiyw95LNP1WX55FU2nj/s44@q5PUqZpVKqXtv9RrqHDQJdptrf7mlD1778IUwXW6ELdoRHoQFzAsQRy1x/3QXf46j789zlMcQfgE "Haskell – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 25 bytes
```
ＩΣＥθ∧κ⌈⟦⁰⌊⟦¹∕⁻η§θ⊖κ⁻ι§θ⊖κ
```
[Try it online!](https://tio.run/##fY0xC8IwEIX/yo0XOKGxiIOT2MWhIDiGDCEJNNhETdPSfx/PunsHx@PxvXd2MNk@zVjrLYdU8GKmgvc5Ym9e@CY4J4cPgt6sIbKrGtYh/bQk6MISnEe25gkHxss1Ob9@k5232UefiucGIcQWZCr8pYTm3eZUq1J7gpbgQHAkkPxPtppPo@tuGT8 "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Port of @xnor's 64-byte Python solution.
```
   θ                        Input array
  Ｅ                         Map over elements
     κ                      Current index
    ∧                       Logical And
              η             Input value
             ⁻              Minus
               §θ⊖κ         Previous element
            ∕               Divided by
                    ι       Current element
                   ⁻        Minus
                     §θ⊖κ   Previous element
         ⌊⟦¹                Clamp above to 1
      ⌈⟦⁰                   Clamp below to 0
 Σ                          Take the sum
Ｉ                           Cast to string
                            Implicitly print
```
[Answer]
# [Perl 5](https://www.perl.org/), 75 bytes
```
sub f{($t,$a,$b)=(@_,9e9);$a<=$t&&$t<=$b?($t-$a)/($b-$a):1+f(@_[0,2..$#_])}
```
[Try it online!](https://tio.run/##jZJLb4JAFIX3/ooTOwrYKw7DWEVLdd@kbrqzxEAKjX2IRZq0Mf52OjO46EOjCcyd3PPdc@5i1mnx2q@qzUeCbGuzklhMLHFCe7qgIA2cMYuvQ1a226xUNZkopMtip2ezRNeRd5kpdM5JuC67WETOrsrywm4Ac/VJERGkQHgDDkS0bwupu0oS8qhUT3k/JI/gE/qEAWFI8Lj6Nen99TgGDjTon@Nosq8OreX7Js3tHxS52bl3Tob473MMDTQqf6NciUIfUh9Dzs3aw9pU1ROoqFHP9eQpVNaocPnAoM5W0W9fNouLgvSDST/XTjhli7Hpgz3lZZjppzTViKPb62K5KrNmqxtsgFZXcFXKEVr@IwA1r66qAzWpbw@rpt4I0NZI340lJrDyFwsjWJ1O5252j9mtVWPP@XJlW2TtAwkq28ySmRw3do3qGw "Perl 5 – Try It Online")
Perl5 versions from 5.32 (TIO has 5.28) got [chained comparisons](https://metacpan.org/release/XSAWYERX/perl-5.32.0/view/pod/perldelta.pod#Chained-comparisons-capability) capability which means `$a<=$t&&$t<=$b` can be shortened to `$a<=$t<=$b` and save 4 bytes.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 50 bytes
```
f=->l,n,z=0{a,*l=l;a<n ?1+f[l,n,a]:1.0*(n-a)/a-=z}
```
[Try it online!](https://tio.run/##KypNqvz/P81W1y5HJ0@nytagOlFHK8c2xzrRJk/B3lA7LRoknhhrZahnoKWRp5uoqZ@oa1tV@79AIS062sQoVgeIucAcIxMQW8fYGMo3NDDQUTACESYgwsLAIBbINLKI/Q8A "Ruby – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 41 bytes
```
function(A,t)approx(B,seq(B<-c(A,0)),t)$y
```
[Try it online!](https://tio.run/##fY7BCsIwEETvfsWCHhLYlmSTkggq2D@RYsFLq7WCfn1M2gZsMQ3sHmZeZrZz9dHVr6bqb23Dztjzy/3etW9W4vP6YOUhq7wqOPfO7uNqVjFNHMGvLWQnkJsgkR4UBNJ/5UjTIEsEhVAgGASLIIWfQMnfvynIjJBeT5r6zPwMpaaGvFgYIhpq8VZraB6XwvYjVkRMeIPC0mFZIYaLbQwjm8YoYpRLncZ0xFQujPsC "R – Try It Online")
Almost-trivial use of `approx` built-in: upvote [pajonk's non-trivial R answer](https://codegolf.stackexchange.com/a/237234/95126) instead...
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 44 bytes
```
Sum[(i=0;{1/(#-i),x<=(i=#)}&/@#2),{x,#}]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7P7g0N/p970KNTFsD62pDfQ1l3UxNnQobW6CAsmatmr6DspGmTnWFjnJtrNr/gKLMvJJoZV27NAcH5Vi1uuDkxLy6aq5qEyMdIK6t1eGqNjLRAWEoDySB4CkY6lQb6hjrmOqY61joGBroGELFzbGLGxphFzc2RjbV2ACZh0OLJS4bLIASBgY6RkBsAsQWBgYQY3BJmGCV4Kr9DwA "Wolfram Language (Mathematica) – Try It Online")
Input `[t, A]`. Returns 1-indexed.
The private-use character is `\[Piecewise]`, which is usually a less byte-efficient `If`/`Which`.
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~74 71~~ 63 bytes
```
float r;f(*a,t){for(r=0;*a<t;r++)a++;r-=(*a-t)/(*a-*--a+1e-9);}
```
[Try it online!](https://tio.run/##jZR9a4MwEMb/91Mcg4HWpE1ifCPrvsg2Rii1FDo7rLBC8avPJcZKZmtqwAje77m75B7c4M1Blru2LQ5HWUMlCn8hUR1cimPlV2siFvKlFlUYBjIMRYXXKozrYKVfC4xlSLc4D0TTfsl96QcXD/ZlDfX2VH@e3z7WF4rybjXCihAd4awRqxVwBvgViBWlOso4gp5gfEywEWFyUIuITG2IEMQIUgQZAkrUYwR0nJG7@VTzkcXHD/J3DSWWIBm1HEVdC8vYYtIxQwwTjZYlydx9sNsiuVuRawX/p6DduChRENMb11tGSH/SzNRgmS2hDgkzErqk3JYwh4QbCVuS1PPAg8I3PtJXBYGA70rlKfyn5@K9fEJQqU9KRQZQnVe5aAbI3BnpAKrro3MSqmmm01w0cLGewDSYDGCCtHemK@vR9agarrKQA701Vq9UnmDzauRIWWaS5BZpTJa50moPXWk9Mhdt7HOlu7k56M45V/qMWCDucBbQ/bOyRxSdlSa/TzXt76Y4yN2pxT9/ "C (clang) – Try It Online")
* Saved 3 thanks to @upkajdt suggestion to use a variable instead of printing it.
* Saved 5 thanks for @ths suggestion to make divisor ~0 by adding *1e-9* to it.
* Saved another 3 by using *float r* instead of *int n* as index counter.
[Answer]
# [Haskell](https://haskell.org), ~~76~~ ~~73~~ 71 bytes
```
s!x|(t,y:_)<-span(<x)s,u<-last$0:t=fromIntegral(length$t)-1+(x-u)/(y-u)
```
[Try it online](https://tio.run/##hY7NCsIwEITvPsUKHhLcappGrFIfwGcQkSDxB2OUJJUWfPeaKOihYA47MDMfy5ykuyitu84Nmyfx2C53tMrcXRpSNdRhXWVaOj9iS7862Nt1bbw6WqmJVuboTyNPs3xMmqymU9IG7a7ybGAF3sqHsk4Buduz8TCB2uxra1sgQ0oHABsgG8G3CIJHi8FyEV2IuOhFPypHKBBmCHOEEiFn4SKRp4B58kN/SVH0I5b6k5y6@AIsRDyKiFIy9p5R/u15ohefftu9AA)
(I hate explicit conversion (in golfing))
[Answer]
# APL+WIN, 42 bytes
Prompts for vector followed by integer. 1 indexed.
```
(m/⍳↑⍴m)+(i-m/v)÷(m←<\(i←⎕)≤v)/v-¯1↓0,v←,⎕
```
[Try it online! Thanks to Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcQJanP5BlyPWooz3tv0au/qPezY/aJj7q3ZKrqa2RqZurX6Z5eLtGLlCNTYxGJpACatF81LmkTFO/TPfQesNHbZMNdMqA4jpAif9AU7j@p3GZGIFQGpeRiQKQNjKBM8GihgrGCqYK5goWCoYGCoZGClyGWAQVuIwxRbkMEaYaGyOYBliUYrGJyxIkZmCgYATEJkBsYWAANNICi6gRVlETIwsA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/) + `-M5.10.0 -a`, 57 bytes
```
$_>"@F"&&$p<="@F"?say$.-3+("@F"-$p)/($_-$p):0,$p=$_ for<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3k7JwU1JTU2lwMYWxLIvTqxU0dM11tYA8XRVCjT1NVTiQbSVgY5Kga1KvEJafpGN3f//JkYWXIYGBlxGQGwCxBYGBv/yC0oy8/OK/@sm/tf1NdUzNNAzAAA "Perl 5 – Try It Online")
## Explanation
Naiive approach, but using some Perl var tricks.
`-a` stores the first input value (the target) in `@F` which, since we know will only be one value, we can access via `"@F"`. With this we can loop through all other lines of input (`for<>`) checking if we're greater than the current value and if the `$p`revious was less than of equal to the target and the current (`$_`) is greater than the target then we output (`say`) the current index (`$.` holds the current, 1-indexed, line of input being processed) plus the ratio of the differences between the current and previous, and previous and target.
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-x`, 36 bytes
```
Yb>=_FIa#y-:$/(-[bMXy]+MN:b<=_FIa)|1
```
Takes the array and the number as command-line arguments. [Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgWbSSboVS7IKlpSVpuhY3VSKT7Gzj3TwTlSt1rVT0NXSjk3wjKmO1ff2skmzAEpo1hhC1UC07opWiDa2NrU2tza0trA0NrA2NYpV0FMxhRgIA)
### Explanation
```
Yb>=_FIa#y-:$/(-[bMXy]+MN:b<=_FIa)|1
       a                              Input array
     FI                               Filter for elements where
 b>=_                                 Input number is greater or equal
Y                                     Yank that list into y
                              FIa     Filter input array for elements where
                          b<=_        Input number is less or equal
                       MN:            Minimum such element
                      +               Plus
               -[    ]                Negative of each of these:
                 b                      Input number
                  MXy                   Max of y (elements <= b)
                                      We now have a list containing two distances:
                                      from the first element larger than b to b,
                                      and to the last element smaller than b
            $/(                  )    Divide the first by the second
                                  |1  If the result was 0 or division by 0,
                                      substitute 1 instead
          -:                          Subtract that result from
        #y                            Length of y (elements <= b)
```
]