Forum Moderators: open

Message Too Old, No Replies

what's that equation?

         

lucy24

10:27 pm on Feb 4, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This headscratcher first arose in connection with my website, but it is not actually a webmastering question.

It goes like this:

In the ebooks area of my website, I have a bunch of titles, currently approaching 100. These in turn are grouped into categories. For whatever book you are currently reading, the navigation header will show all the categories, plus all the titles for the current category:

GROUP1 GROUP2 GROUP3: title1 title2 title 3... GROUP4 GROUP5

and so on. The total number of items in the header--assuming the same number of titles in each category--is therefore
c + t/c
where
c = number of categories
t = number of titles
and 0 < c < t. (It doesn’t have to, of course--I could have empty categories--but let’s be reasonable.)

The challenge is to keep the navigation header as short as possible. I found by trial and error that this is best achieved by letting c be as close as possible to sqrt(t), for example 100 titles : 10 categories.

But math isn’t about trial and error, it’s about formulas and exactitude. I’ve got a vague idea that I want the derivative of something-or-other to be zero (value goes up at either end, and bottoms-out in the middle, like a lopsided parabola)--but what am I taking the derivative of?

NickMNS

3:24 am on Feb 5, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



But math isn’t about trial and error, it’s about formulas and exactitude.

I'm not sure I agree with that, there are times when brute force is the only solution. Solving cryptographic hashes (think bitcoins) is such an example.

However, sometimes there are situations where an approximation can lead you to close to the correct answer.

Let me start by re-stating your problem to be sure that I understand it. If you have 36 titles, you would like to split them up into 6 groups such that each group has 6 titles, such that the number of titles is close to then number of groups. As opposed to having 3 groups with 12 titles where now one has few groups but many titles.

The exact solution is to find the median factor(s) of the number of titles. Eg: For 100 titles, 100 has factors, 1,2,5,10,20,50,100, where the median is 10. For 99 => 1,3,9,11,33,99 median = 9,11. But if you are unlucky and land on a prime number say 113, the median factor are 1, 113 in which case even that solution does not work.

But the astute observer will notice that 10 is sqrt of 100. So taking the square root of the number of titles, may not produce the exact answer but it will lead you very close to an optimal solution. For 113 the sqrt is 10.63... 10 x 11 = 110, so 3 categories will have one extra title. For 356 sqrt = 18.86... 18 x 19 = 342 so 14 extra titles.

lucy24

12:27 am on Feb 13, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I concurrently presented this question to

(a) an old friend who recently retired from teaching mathematics
(b) my son, who majored in math

in hopes that all three would yield the same result--which, again, is what one hopes for in mathematical venues. Alas, my friend has--like me--forgotten all the calculus she ever knew (someone else generally taught it), but son came through. Treating t (number of titles) as a constant and c (number of categories) as the variable:

y = c + t/c
dy/dc = 1 - t/c^2
0 = 1 - t/c^2
=>
c = sqrt(t)

Whew. It would admittedly be better if I had been able to work this out for myself, but it's reassuring that at least I can still understand it when someone else does the work.