Skip to main content
1-Visitor
August 18, 2016
Question

Clueless about solver and intermediate variables

  • August 18, 2016
  • 1 reply
  • 2506 views

Hi Mathcad'ers,

It's been quite a few years since I last worked with Mathcad, and I don't remember if/how Mathcad could solve a system of equations with intermediate variables.

The sheet that I have put together results in an error for undefined variables if I do not place guess values for the intermediate variable. Do I need to put a guess value for these?
If I do set a guess value, I get an error that "this value must be a function".

What's the best way of addressing this?

The details for the sheet are:

I would like to determine a,b,o,and q as a function of g and s (inputs).

l,t, and p are constants.

j,o1,o2,b1,b2 are intermediate variables.

Thanks for the help,

Raphael

1 reply

1-Visitor
August 18, 2016

I can't open your file, but you likely just need to turn your intermediate values into functions of the variables you are trying to solve for.

For example, if j:=a+b, then make it j(a,b):=a+b.  Then, anytime you use j in an equation, replace it with j(a,b).

rrogman1-VisitorAuthor
1-Visitor
August 18, 2016

Thanks Mark,

I tried this approach but i haven't had much success.Most likely because each function is a function of another. Here's the original sheet.Mathcad Sheet.PNG

And a screenshot of the updated sheet- the error now is the initial  guess must consist of scalars and matrices.

Mathcad sheet r2.PNG

Regards,

Raphael

1-Visitor
August 18, 2016

Raphael,

Your second screenshot does not show the solve block (guess values, constraints, solver on left side).  I assume this just got cut off of your screenshot.

Aside from that, I see a few problems with your setup:

  1. I'm not sure if it's necessary or not, but typically only the variables you're trying to solve are defined in the "guess values" section, and only the inequalities are included in the "constraints" section.  Therefore, you should move the definitions of p, l, t, g, s, d, j, o1, o2, b1, and b2 above the solve block.
  2. Your definition of o1 should be o1(t,d,a).  o1 should not be a function of j since j is not a variable - it is a function.  Similarly throughout your other definitions.
  3. You're solving for 4 variables, therefore you need 4 inequalities.  I'm guessing that your fourth is intended to be o=o1(t,j,d)+o2(p,j,l) instead of your definition of o(o1,o2).

Also, as long as you define j after t & d, there is no need to make j a function of those variables (since you are not solving for those variables).  Your definition of j could simply be j(a):=...  The same goes for your other similar variables.  There is nothing mathematically wrong with the way you have done this, but it would help clean things up.