cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Programming help - iterating through multiple equations.

ptc-4451268
1-Newbie

Programming help - iterating through multiple equations.

Hello,

I've attached a mathcad document explaining what I am trying to achieve.

To simply for explanation purposes, I have have a few intial givens:

a b c d

the first equation calculates a number based on the givens.

the second equation calculates the next number based on the first equation

the third equation calculates the next number based on the second equation

the number in the third equation is added to a few of the givens, and the cycle repeats itself.

Could somebody help me write this program?

The mathcad document explains it in more detail.

Thanks!!!!!

1 ACCEPTED SOLUTION

Accepted Solutions

I was adding twice, corrected attached.

Fred showed the use of range variable, and Andy improved upon that. If you only want one solution, Andy's is pretty clear and concise.

I showed a different method using a program. It's a little longer, but self contained and can be used to study different conditions a little easier, or used in other functions.

By the way, if a0 and c0 are equal, then I think ci=ai, you only need to calculate ai, so I assume you want to study different inital values.

View solution in original post

7 REPLIES 7

Set up for step-by step iteration. Probably could set up for ODE solvers.

Fred,

Thanks for the help, however I don't believe the sheet is working correctly. I may be able to fix it myself though - not sure.

da/dN at a phi of 90° should be added to a

da/dN at phi of 0° should be added to c.

I checked it against the attached spreadsheet, and it diverges as the cycles are increased.

What I am trying to do is replicate the attached worksheet, where I can just fill down the row's and it will work just fine.

Another way, using programs

But Fred and I get different results, so on of us goofed, maybe both.

Not the most efficient program, but you can follow the steps as you stated them (I think )

Wayne,

Thanks for your help, but it looks like there is a few minor errors in your spreadsheet. The first E equation is a square root. Also, it looks like you are adding a0+a1+da/dn. a and c are doubling as they go down, but they should only go up a little bit, like:

0.500

0.501

0.503

0.506

etc.

I'll try to debugg it but I'm not sure I follow it.

Here's another method.

Initial equations reworked to be functions, then quite simple to use a range variable to iterate through to the required depth

Regards

Andy

I was adding twice, corrected attached.

Fred showed the use of range variable, and Andy improved upon that. If you only want one solution, Andy's is pretty clear and concise.

I showed a different method using a program. It's a little longer, but self contained and can be used to study different conditions a little easier, or used in other functions.

By the way, if a0 and c0 are equal, then I think ci=ai, you only need to calculate ai, so I assume you want to study different inital values.

Wayne,

This works great - thanks! There was one thing that needed to be fixed, and that was turning 90° into Pi/2, but other than that it is perfect.

Thanks again!

Top Tags