1

I want to define a function with parameters and make calculations with it so that the resulting equations contain my parameters and are not calculated based on the pre-defined values of parameters.

Consider I have some function with 2 parameters (a,b) in a Mathcad document.

When I type something like:

$$f(t):=at^2+bt+5$$

I get an error claiming that variable a is undefined. When I use $\rightarrow$ transformation in the same statement I see something like:

$$f(t):=at^2+bt+5 \rightarrow at^2+bt+5 $$ which looks like a duplication of my statement (I anticipate some mistake here) but generates no error.

When I then do calculations with $f(t)$, for example to get $f(1)$, I get the proper parameteric equations like: $$f(1)=a+b+5$$ - AND THIS IS WHAT I REALLY WANT AS A RESULT.

If I define some values for $a:=10$ and $b:=20$ before declaration of $f(t)$, I get $f(1)$ calculated with that values: $$f(1)=35$$ - WHICH IS NOT A RESULT I WANT, but in such case I get no error when I don't use $\rightarrow$ in $f(t)$ declaration!

Am I doing these operations right or is there some other way to define parameters before declaring $f(t)$ formula to get PARAMETER-based calculations for $f(1)$ and do not using $\rightarrow$ transformation in $f(t)$ statement?

  • I am not familiar at all with Mathcad but would it be possible to define f[a,b,t] ? – Claude Leibovici Dec 28 '13 at 08:29
  • @ClaudeLeibovici Of course it is possible. And $\to$ transformation can be applied to $f(a,b,1)$... – Constructor Dec 28 '13 at 08:31
  • @ClaudeLeibovici I'm not famliar too, but I assume that a and b are more like constants that are used in a set of formulas, not just f(t), but I don't want to give them values to get a parameter-based equations – Andrey Pesoshin Dec 28 '13 at 08:32
  • @ClaudeLeibovici I think that your comment could be considered as an answer to my question. I tried several times more and got an idea that parameters are quite similar to variables in Mathcad and at the same time i can select a main variable I want to deal with (in the example, t) and make analytic transformations around it – Andrey Pesoshin Jan 06 '14 at 12:14
  • @AndreyPesoshin. Glad to have helped in spite of my total ignorance of Mathcad. Cheers. – Claude Leibovici Jan 07 '14 at 06:31

1 Answers1

0

You will get the 'undefined variable' error because the variable is, well... undefined.

In Mathcad, if you declare a function that uses variables that have not been previsouly defined - either as parameters to the function or variables in their own right, then you will get the 'undefined variable' error.

The $ \to $ operator (Evaluate Symbolically) will simply repeat your function as there is nothing to evaluate, and therefore there will be no error.

Your options are:

  1. Define the variables $ \{a,b\} $ before the function declaration and then call the function passing the parameter $ t $
  2. Create additional parameters to the function for $ \{a,b\} $ and pass these when calling $ f $

What you will have for each option above is a worksheet as follows:

For 1)

$$\begin{align} & a:=10\\ & b:=20\\ & f(t):=a*t^2+b*t+5\to 10*t^2+20*t+5\\ & f(1)=35 \end{align}$$

For 2)

$$\begin{align} & a:=10\\ & b:=20\\ & f(a,b,t):=a*t^2+b*t+5\to a*t^2+b*t+5\\ & f(a,b,1)=35 \end{align}$$

Or

$$\begin{align} & f(a,b,t):=a*t^2+b*t+5\to a*t^2+b*t+5\\ & f(10,20,1)=35 \end{align}$$

I hope this helps and answers the question you have. If not, please leave me a message or contact me and I will try to help some more.

Mike
  • 461