I am trying to get my calculator to work out how to work out equations that rely on several other equations which I have defined as a variable. For example:
\begin{align}w&=3\\
x&=2y\\
y&=w+2\\
z&=2y+4x\end{align}
In the calculator I have created the variable $3→w$ which sets $w$ as 3. If I type $w$ and hit enter I get $3$. Now to enter the equation for $x$ I have to type:
$$2y→x(w)$$
Now if I want to find $x$ I have to type $x(3)$. I want to be able to just type $x$ and the calculator automatically realises that $x$ is $6$. In this instance it isn't so bad, I just have to type $x(3)$, but it makes the whole process of entering the variable $w$ redundant as I have to enter it in subsequent equations anyway.
When we get to the equation $z$ it gets very messy. I have to enter each variable as a function of such and such. So my question is, how do I get my calculator to save the answer to each variable so it will automatically calculate subsequent equations that use those variables, instead of typing each value for them manually?
Answer
This is only possible in a document, not in the calculator application itself.
Create a new document and add the calulator app (press 1).
Now open the menu (menu button) and select "Functions and Programs" (press 9), open the program editor (press 1) and create a new file (press 1).
Name your first function, in your case that would be y. Change the type to "Function" and click OK.
You are now presented with this text
Define y()=
Func
EndFunc
You can now write the function definition between "Func" and "EndFunc" and have it output with the "Return" statement. In your case you would write
Return w+2
Save and check your function with Ctrl+B. You can now use it in your calculator app, which should be empty for now. If you write now y() it will return w+2.
But if you save a value to w, in your case $3→w$, and write y() again, it will return 5.
For x() you can do the same and since you want to use y(), you can define the function like this to access y():
Return 2*y()
Writing x() should now return 10.
As a side note: You have to write the brackets after x and y, because the brackets indicate that a function has to be called, while x and y without brackets would indicate that they are stored values. Also you can't use the normal calulator app, since all the functions in there are pure functions and can't access stored variables. You have to stay within the document.
No comments:
Post a Comment