dbTalk Databases Forums  

Can repeating step calculations be performed in Filemaker?

comp.databases.filemaker comp.databases.filemaker


Discuss Can repeating step calculations be performed in Filemaker? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
stonefacejr@yahoo.com
 
Posts: n/a

Default Can repeating step calculations be performed in Filemaker? - 11-05-2005 , 12:55 PM






1. I want to perform an operation, say division, on a number that is a
constant.
2. I want to take the result and add it to another number that is also
a constant.
3. Then I want to add to or subtract from (by, for example, 0.01) the
number in step 1 and add this result to the result in step 2.
4. I want to repeat this operation a number of times that is determined
by the difference between two numbers, one a constant and the other a
variable, divided by the number in step three (in this case, 0.01). So
if the two numbers were 100 and 90, the process would be repeated
10/0.01 or 100 times.

Here's an example:

Start with:
1/t = x
x + C = C2

t = 100
C = 95

1. 1/100 = 0.01
2. 0.01 + 95 = 95.01
3. 1/100 + 0.01 = 1/100.01
4. 1/100.01 = 0.01
5. 0.01 + 95.01 = 95.02
6. Repeat until t = 101
7. Result should be 98.31

Is it possible to do this kind of calculation with Filemaker. If so,
how?

Thanks.


Reply With Quote
  #2  
Old   
Matt Wills
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-05-2005 , 01:44 PM






stonefacejr (AT) yahoo (DOT) com wrote on (11/5/2005):

Quote:
1. I want to perform an operation, say division, on a number that is a
constant.
2. I want to take the result and add it to another number that is also
a constant.
3. Then I want to add to or subtract from (by, for example, 0.01) the
number in step 1 and add this result to the result in step 2.
4. I want to repeat this operation a number of times that is determined
by the difference between two numbers, one a constant and the other a
variable, divided by the number in step three (in this case, 0.01). So
if the two numbers were 100 and 90, the process would be repeated
10/0.01 or 100 times.

Here's an example:

Start with:
1/t = x
x + C = C2

t = 100
C = 95

1. 1/100 = 0.01
2. 0.01 + 95 = 95.01
3. 1/100 + 0.01 = 1/100.01
4. 1/100.01 = 0.01
5. 0.01 + 95.01 = 95.02
6. Repeat until t = 101
7. Result should be 98.31

Is it possible to do this kind of calculation with Filemaker. If so,
how?

