Post Reply 
Solving with multiple unknown variables & more
03-25-2015, 01:58 PM
Post: #1
Solving with multiple unknown variables & more
Hey, I just recently got the HP Prime calculator and I have a few issues.
I want to solve, or "rearrange" an equation with multiple unknown variables.
Let's say I have an equation "x-a = 500" and solve for x I would get "x = 500+a".
Is there a way to do this on HP Prime or any symbolic calculator?

Another issue I'm having is how does one create custom functions and calculate their values at specific points.
Eg. I want to create a function f(x) = x^2+50, the get the derivative f'(x) and calculate f'(5).
I know you can do this with diff(x^2+50) but after that I'd have to copy the result into the where-block so I can get 2x | x=2 => 4.
There must be a simpler way to do this, right?
Find all posts by this user
Quote this message in a reply
03-25-2015, 02:33 PM
Post: #2
RE: Solving with multiple unknown variables & more
For your first question: Open the Tools (Key with B), select Solve, then Solve and click OK. Then enter :
solve (x-a=50,x)

and you will x=(a+50).

Bill
Find all posts by this user
Quote this message in a reply
03-25-2015, 02:55 PM
Post: #3
RE: Solving with multiple unknown variables & more
For your second question you can copy 2x to the FUNCTIONS APPS. Then click Plot to view the plot, click on the plot to show the cursor, and the value of the function is displayed as you move the cursor.

Also, clicking Num will give you numerical values as a function of x.

Bill
Find all posts by this user
Quote this message in a reply
03-25-2015, 02:57 PM (This post was last modified: 03-25-2015 02:58 PM by Han.)
Post: #4
RE: Solving with multiple unknown variables & more
(03-25-2015 01:58 PM)Ollie Wrote:  Hey, I just recently got the HP Prime calculator and I have a few issues.
I want to solve, or "rearrange" an equation with multiple unknown variables.
Let's say I have an equation "x-a = 500" and solve for x I would get "x = 500+a".
Is there a way to do this on HP Prime or any symbolic calculator?

As Bill_G suggested, you can use the solve command (in CAS view). If you simply type solve on the command line and hit the [Help] key, you will see some information and examples of how to use this command.

Quote:Another issue I'm having is how does one create custom functions and calculate their values at specific points.
Eg. I want to create a function f(x) = x^2+50, the get the derivative f'(x) and calculate f'(5).
I know you can do this with diff(x^2+50) but after that I'd have to copy the result into the where-block so I can get 2x | x=2 => 4.
There must be a simpler way to do this, right?

You can create functions by defining them in the following manner:

f(x):=x^2+50; // on the right side of the screen you will see how functions are represented internally
f(1); // this gives 51 as the result
diff(f(x),x); // this produces 2*x as the result
g(x):=<copy and paste result above using the touchscreen>
g(2); // this gives 4 as the result

In creating g(x), you could simply type:

g(x):=

and then tap the screen where the 2*x is (twice) to copy.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-25-2015, 03:59 PM (This post was last modified: 03-25-2015 04:03 PM by Ollie.)
Post: #5
RE: Solving with multiple unknown variables & more
Thank you all for the quick replies!
Is there a fast way to plot these internally defined functions f(x),g(x), etc. or do I have to copy the result to the Function app?
Also another question; What does the Integers option in the Home Settings menu do? Even if I have it set to 32 bit hex my answers appear as expected in base10.
Find all posts by this user
Quote this message in a reply
03-25-2015, 06:21 PM
Post: #6
RE: Solving with multiple unknown variables & more
(03-25-2015 03:59 PM)Ollie Wrote:  Thank you all for the quick replies!
Is there a fast way to plot these internally defined functions f(x),g(x), etc. or do I have to copy the result to the Function app?

Think of F0 through F9 as built-in variables that are predefined to be functions (and can only store functions). If you already did something like:

f(x):=x^2+50;

then f itself is a function variable, whereas f(x) is an evaluation of the function at an input of x. Thus, you can simply do:

F1:=f;

and it will place the formula into F1. If you want the derivative, then create g(x) as described in my previous post and do

F2:=g;

Then press the [Symb] key and ensure that the functions are check-marked for plotting, and press [Plot] (assuming, of course, you have the Function app running).

Quote:Also another question; What does the Integers option in the Home Settings menu do? Even if I have it set to 32 bit hex my answers appear as expected in base10.

It's mainly for integers that are entered in the form #????h where the last letter h denotes hexadecimal, but could aslo be b (binary) or d (decimal) or o (octal). As an example, #10h is the hexadecimal integer whose decimal value is 16. Though internally (and this is just a hunch) these integers are stored as your ordinary, everyday integers. So if you make a matrix of integers and recall the integers, they may actually get converted into decimal form. For example, in the Home view type: [[ #10h, #2h ]] and you get [[ 16, 2]] (a 1x2 matrix of ordinary integers). That option, among other things, allows you to type #10 and leave off the base, as it will assume you meant the base selected in the settings.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-25-2015, 08:08 PM
Post: #7
RE: Solving with multiple unknown variables & more
Alright, thanks for helping me out!
Find all posts by this user
Quote this message in a reply
03-30-2015, 05:11 AM
Post: #8
RE: Solving with multiple unknown variables & more
hello everybody!

Thank you for the Information given in this thread. I started to play with the functionality and I am very impressed. You need to know about the syntax but then solve() is really powerful. Sadly, like expected, I ran into Problems later... Maybe you can help me on how to do it correctly or give me some magic pragma again that does the job:

What I did: Define two functions.

Ekin(m,v):=0.5*m*v^2
Epot(m,h):=m*9.81*h

You can calculate energies at once for 70 kg and 15 m/s by evaluating the functions. Ekin(70,15)

