Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to jog my memory of calculus from 10 years ago and it's proving a bit difficult. I'm hoping someone can give me a push in the right direction here. I've found a number of good resources online, but they're all either too far abstracted from my problem or too advanced. The concrete problem that I'm trying to solve is the following:

I'm writing a pagination function that uses $13$ discrete steps, i.e. there will be a maximum of $13$ links shown, regardless of number of pages. Now say I have $n$ total pages, and I'm on page $p$ where $1 \leq p \leq n$ (and for the sake of this discussion, $n > 13$). I need an equation that will yield $13$ links from $1$ to $n$, with the $6$ links immediately surrounding $p$ being pretty much linear - i.e., $45, 46, 47, 48, 49, 50, 51$ where $p = 48$ - and with the first and last step being the bounds - i.e., $1$ and $13$, respectively.

It looks to me like this would be something along the lines of $(x-s)^3/u + p$, where $s$ is the current discrete step (between $1$ and $13$) and $u$ is some variable that I don't know how to derive. I managed to come up with a quadratic equation that I could force to intersect with $(s,n)$, but I then I got lost trying to integrate it to achieve my cube equation..... I don't know, maybe I'm going way off in the wrong direction with all this.

Any help?

Update:

Really, this specific problem isn't the focus here. I've come up against this type of problem a number of times now and what's really bugging me is that I know there's an elegant mathematical way to solve it, but I can't figure out how. I'm basically trying to "mash" a graph into the given boundaries. The simplest way to think of it is to start with $f(x) = x^2$. This intersects $(-3,9)$ and $(3,9)$. Now say I want to move the vertex up to $(0,5.5)$, but I still want the graph to intersect those same two points. Then I want to move the vertex to $(1.2,5.5)$, but still intersect those points. See what I mean? It seems like the kind of thing where someone will come along and say "Oh, that's easy; you just do this, then plug in your numbers, then take the derivative of that" or something, but so far I haven't found that to be the case. Maybe I'm assuming this is much more trivial than it actually is. Am I wrong in thinking this shouldn't be terribly complicated?

Thanks, Kael

share|improve this question
    
If you're looking for a simple function that goes through particular points in the plane, you should start by checking out Lagrange interpolating polynomials: en.wikipedia.org/wiki/Lagrange_polynomial –  Greg Martin Apr 19 '13 at 7:10
    
While this will require a little more study on my end, I'm pretty sure Greg Martin's this is the path I was looking for. I'll be in the jungle for a while catching up on some of the background here, but I think this will lead me out. Please post it as an answer so that I can select it and mark the question as answered! –  kael Apr 21 '13 at 17:49

2 Answers 2

up vote 0 down vote accepted

If you're looking for a simple function that goes through particular points in the plane, you should start by checking out Lagrange interpolating polynomials.

share|improve this answer

To me this isn't a calculus problem at all. You want 13 links, and you've already told us what 9 of them are: you want the links to be 1, ?, ?, $p-3$, $p-2$, $p-1$, $p$, $p+1$, $p+2$, $p+3$, ?, ?, $n$. Why not just have the missing links interpolate linearly between the known values? So the sequence starts 1, $(p-1)/3$, $(2p-5)/3$, $p-3$ (rounding off).

You haven't told us much about what you want your link choices to achieve; this solution seems to match what you have told us.

share|improve this answer
    
Very true, this solution would work fine, and this is what I've implemented for lack of knowledge on how to create the function. See my update above. –  kael Apr 19 '13 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.