MathCAD: composite function, (f∘g)(x)

759 Views Asked by At

So sorry for the dumb question, but I can't figure this out and I have been searching for the answer and can't find it... and at this point I no longer know what to Google.

Using MathCAD, how do I define something as a function of a variable when that variable is also a function of another variable - like calculating $(f\circ g)(x)$, otherwise known as a composite function? Let me explain using an example...

g := 32.2*ft/s^2
volume := 5*ft^3

(Notice that this is over a range of possible values)
weight := 0.1*lbf,0.2*lbf...10.0*lbf

(Notice that this is a function of the weight)
mass(weight) := weight/g

(Notice that this is a function of mass, but mass is a function of weight)
density(mass) := mass(weight)/volume

density(mass) = error (This value must be a scalar or a matrix)

Of course I'm getting an error.

Basically, I'm telling MathCAD that I want the weight to vary over a certain range, which means that the mass will vary as well, according to the range given to the weight. I don't know what that range will be - I want MathCAD to do the calculation for me and tell me what the masses could possibly be. Then, I want the density which will vary over a certain range, as specified by the range for the mass.

By the way, the problem I'm solving is way more complicated than this example, so I can't just solve for density in terms of weight. I mean, I can do that for this easy example, but it will be way more difficult in the problem I'm actually solving.

1

There are 1 best solutions below

0
On

Well, I finally figured it out. If I replace

density(mass) := mass(weight)/volume

with

density(weight) := mass(weight)/volume

it works. I guess since the weight is what was originally referenced, that is what I'm supposed to make the density a function of. In other words, it looks like if y is a function of x, and x is a function of t, in MathCAD you just say

x(t) 
y(t) := something with x(t) in it 

and skip the middle step of y(x). I guess this makes sense since, in the end, y is inevitably a function of t.

And how long did it take for me to figure this very simple problem out? *sigh*

Please let me know if I'm wrong somehow with my answer, or if there is another way of doing this that I should know about.