Skip to main content
1-Visitor
March 26, 2016
Solved

recursivic Calculation

  • March 26, 2016
  • 11 replies
  • 9801 views

Hey guys,

i would need a recursivic calculation with a break condition. I made it so far but now i would need an extention to this calculation.

I added a mathcad file in which i described my problem.

I hope that someone can help me 😃

This is only an example but is describing my problem very good

Best thx!

Best answer by -MFra-

Hello Stefan, do you like my solution below?

for smoll 2.jpg

or like this:

for smoll 2.jpg

11 replies

23-Emerald IV
March 28, 2016

It's not completely clear what you want to accomplish. Here some first comments:

Luc

23-Emerald IV
March 28, 2016

Is this what you are looking for?

Luc

25-Diamond I
March 28, 2016

>> This is only an example but is describing my problem very good

Really? Not in my eyes.

First, all I see is a somewhat strange iteration, no recursion!

You write, that you don't want to write the formula with a and b - what do you mean by that?

In your example, you first define a as 1 x 1 vector, then, by a <- a[i you make it a scalar and immideatly after that you use it with an index as if it still would be a vector. THis throws the error.

If you replace every a by a[i your prgram works, but a[i never gets a new value, all a[i equal to 1 and so b is always calculated as 0,75 and as 0,25/1 is never smaller than 0,1%, you never reach the break command.

So its unclear to me what you are trying to do.

Also absolutely unclear is, why you expect a 3 x 3 matrix as result. Your routine just returns a 2 x 1 vector.

R

-MFra-21-Topaz IIAnswer
21-Topaz II
March 29, 2016

Hello Stefan, do you like my solution below?

for smoll 2.jpg

or like this:

for smoll 2.jpg

1-Visitor
March 29, 2016

Thx for the fast help so far!

I think i am confused with the the meaning of recursivic.

I think i only need a normal iteration.

I try to explain a second time for better understanding.

I have a Input Vector.

Example: Force [100N;200N;300N]

For Every Force i need a separat Iteration with well defined formulas. Here just for simple: 1/2*(1+Force/2) and a breaking condition

The Resulting matrix should then be the INput force (here 100N;200N;300N); the last iteration step before breaking condition and the Result of the Iteration.

In the upper example instead of Force (100;200;300); the vector a is given (1,2,3)

So it is a normal iteration calculation, applied to every row of the input Vector until breaking condition

--------------------------------------------

One last question: Do i need a vectorising operation when im doing a complicated calculation for b1?

------------------------------------------------

Thx all for help

@FM thx for your file

For me its important to get the resulting value of the last iterationstep from every row of the input vector. (As to say the maximum needed iterations are different, depending on the input vector.

Here: a0=1 a1=2 a3=3

------------------------------------------------------

So far i have a problem to realise the calculation 😞

Maybe somone can give me a tip.

Regards!

1-Visitor
March 29, 2016

@LucMeekes

yes i think that is what i need. I added my Mathcad file but there is a small problem so far. I didnt get the failure.

The excel file shows the result of every loadstep. I think it is what i need.

Hmm lazyness yes maybe

But it has certain reasons: I have very long formulas with many  indizes. It is very confusing when i have more indizes than i need

When im finished with my project im gonna post it here so you can see what i need hehe

1-Visitor
April 15, 2016

Thx for the Posts to help me startening of the Iterative Calculation.

Up to now i have problems to realise it 😞

How can i make the break condition with "OK" "NOK"

Hmm would be great if you guys can help me out

1-Visitor
April 15, 2016

Ok i think i found the failures of by myself.

But still i have the problem of that i dont know how i can say to mathcad that i want the previous iterationstep as result.

Because the previous step the condition dm1 <= am1  should be true

1-Visitor
April 15, 2016

Sorry for double postings

25-Diamond I
April 15, 2016

This question is already marked answered and its already quite cluttered, so it may make more sense to open a new thread for a new question.

It looks to me that you can much better achieve what you are trying to do using a solve block!

25-Diamond I
April 15, 2016

I guess there is an easy answer to your question.

The only value which is changed in your routine is F by a constant of 1kN in every step.

So simply return F.new-1kN to get the value you want.

You can always re-calculate d.m1 with this Force to verify the condition d.m1 <= a.m

WE

25-Diamond I
April 15, 2016

OK, as I don't like the way you use your vectors directly in your calculation routine - here is a solution using a solve block.

Its always better to set up all calculation (no matter if iterations, programs, solve blocks, ..) to work for single scalar arguments and and only later call them vectorized with your vector arguments to get the results for a bunch of values with one call.

As the equation a.m=d.m1 can easily be solve symbolically, I also attached a function for direct calculation.

WE

1-Visitor
April 15, 2016

Thx for your help....

I solved it that way because i need to write much more complicated input....

here are 2 examples i finished so far.

But i still i have a failure on here 😞

I think the problem is the condition and the Number "1" in the routine

Maybe you can help me out another time

Thx

Still trying to understand your post.

The problem is that i have more than 20 input variables. This is only the beginning of the iteration (see my postet files)

I think i should have testet the program while writing regularly

25-Diamond I
April 15, 2016

> The problem is that i have more than 20 input variables. This is only the beginning of the iteration (see my postet files)

I see, but nevertheless I guess its better to create functions depending on 20 arguments and call them later vectorized than to deal with the vectors from the very beginning.

This has nothing to do with the question if a solve block could do the job better or not.

Working with named functions is one of the benefits of Mathcad once you have accustomed yourself to them.

The problem in your file is here:

And isn't a minus sign missing here in front or something else? Your condition as its written means asking if A.m1[s equals 1/3 a[2