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

Programming help - iterating through multiple equations.

SOLVED
Highlighted
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

Re: Programming help - iterating through multiple equations.

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

Re: Programming help - iterating through multiple equations.

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

Re: Programming help - iterating through multiple equations.

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.

Re: Programming help - iterating through multiple equations.

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 )

Re: Programming help - iterating through multiple equations.

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.

Re: Programming help - iterating through multiple equations.

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

Re: Programming help - iterating through multiple equations.

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

Re: Programming help - iterating through multiple equations.

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!