I can save the weight into m. m:=70; And calculate Ekin(m,15).

I can use solve() to equal Ekin and Epot (It took me a while to realize that I have a function and must use the following Syntax)

solve( Ekin(m,v)=Epot(m,h),v ).
There are two solutions, of course. BUT I found the way to pass assumption to the calculator.

assume( v>=0 )
solve( Ekin(m,v)=Epot(m,h),v ). Only one solution! GREAT!



1) With the Function App there are problems. I cannot really find out what is going wrong. Maybe someone can help me!
The function plots functions of one independant variable. So far so good. Assignment of e.g. Ekin(m,v) to the app fails although it is a function of one independant. Remember I assigned m:=70, so that is a constant. Only independant var is v.
How do I copy Ekin(m,v) to the app to have it plotted? In practice functions of one independant variable are often seen - but only because other variables can be defined to constants....


2) Now if I define Ekin2(v):=0.5*70*v^2 because I did not find the correct way to copy the function into the app. Not practical at all, but what should I do.
Assignment to F1 now works as described:
F1:=Ekin2.
No variables like F1(X) needed. That is some auto-Transformation going on.
BUT the calculator Forgets about my assumption about v i.e. assume(v>=0)! Is that a bug?


Thanks for help in advance
Find all posts by this user
Quote this message in a reply
03-30-2015, 12:55 PM
Post: #9
RE: Solving with multiple unknown variables & more
(03-30-2015 05:11 AM)leprechaun Wrote:  1) With the Function App there are problems. I cannot really find out what is going wrong. Maybe someone can help me!
The function plots functions of one independant variable. So far so good. Assignment of e.g. Ekin(m,v) to the app fails although it is a function of one independant. Remember I assigned m:=70, so that is a constant. Only independant var is v.
How do I copy Ekin(m,v) to the app to have it plotted? In practice functions of one independant variable are often seen - but only because other variables can be defined to constants....

The function app only understands one input variable: X. To plot Ekin(70,v), you simply need to pass X as the dummy variable. In the Symb view of the Function app, just type in: Ekin(70,X) as one of the functions and hit plot.

Quote:2) Now if I define Ekin2(v):=0.5*70*v^2 because I did not find the correct way to copy the function into the app. Not practical at all, but what should I do.
Assignment to F1 now works as described:
F1:=Ekin2.

No variables like F1(X) needed. That is some auto-Transformation going on.
BUT the calculator Forgets about my assumption about v i.e. assume(v>=0)! Is that a bug?

Thanks for help in advance

No variables are needed in this particular example because F1 is a built-in "function" variable. And Ekin2 is a user-created "function" variable. Since dummy variables are just that -- dummy variables (placeholders), the calculator auto-converts the v to X. (This would not have been possible with the original Ekin(m,v) function since you cannot assign a one-variable function F1 to be a two-variable function.)

As for the assumption on v, this is placed only on the variable v, and not X. As for as plotting is concerned, just set your input range in the plot settings.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-30-2015, 01:13 PM
Post: #10
RE: Solving with multiple unknown variables & more
I don't understand how to plot Ekin(m,v). I do assign m:=70, so that is no longer a variable.
Why does F1:=Ekin not work in that case. How can I assign Ekin to the app?
Find all posts by this user
Quote this message in a reply
03-30-2015, 01:36 PM
Post: #11
RE: Solving with multiple unknown variables & more
One can use the geometry App for plotting aswell. plotfunc() does the job.

The difference is that plotfunc() is for expressions. So maybe a frontend to exchange data between geometry app and cas would be helpful. I should try to start working on some program but my programming skills are still not sufficiant.
http://www.hpmuseum.org/forum/thread-3203.html
Here it is shown how to pass the data to the app variables. You would need to extract the Expression from the formula, of course.
Find all posts by this user
Quote this message in a reply
03-30-2015, 05:32 PM
Post: #12
RE: Solving with multiple unknown variables & more
(03-30-2015 01:13 PM)leprechaun Wrote:  I don't understand how to plot Ekin(m,v). I do assign m:=70, so that is no longer a variable.
Why does F1:=Ekin not work in that case. How can I assign Ekin to the app?

Even though you defined m:=70, that does not affect dummy variables. That is, if Ekin(m,v) is defined with m and v as dummy variables, then these are just "placeholders" and only take on numerical values when evaluating the function Ekin.

As I explained earlier, F1:=Ekin does not work because F1 is a one-variable function whereas Ekin is a two-variable function. You can do something like:

g(x):=Ekin(70,x);
F1:=g; // (automatically adjusts the placeholder variable x to X)

In the Function app, just type in Ekin(70,X) -- note the upper case X.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-30-2015, 06:03 PM (This post was last modified: 03-30-2015 06:05 PM by leprechaun.)
Post: #13
RE: Solving with multiple unknown variables & more
ok I hope I understood. Somehow I had the idea that the calculator should memorize that m was already defined. As suggested I did a search on the forums and read the above link. Did I undersand it correctly that something like the following should be done? If there are programming flaws point them out. I used Han's c-style argv building block. That was a great idea.
Maybe I should save and retstore old fomulae in the geometry app?
Code:

#cas
foo(args)
BEGIN
  LOCAL argv, argc;
  argv:=[args];
  argc:=size(argv);
  
  Instruction(1,2):="GA";
  Instruction(1,3):=plotfunc(argv(1),argv(2));
  CHECK(1);

END;
#end
Ideas for improvement? I remeber that there is a command for automatically switching to the plot view and actiate geometry app. I can't remember.
[/code]

I could call foo(Ekin(m,v),v). Maybe HP could make a refined well designed frontend for the purpose???
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)