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

Mathcad function definition cross reference

dcompel
1-Newbie

Mathcad function definition cross reference

Hi I have a problem with the definition of functions. I have a function A that references to function B which uses function A from a previous iteration.

here's my code (more in xmcd file)

Mathcad 15.JPG

Thank you for your help

6 REPLIES 6
JeffH1
12-Amethyst
(To:dcompel)

There are three problems here:

  1. The first is that theta.a(t) is a local function (it only exists within your program structure) of the variable Delta-Theta.a.t(t), which is defined globally at the top of the first page, but is a function of c.a(t) outside the program.  c.a(t) is defined outside the program, but as a function of theta.a(t), which is circularly defined in terms of Delta-Theta.a.t(t) and out of sequence.  Functions can only call other functions if they are defined prior (above) in the worksheet.  You end up with a circular reference here that is not legal.

  2. Programs cannot return functions as you've defined, but only numerical results in terms of scalars or arrays. 

  3. I believe what you are trying to do is return an array of values for each iteration that depend on previous iteration values.  Using functions is not the vehicle for this. If you want to iterate, storing and using previously iterated values, then you should be using iterated arrays to do this.  Look through the help and the quick sheets for examples of using iterated variables.

I hope this helps.

LucMeekes
23-Emerald I
(To:dcompel)

In addition to what Jeff mentioned, there are more problems. You have a number of variables undefined.

I made an attempt to build an iteration. It 'works' in the sense that it iterates, but not knowing the subject my attempt may be far off the intent.

Anyway:

See if this works for you, or if you can make it work.

Note that 't' is no longer time iteself, but an index into the time points (each Delta-t apart).

In the end you get 4 arrays, and to output them simultaneously (using the augment statement), they HAVE use the same unit. I chose unitless, that's why h.net is divided by its units.

Success!
Luc

LucMeekes
23-Emerald I
(To:LucMeekes)

They do result in nice graphs:

Hello guys, thank you very much for so many responses! I really appreciate it! Im also sorry for such a late response, havent had much time last days...

I tried last two days to put it together and make it working but without any success. Like you said you have used arrays instead of functions and thats where I lost somehow. I mean I dont understand really the logic of your algorithm.

  1. I found out that recursive function might be something useful for this? But problem is that i have no skill at all in programing so its kinda difficult for me.
  2. Is there any option of "storing values" in functions?
  3. Also I just found out that my problem has grown and become more complicated. Is this still posible to write it down?

just for information: Main point of this calculation is to calculate iteratively increasing of temperature of member from air which is increasing temperature.

edit// I understand that i cant write it like that, also i understand that i have to create iterative loop but i dont have any idea how with such complex problem.

edit2// theres error in picture statement "Effective radiation temperature of the fire environment" in mathcad file its correct

question.jpg

LucMeekes
23-Emerald I
(To:dcompel)

I think you need iteration, rather than recursion.

Iteration is a process that uses previous values of an estimated parameter to find better estimates.

Here's an example to find the square root of S:

You need a starting point for your iteration, the example above uses the initial value x.

And you need a stop criterion, like the number of iterations.

You can also use the difference between two estimates, as shown below:

Note that I use an array (R) to hold the iteration values, so I can plot how the iteration reaches its destination:

If you're not interested in how the iteration runs, but only in the end result, you could use:

Success!
Luc

LucMeekes
23-Emerald I
(To:dcompel)

Here is another iteration that involves two parameters that depend on each other:

You can see how X depends on (the previous value of) Y, and Y depends on (the previous value of) X. Finally R is just calculated from the present values of X and Y.

Announcements
Check out the latest
Mathcad Tip
"PTC Mathcad 15 / Prime 1-6 Update."