A little xmas eve math (help)
-
for whatever reason, i'm not seeing a simpler way to do this but i know it's out there..
all fractions feeding into this will be sixteenths between 0 and 1 {1/16, 1/8, 3/16, 1/4, etc...}
the goal is to get the multiplier(s) for the original fraction that will give me the two preceding numbers..
ie— in this example, i start with 1/2.. i need to multiply 1/2 by (x) in order to get 7/16 then again to get 3/8..
this is working as i have it but it feels a bit overboard...
%(#008040)[set fraction to (1 / 2)
set target1 to (fraction - 0.0625)
set target2 to (fraction - 0.125)
set multiplier1 to target1 / fraction
set multiplier2 to target2 / fractionmultiplier1 = .875
multiplier2 = .75]i could now multiply 1/2 by .875 to get 7/16
and by .75 to get 3/8..anybody seeing a more sensible way?
thanks(going out for a bit.. you have an hour.. ready,set,go! )
thanks[edit] oh.. and i don't necessarily need two variables at the end (multi1 and 2)..
it could end up being something like
(multiplier * fraction) = 7/16 and
((multiplier * ?) * fraction) = 3/8 -
8/16 * 14/16 = 7/16
0.5 * 0.875 = 0.43758/16 * 12/16 = 6/16
0.5 * 0.75 = 0.3758/16 * 10/16 = 5/16
0.5 * 0.625 = 0.3125Therefore...
12/16 * x/16 = 11/16
12 * x = 11
12x = 11
x = 11/12
12/16 * 11/12 = 11/16
So to answer your question [from my point of view] your looking at multiplication in alegbra because this seems to work everytime
9/16 * x/16 = 8/16
9 * x = 8
9x = 8
x = 8/9
9/16 * 8/9 = 8/16
-
@unknownuser said:
So to answer your question [from my point of view] your looking at multiplication in alegbra because this seems to work everytime
9/16 * x/16 = 8/16
9 * x = 8
9x = 8
x = 8/9
9/16 * 8/9 = 8/16
right.. that's the way i'm doing it right now (albeit a little differently / less steps)
in this case, with 9/16 , you're showing the result for one of the numbers i need (multiplier1) so leaving out the calculations for multiplier2, it does this:set fraction to (9 / 16) _________ meaning I'm starting out with 9 / 16
set target1 to (fraction - 0.0625) which is a simpler way to get 8 / 16
set multiplier1 to (target1 / fraction) or (8/16 ÷ 9/16) which is the same thing as 8/99/16 * 8/9 = 8/16
that said, it doesn't seem like the quick way to get from A->B... especially when considering i want 2 preceding numbers instead of just the one..
meh.. i'm probably going to keep thinking about this one until 1) i give up, 2) i figure it out, 3) someone else figures it out..
probably 1 or 3[edit] oh wait, i'm confused..
what's this doing?:9/16 * x/16 = 8/16
-
If I have 3/16 and want to know what to multiply by to get 2/16 and 1/16 I do this...
3/16 = 2/16 therefore * 2/3
3/16 = 1/16 therefore * 1/3In my head I see...
162/316 = 32/48 = 2/3
-
@unknownuser said:
If I have 3/16 and want to know what to multiply by to get 2/16 and 1/16 I do this...
3/16 = 2/16 therefore * 2/3
3/16 = 1/16 therefore * 1/3In my head I see...
162/316 = 32/48 = 2/3
oh right.. maybe i forgot to mention
it's part of a script.. so i can't just assume it sees these things.. and for me to make it see what you're seeing would add more steps.. (it might be simple to do if the fractions coming in were 8/16 or 12/16 but they aren't.. they're 1/2 and 3/4 in those cases, although we can immediately see 1/2 -> 7/16, the script can't..)
[but actually, there might be a quick little way to do this in the script which will in fact streamline it some ] -
I know my thinking is based on some formula I've forgotten...
x/y * a/b = q/r
x * a = q / y * b = r
Or something along those lines. From these you can extract roots so...
x * a = q
ax = q
x = a/q
Now I'm lost
Just press print
-
in Applescript [or Ruby]
9/16*8/9
returns
0Or, you can convert integers to floats by adding .0
9.0/16.0*8.0/9.0
returns
0.5any help?
john
PS. merry xmas
-
^ maybe you have an older version of applescript since you're on leopard? because if i use 9/16 * 8/9, i will get 0.5.. (but it compiles to 9 / 16 * 8 / 16 (with spaces) then calculates..
that said, i'm mostly using the decimal numbers of these fractions for the calculations while the user will see the fraction ( 1/2" = 1' type of stuff).. otherwise, i've been doing
(9 ÷ 16) ÷ (8 ÷ 9)and that aside, i found a simple way to do what i was originally asking in this thread.. a two liner to get both of the multipliers i need.. i had some other variables set for another part of the script that i was also able to use for this part..
-
I read something about the maths update for lion or snow... least you have a solution.
I've got a 3 button multi-sheet to scale version of PrintRight working [but clunky]
did you ever try the single button one?
john
-
@driven said:
I read something about the maths update for lion or snow... least you have a solution.
I've got a 3 button multi-sheet to scale version of PrintRight working [but clunky]
did you ever try the single button one?
john
i actually have a version of PrintRight that's working very well right now.. i'm going to make a preview video a little later today and put it in that thread.. there are still some things i don't like about it right (well, personally I like it because it does exactly what I need it to do.. i'll have to mess around with it some more before making it publicly available)
-
Other then wanting to be able to 'PrintRight' on a mac, I've just been working on it as an excuse to finally learn some ruby...
and try out some ideas for another project...PM me your latest if you want any input, Leopard or Snow [I switched my macBookPro over]
john
Advertisement