Skip to main content
1-Visitor
September 12, 2012
Question

Iterate two sets of formulas

  • September 12, 2012
  • 4 replies
  • 5376 views

I have a sheet in which I have two sets of formulas. For these sets of formulas I have to iterate 1 input variable untill both sets generate the same end result.

Example (which will probably not yield any result):

Input: A, B, C, D

variable input: E

set 1:

H = A + B

I = C^2

J = H^D+I

Z = E*H*I*J

set 2:

M = A * B

N = C/2^0.5

O = N^E

Z = M * N * O

now I have to select E such that Z in set 1 equals Z in set 2. I can do this using a while loop, but because I want to get a result with at least 6 decimals.

Is there a standard function in Mathcad which can do something like this?

4 replies

1-Visitor
September 12, 2012

Set the first Z equal to Z1(E). Set the Z of the second set equal to Z2(E).

Now set f(E)=Z1(E)-Z2(E).

Use the "root()" function in Mathcad to find where f(E)=0.

You should graph f(E) first to get an idea/guess where the root is.

corne_mo1-VisitorAuthor
1-Visitor
September 13, 2012

Michael, thanks for your reply, but I don't really understand what you mean. Can you please upload an example?

Thanks in advance.

1-Visitor
September 13, 2012

Please explain what you don't understand.

1-Visitor
September 13, 2012

Could you please upload a worksheet?

Mike

corne_mo1-VisitorAuthor
1-Visitor
September 18, 2012

I don't know how to attach a file, so I added a link. This will not remain active for months and months, I'm sorry for that.

http://home.planet.nl/~moerb104/testfile.zip

In the sheet linked above there is in red txt marked where the two sets of formulas that need to iterate start. Don't mind the rest of the sheet and the layout. It is just a test.

The idea of the sheet is the following:

A fluid is blocked in a pipe. After being blocked there is a temperature change. This will result in a pressure change in the pipe.

Due to this pressure change, a stress will occur in the pipe. This stress, or actually strain, will result in a changing volume of the pipe and thus, because of the fluid being blocked, a changing pressure.

These two calculations need to give the same result for the final pressure, so the system is in balance. This needs to be done iteratively. Currently this is done by hand, adding two variables and continiously changing the values untill both yield the same result.

I guess it must be possible to do this using some sort of function or whatever. I am looking forward to your replies.

19-Tanzanite
September 18, 2012

Corné Moerbeek wrote:

I don't know how to attach a file, ...

Go to the top right-hand corner of the editor and select 'Use advanced editor'. At the bottom of the advanced editor is a facility for uploading files.

Alan

corne_mo1-VisitorAuthor
1-Visitor
September 18, 2012

Now it should also be available in this post.

Thanks for the tip Alan.

19-Tanzanite
September 18, 2012

I might have misunderstood the problem, but have a look at the attached.

Alan

1-Visitor
September 19, 2012

My only comment would be to add a graph of the two equations and a vertical marker for Peq.

This helps avoid dumb mistakes like forgetting a minus sign in an equation or something.