On Nov 6, 2010, at 7:00 PM, flebber wrote:

> On Nov 7, 9:45 am, flebber <flebber.c... / gmail.com> wrote:
>> On Nov 7, 2:24 am, Robert Klemme <shortcut... / googlemail.com> wrote:
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>> On 06.11.2010 10:19, flebber wrote:
>>=20
>>>> I am trying to create a class. I am struggling to figure the best =
flow
>>>> to get the maths side to work.
>>=20
>>>> So say that
>>=20
>>>> R is a float given by user input
>>>> P is a Total amount(Pool)
>>>> Per is a variable %
>>>> X is a variable that is a percentage of P defined by a maximum
>>>> allocation.
>>=20
>>>> So main =3D (( R * X)/P)*100
>>=20
>>> First of all you should get your variables right.  Variable "Per" =
does
>>> not show up in the formula and "main" is not mentioned in the list.
>>=20
>>> The meaning of the formula is totally unclear to me.  =46rom what =
you gave
>>> you are calculating the fraction (R/P) multiply it with 100 (so you
>>> actually get (R/P) percent and now you multiply with another =
percentage
>>> (X).  So you have a percentage of a percentage.
>>=20
>>>> What I want to test is the value of X needed to equal Per from X's
>>>> maximum allocation down.
>>=20
>>> Can you write down a formula that contains all variables in your =
list
>>> and point at the fixed ones (constants), user inputs and variables =
you
>>> want to resolve?
>>=20
>>>> What i am thinking but cant get right
>>=20
>>>> Say
>>=20
>>>> R =3D 5
>>>> P =3D 10
>>>> Per =3D 190
>>>> X =3D max 80% of P
>>=20
>>>> For X in main =3D Per ( Closest whole number or half that equals =
closest
>>>> to but greater than Per)
>>>> main =3D (( 5 * 8)/10)*100
>>=20
>>>> So in example intially main equalled 400%. And answer I would want =
to
>>>> resolve it to is X =3D 4 which is 200% as 3.50 equals 180%.
>>=20
>>>> Any ideas?
>>=20
>>> Sorry you lost me somewhere along the path.  Also it's tea time =
right now...
>>=20
>>> Cheers
>>=20
>>>         robert
>>=20
>>> --
>>> remember.guy do |as, often| as.you_can - without =
endhttp://blog.rubybestpractices.com/
>>=20
>> So I want to check by changing X when in forumla "main" that it is =3D>=

>> than "per"
>>=20
>> In simple terms I want to calculate units needed to reach a rate of
>> return, X represents the variable units and per is the ROI(return of
>> investment rate I would deaire to acheive), R is the ratio of return
>> and P is a pool or base amount, I am using base 10 to start off with.
>>=20
>> I am trying to test X for a value, the only constraint on X is that =
it
>> cannot exceed 80% of the P or Pool amount.
>> So if I set per =3D 190%
>>=20
>> R =3D 5
>> P =3D 10
>> Per =3D 190
>> X =3D max 80% of P
>>=20
>> For X in main >=3D per
>>=20
>> main =3D (( 5 * X)/10)*100 >=3D 190%
>>=20
>> so for X =3D 80% of P or 8 base units
>>=20
>> main =3D (( 5 * 8)/10)*100
>>=20
>> which would test out as
>>=20
>> main >=3D per
>>=20
>> 400 =3D> 190 -
>>=20
>> So when X is 8 units the main section is greater than per but its not
>> the closest whole unit to per.
>>=20
>> So when X =3D 40% or 4 base units
>>=20
>> main =3D (( 5 * 4)/10)*100
>> main >=3D per
>> 200 >=3D 190
>>=20
>> this is the largest unit in 0.5 increments that remains greater than
>> Per of 190 so I would want X once tested to resolve to this.
>>=20
>> I hope that made sense.
>=20
> So how do I best get X to run a loop in 0.5 increments until it
> reaches the closest value that makes the left side of an equation
> greater or equal to the right. But where it is the lowest value that
> is greater than or equal to the the right.
>=20
> Main =3D> Per - where main is the lowest value it can be greater than
> per.
>=20
> Cheers
>=20
> Sayth
>=20


The wording is pretty vague at several points, but I'm trying to work =
through it to make sense of it...

You've really lost me when 80% turns into 8 (or 8 base units).  What is =
a base unit? And why would it be equal to 10%?
Are you looking to vary X from 80% down by 5% increments?


Mike Cargal

mike / cargal.net
http://blog.mikecargal.com