PDA

View Full Version : Maths problem!



kyuzo
10-16-2015, 04:34 AM
I have a maths problem (for work) which I can't get my head around. I'm normally okay with these sort of things, but I'm stumped with this one.

The boring explanation:
We use a DTP package which allows a font to be given a base size, but allow it to scale up automatically by a certain amount.
eg, if the base font is 100pt, and it is allowed to vary by 50% then:
The upper max font size is calculated as 100pt x (1+0.5) = 150pt.
The lower font size is calculated as 100pt / (1+0.5) = 66.666pt.

I want to be able to specify two font sizes as the max and minimum, and work out what the starting font size needs to be, and what % modifier can be applied.

So I have two equations..
Fontsize1 * X = Y
Fontsize2 / X = Y.

Given specific values for Fontsize1 and Fontsize2, how the hell do I determine what X and Y are? Without endless trial and error?

Cheers!

Derek

RebelHill
10-16-2015, 05:16 AM
You're stuck because your initial working is wrong... if the scale can vary by 50% (or *0.5) in either direction (+/-), then the lower calculation is wrong. It is not... size/1.5... it should be... size*(1-0.5) (=50pt). [if you take 100 and scale it down 50%, the answer is clearly 50, not 66.x]

Ergo, to set bounds on the size range, discover the start point, and the multiplier...

let the smallest size be Fmin, the largest Fmax, the start/base size be Fbase, and the multiplier be m... then...

Fbase = (Fmin+Fmax)/2

m = 1-(Fmax/Fbase)

Which in turn yields...

Fmin = Fbase*(1-m)
Fmax = Fbase*(1+m)

kyuzo
10-16-2015, 05:46 AM
Hi Craig,

Yeah, I assumed it would work the same way you did... And if I was designing it, I'd do the same. (Or even easier, just give an option for a 'min' and 'max')

However after putting numbers into the actual software, I discovered that not to be the case. After testing numerous examples and tryig to see what the smallest and largest font size they output, I was able to reverse engineer the actual equations it's using to modify the base size.

When I enter 100pt as the base font size, and 25% as the variance, I get a min value of 80 and a max value of 125
When I enter 100pt as the base font size, and 100% as the variance, I get a min value of 50 and a max value of 200

This software I'm using makes Microsoft products look intuitive...

MarcusM
10-16-2015, 05:54 AM
You counting 100pt like it have already tax included ;]

kyuzo
10-16-2015, 06:13 AM
I've not found a pure maths solution, but have managed to find a way to calculate the answers I need.

Wonderfully, it is a Lightwave-based solution.

I created two Nulls, 'Max font size' and 'Min font size'.
I created two more nulls 'Max font scaled' and 'Min font scaled'
I created a null called '% multiplier'.

Using a scale of 1m = 100pt, the 'max/min font scaled' nulls had nodal motion modifier applied to reverse engineer the relevant equations, using the position of the '% multiplier null'.

By setting the positions of the max and min font sizes, and sliding the multiplier null up and down, I could see the values for the '% multiplier' and the position where the 'scaled' nulls intersected.
This then gave me values for the base font and the % multiplier.

Phew. What a palaver. Still, good to know that LW is useful for more than making pretty pictures!

RebelHill
10-16-2015, 06:58 AM
well... kudos on your working. You've not ofc found a solution, you've essentially built a calculator. This kind of creativity is perhaps more important in problem solving than finding formal solutions.

However...

I see now that the problem stems from the way your program itself is designed... so either it was purposefully designed that way by the programmer (who can say why, it seems an odd choice), or they themselves made the mistake in their own math I outlined to begin with.

As it stands though, what you have here is a problem which requires the solving of simultaneous equations (which can be hard)... technically speaking, the first answer I gave was a form of this... just VERY simple.

So, to view it in those terms... let us formalise what we know...

Fmin = Fbase/(1+m)
Fmax = Fbase*(1+m)

We could also write this more shorthand as high,low,base,mutliplier (h,l,b,m) to use...

h = b/(1+m)
l = b*(1+m)

where we solve for the variable b and m with respect to l and h

The working is a bit of a muddle, and I dread to try and describe the process, but, after a bit of pondering, I think (THINK), the solution is

b = sqrt(h*l)
m = { [sqrt(h*l)] -l } / l

Cheers.

kyuzo
10-16-2015, 07:24 AM
well... kudos on your working. You've not ofc found a solution, you've essentially built a calculator. This kind of creativity is perhaps more important in problem solving than finding formal solutions.

- Cheers, I was quiet chuffed that I got a solution, even if it wasn't not a pure maths one...


I see now that the problem stems from the way your program itself is designed... so either it was purposefully designed that way by the programmer (who can say why, it seems an odd choice), or they themselves made the mistake in their own math I outlined to begin with.

- Trust me, this software we have to use has MANY other 'challenging aspects' about it. I suspect it is a case of the programmers not having a clue what the end users will be doing.


.. requires the solving of simultaneous equations (which can be hard)...

- Yep. I had vague memories of maths lessons about this sort of stuff, but that's about as far as I got...


.We could also write this more shorthand as high,low,base,mutliplier (h,l,b,m) to use...
h = b/(1+m)
l = b*(1+m)

- Wahey! I'm keeping up with you so far. And I was kinda there with...
"The upper max font size is calculated as 100pt x (1+0.5) = 150pt.
The lower font size is calculated as 100pt / (1+0.5) = 66.666pt."


.The working is a bit of a muddle, and I dread to try and describe the process..

- That explains why I hit a wall there. I'd like to think I'd have got there eventually, but I suspect the process would best be described using the words 'monkeys' 'Shakespeare' and 'infinite'.

:D

Your solution is absolutely spot on. Thank you, much appreciated.

Derek

RebelHill
10-16-2015, 07:40 AM
No worries...

As a point of note, the example which opened the curtain for me was the 100/100% giving 50/200 one. Here a 100% variance causes either halving or doubling of the base quantity... this is a smoking gun for a simple geometric operation, such as a square root. You could solve this formally, I did it by elimination as I knew the solution had to involve a combination of the min, the max, with a root op in there.

With this done, you then have the first equation solved, you can substitute for b (or base) in the second equation, rotate the thing around... second one solved.

Further... if you fancy taking time in your life to learn/practice and become more familiar with such things... this is a great volume...

http://www.amazon.co.uk/gp/product/0471852074

kyuzo
10-16-2015, 08:46 AM
Hmmm that book looks interesting. Might make it's way onto my Christmas wishlist...

cheers!