Thanks.
Others might suggest a more elegant way to do it using a recursion
calculation, but I am still pretty clueless about how to do that properly
(only because I haven't sat down to study it), so...

You could do a brute force recursion with a looping script, each step in
the loop setting a field to the various values you define above. You
pretty much have the scheme laid out in steps 1, 2, 3, and 5:

Set Field [ x ; 1 / T ]
Loop
Set Field [ c2 ; c + x ]
Set Field [ t ; t + x ]
Exit Loop If [ T = 101 ]
End Loop

I don't quite understand your step 4, though. If you already have the
value of x set at .01, what is the purpose of that step? Not to mention
the fact that 1/100.01 would result in .00999 (etc., etc.)?

Matt


Reply With Quote
  #3  
Old   
Matt Wills
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-05-2005 , 01:49 PM



Matt Wills wrote on (11/5/2005):

Quote:
Set Field [ x ; 1 / T ]
Loop
Set Field [ c2 ; c + x ]
Set Field [ t ; t + x ]
Exit Loop If [ T = 101 ]
End Loop
Nope. Don't really need C2, and that (above) wouldn't work anyway, because
nothing was incrementing c:

Set Field [ x ; 1 / T ]
Loop
Set Field [ c ; c + x ]
Set Field [ t ; t + x ]
Exit Loop If [ T = 101 ]
End Loop

If you really wwant to keep C2, add another step

Set Field [ x ; 1 / T ]
Loop
Set Field [ c ; c + x ]
Set Field [ c2 ; c ]
Set Field [ t ; t + x ]
Exit Loop If [ T = 101 ]
End Loop

--



Reply With Quote
  #4  
Old   
42
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-05-2005 , 03:19 PM



In article <1131216937.499897.173390 (AT) o13g2000cwo (DOT) googlegroups.com>,
stonefacejr (AT) yahoo (DOT) com says...
Quote:
1. I want to perform an operation, say division, on a number that is a
constant.
2. I want to take the result and add it to another number that is also
a constant.
3. Then I want to add to or subtract from (by, for example, 0.01) the
number in step 1 and add this result to the result in step 2.
4. I want to repeat this operation a number of times that is determined
by the difference between two numbers, one a constant and the other a
variable, divided by the number in step three (in this case, 0.01). So
if the two numbers were 100 and 90, the process would be repeated
10/0.01 or 100 times.

Here's an example:

Start with:
1/t = x
x + C = C2

t = 100
C = 95

1. 1/100 = 0.01
2. 0.01 + 95 = 95.01
3. 1/100 + 0.01 = 1/100.01
4. 1/100.01 = 0.01
5. 0.01 + 95.01 = 95.02
6. Repeat until t = 101
7. Result should be 98.31

Is it possible to do this kind of calculation with Filemaker. If so,
how?
It would help if your example made more sense.

The number of iterations according to rule 4, {t=100 c=90} should be
1000 not 100. 10/0.01 = 1000 not 100.

In step 3 of the example you state 1/100 + 0.01 = 1/100.01 which is
apparently false. Unless you mean 1/(100+0.01)?

In step 4 you you assert 1/100.01 = 0.01? Which is also false unless you
are doing some rounding you neglected to mention.

I can't even figure out where you are incrementing t. Its going to need
to increase if its going to ever reach 101 in step 6!

Why should we repeat until t = 101 in step 6? Where does this 101 come
from? This makes no sense at all... EVEN if I assumed that you were
basing it on 100 iterations incrementing by 0.01, there would be no
basis for "100" iterations. On the one hand 100 is wrong according to
rule 4; it should be 1000, and on the other hand that error in rule 4
shouldn't even matter... your example uses C=95 not 90, so why would I
need the same number of iterations? (in this case rule 4 dictates that
I'd need 500 iterations for t=100 C=95).

Given the number of errors present I'm just not sure whats going on. Is
the final result 98.31 the correct answer for t=100 c=90? or for t=100
c=95? or is it correct at all?

I'm sure FM CAN solve this problem, but right now I just don't
understand the problem.
Best Regards,
Dave



Reply With Quote
  #5  
Old   
stonefacejr@yahoo.com
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-05-2005 , 08:20 PM



Thanks for the help!

Sorry about the errors.
There should be parentheses: 1/(100 + 0.01); the numbers are rounded to
nearest 100th; 90 should be 101. And there's a missing, irrelevant,
step. Without this step, the answer should be 95.99 (rounded), not
98.31.


Reply With Quote
  #6  
Old   
42
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-06-2005 , 03:12 PM



In article <1131243649.488218.33390 (AT) f14g2000cwb (DOT) googlegroups.com>,
stonefacejr (AT) yahoo (DOT) com says...
Quote:
Thanks for the help!

Sorry about the errors.
There should be parentheses: 1/(100 + 0.01); the numbers are rounded to
nearest 100th; 90 should be 101. And there's a missing, irrelevant,
step. Without this step, the answer should be 95.99 (rounded), not
98.31.


Hmmm... I'm still lost:

if t=100, and C=101 then yes we need 100 iterations. But I'm not sure
how the final answer would end up as 95.99. Both our starting constants
are >=100 and all we do is addition ... so how are we getting down to
95.99?

Maybe run us through an iteration or two with the right numbers?


Reply With Quote
  #7  
Old   
stonefacejr@yahoo.com
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-06-2005 , 04:02 PM



C = 95 (not 101)

t = 100

101 is T (not C; it's the final value of t after adding 100 * 0.01 in
this example)

Each time I add (or subtract) 0.01 from t, I want to add a value equal
to the new value of 1/t to C.

So if we start at C = 95, adding the appropriate amount for each
iteration of 1/t to C, we should end up with 95.99 after 100
iterations. In the example, although 1 is added to t (100), only 0.99
(rounded) is added to C (95).


Reply With Quote
  #8  
Old   
42
 
Posts: n/a

Default Re: Can repeating step calculations be performed in Filemaker? - 11-06-2005 , 06:04 PM



In article <1131314549.693019.14790 (AT) g49g2000cwa (DOT) googlegroups.com>,
stonefacejr (AT) yahoo (DOT) com says...
Quote:
C = 95 (not 101)

t = 100

101 is T (not C; it's the final value of t after adding 100 * 0.01 in
this example)

Each time I add (or subtract) 0.01 from t, I want to add a value equal
to the new value of 1/t to C.

So if we start at C = 95, adding the appropriate amount for each
iteration of 1/t to C, we should end up with 95.99 after 100
iterations. In the example, although 1 is added to t (100), only 0.99
(rounded) is added to C (95).
/sigh

So is T=101 an input or just something that happens as a side effect? If
it happens as a side effect how are you determining the number of
iterations? (And the size of the increment for that matter)

Seriously, this is getting ridiculous.

For the moment, I'm just going to assume that the amount to increment
and the number of iterations are supplied as inputs because I STILL
can't figure out where you are getting those numbers.

So given:

t=100
increments n = 0.01
iterations I = 100
Co = 95

It looks like what you want is:

a simple function: (pseudocode)
f(t,n,I,C0)
{
C = Co;
for i = 0 to I-1;
C = C + round(1/(t+ni),2)
end_for
return C
}


or you could do it recusively with something like:

f(t,n,i,I,C)
{
if i=I return C else return f(t,n,i+1,I,C+round(1/(t+ni),2))
}

and you'd call it initially with f(100,0.01,0,100,95)

Either approach is doable in Filemaker (although recursion requires
Developer 7 or Advanced 8)

-regards
Dave



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.