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?
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.
Michael, thanks for your reply, but I don't really understand what you mean. Can you please upload an example?
Thanks in advance.
Please explain what you don't understand.
My formulas are as stated in my first post, so nothing is dependent on E.
Can you upload an example with my formulas?
The sheet doesn't have to give a satisfying result as I made up those formulas. But it is a good example of my actual sheet.
Both Zs depend on E, Z1 explicitly and Z2 if you do some substitution.
Take a close look.
I understand that they depend on E, but in my final sheet it will be very hard to substitute all formulas untill the end results (in this example Z) both depend on the same input variable.
So I would prefer a solution where something like that is not necessary.
Corné Moerbeek wrote:
I understand that they depend on E, but in my final sheet it will be very hard to substitute all formulas untill the end results (in this example Z) both depend on the same input variable.
So I would prefer a solution where something like that is not necessary.
It's difficult to understand what your issues are without looking at a sample worksheet.
It may be easier than you think.
I suggest attaching a Mathcad worksheet as soon as possible.
As I have requested below, please provide a worksheet to save users time and prevent users from second guessing you.
Mike
The example you give is a trivial set of equations as it resolves down to :-
X * e = Y * e
So solutions are e =0 if X not = Y
or e = anything if X = Y
3 possible options for solving simple equations attached.
Regards
Andy
A Westerman wrote:
The example you give is a trivial set of equations as it resolves down to :-
X * e = Y * e
So solutions are e =0 if X not = Y
or e = anything if X = Y
3 possible options for solving simple equations attached.
Regards
Andy
In the first set, Z is linear in E, while in the second set Z has E as an exponential power.
The solution is not trivial nor obvious.
Sorry, mis-read the picture saw n*e not n^e (its much easier to work with attached xmcd files).
But of the 3 options , the symbolic solution is less likely to work as it can throw solutions that don't have defined numeric answers.
Regards
Andy
Could you please upload a worksheet?
Mike
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.
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
Now it should also be available in this post.
Thanks for the tip Alan.
I might have misunderstood the problem, but have a look at the attached.
Alan
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.
MichaelH wrote:
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.
I agree. Always a good idea to draw a graph where possible.
Alan