Post Reply 
Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
02-14-2014, 07:46 AM
Post: #1
Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
For a thermodynamics class I often need to interpolate values which are not given in the tables I use. Say I want to know the specific volume of water at 130 degrees and pressure of 100 kpa, when I only have the specific volume for 100 and 150 degrees at 100kpa.
Is there some statistic function I can use, which would be faster than the solver?
Find all posts by this user
Quote this message in a reply
02-14-2014, 02:52 PM (This post was last modified: 02-14-2014 04:11 PM by Han.)
Post: #2
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
In general your interpolation (and its accuracy) depends on the relationship between the parameters. For your example, if you use \( PV=nRT \) and pressure \( P \) is kept constant, then in this case a linear interpolation would be fine since
\[ V = \underbrace{\frac{nR}{P}}_{\text{slope}} \cdot T \]
So since \( n \), \( R \) and \( P \) are constant, then \( V \) is a linear function of \( T \). This should enable you to interpolate the volume provided the pressure is fixed at 100k pascals.

Haven't tested this, but using a linear fit with your known values and then using the trace feature should allow you to figure out the interpolated volume.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
02-14-2014, 04:44 PM (This post was last modified: 02-14-2014 04:45 PM by Rich.)
Post: #3
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
I just recently took Thermodynamics and fluid flow 1. For linear interpolations, i assigned this object which is pretty fast for me:


f(x_1,y_1,x_2,x_3,y_3):=y_2 = (((x_2-x_1)*(y_3-y_1))/(x_3-x_1)) + y_1
x_1 = (Value)
y_1 = (Value)
x_2 = (Value)
y_2 = Unknown
x_3 = (Value)
y_3 = (Value)

To use just perform f(1,1,2.5,10,10) and ENTER

The result should be a direct linear interpolation with y_2 = 2.5

I hope this helps.

Though I recommend just using the EES software package, if it is available at your school and you can use it on an exam. It comes preloaded with almost all tabulated values of entropy, enthalpy, specific heat...etc etc.
Find all posts by this user
Quote this message in a reply
02-14-2014, 09:48 PM
Post: #4
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-14-2014 04:44 PM)Rich Wrote:  I just recently took Thermodynamics and fluid flow 1. For linear interpolations, i assigned this object which is pretty fast for me:


f(x_1,y_1,x_2,x_3,y_3):=y_2 = (((x_2-x_1)*(y_3-y_1))/(x_3-x_1)) + y_1
x_1 = (Value)
y_1 = (Value)
x_2 = (Value)
y_2 = Unknown
x_3 = (Value)
y_3 = (Value)

To use just perform f(1,1,2.5,10,10) and ENTER

The result should be a direct linear interpolation with y_2 = 2.5

I hope this helps.

Though I recommend just using the EES software package, if it is available at your school and you can use it on an exam. It comes preloaded with almost all tabulated values of entropy, enthalpy, specific heat...etc etc.

Thank you, I will check it out. The linear fit as well.
Find all posts by this user
Quote this message in a reply
02-15-2014, 01:21 AM
Post: #5
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
Just wandering.
Did try to find the answer by yourself before asking?
Since this kind of problem is usually a primary school problem, it is surprising to see you asking the question.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
02-15-2014, 08:22 AM
Post: #6
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 01:21 AM)patrice Wrote:  Just wandering.
Did try to find the answer by yourself before asking?
Since this kind of problem is usually a primary school, it is surprising to see you asking the question.

Just wondering.
Did you read my OP? Anybody with a primary school level of English should understand that I knew how to calculate it, and did it before.
My main concern is and was saving key strokes, as time is critical during exams. I was hoping this could be done without programming my own function which I had not done yet on a calculator.
Find all posts by this user
Quote this message in a reply
02-15-2014, 08:46 AM
Post: #7
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
I have read again your first post.
It is not obvious that the problem was a matter of keystroke saving.

Why don't you just define the functions you need?
Once defined, you just recall the function and feed with parameters.
difficult to save more.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
02-15-2014, 10:53 AM
Post: #8
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 08:22 AM)DeucesAx Wrote:  
(02-15-2014 01:21 AM)patrice Wrote:  Just wandering.
Did try to find the answer by yourself before asking?
Since this kind of problem is usually a primary school, it is surprising to see you asking the question.

Just wondering.
Did you read my OP? Anybody with a primary school level of English should understand that I knew how to calculate it, and did it before.
My main concern is and was saving key strokes, as time is critical during exams. I was hoping this could be done without programming my own function which I had not done yet on a calculator.

I was in your shoes last millennium with an hp15c in thermodynamics course. I guess part of the fun of the hp15c was writing a small program for interpolation, even with only 4 stack levels and 5 inputs. I'm enjoying the HP Prime for the same reason today.

Note that besides defining a function, you may want to check out the spreadsheet app which is pretty powerful and flexible.

Best,
Carl
Find all posts by this user
Quote this message in a reply
02-15-2014, 12:16 PM (This post was last modified: 02-15-2014 12:16 PM by Tugdual.)
Post: #9
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
May not be super easy but this is another way:
- [Apps] Statistics 2 vars
- [Num] key
- enter x1, x2 in C1 and y1, y2 in C2
- [Symb]
- Make sure that Type1 is Linear
- Tab the field Fit1 and [Shift][View] (for Copy)
- [Apps] Function
- Tap F1 field
- [Shift][Menu] (for Paste)

Now call F1(X) from Home and you're done.
Find all posts by this user
Quote this message in a reply
02-15-2014, 02:51 PM
Post: #10
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 12:16 PM)Tugdual Wrote:  - Tab the field Fit1 and [Shift][View] (for Copy)
- [Apps] Function
- Tap F1 field
- [Shift][Menu] (for Paste)

Now call F1(X) from Home and you're done.

No need for that. Use the app functions PredX and PredY.

I think a lot of people haven't noticed yet that each application can have its own functions. For example, Stat2Var has PredX,PredY, and Resid. The triangle solver has SSS, SAS, etc. Basically, we'd like to make it so anything that can be done in an application can be done directly with functions as well.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
02-15-2014, 03:33 PM
Post: #11
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 02:51 PM)Tim Wessman Wrote:  I think a lot of people haven't noticed yet that each application can have its own functions. For example, Stat2Var has PredX,PredY, and Resid. The triangle solver has SSS, SAS, etc. Basically, we'd like to make it so anything that can be done in an application can be done directly with functions as well.
Indeed, thanks for mentioning it Tim, I learned something today.
Find all posts by this user
Quote this message in a reply
02-15-2014, 04:44 PM (This post was last modified: 02-15-2014 04:45 PM by CR Haeger.)
Post: #12
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 02:51 PM)Tim Wessman Wrote:  
(02-15-2014 12:16 PM)Tugdual Wrote:  - Tab the field Fit1 and [Shift][View] (for Copy)
- [Apps] Function
- Tap F1 field
- [Shift][Menu] (for Paste)

Now call F1(X) from Home and you're done.

No need for that. Use the app functions PredX and PredY.

I think a lot of people haven't noticed yet that each application can have its own functions. For example, Stat2Var has PredX,PredY, and Resid. The triangle solver has SSS, SAS, etc. Basically, we'd like to make it so anything that can be done in an application can be done directly with functions as well.

Tim - I assume you still have to setup and run the stat2var app before using predx or predy?
Find all posts by this user
Quote this message in a reply
02-15-2014, 05:27 PM
Post: #13
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-15-2014 04:44 PM)CR Haeger Wrote:  Tim - I assume you still have to setup and run the stat2var app before using predx or predy?
This is correct. The help also indicates that the functions will use the context of the first selected interpolation.
Find all posts by this user
Quote this message in a reply
02-16-2014, 02:03 AM (This post was last modified: 02-16-2014 02:07 AM by Joe Horn.)
Post: #14
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
This is not a one-keystroke solution, but I think it works. CAS only.

Example:
(x,y)1 = (1,5)
(x,y)2 = (7,17)
(x,y)3 = (10,?)

subst(lagrange([1,7],[5,17]),x=3) --> 23, answer.

In general: subst(lagrange([x1,x2],[y1,y2]),x=x3) --> y3, where "x" is a literal x.

Can somebody sober verify this? Thanx. I'm currently under the influence of Nyquil.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
02-16-2014, 02:13 PM
Post: #15
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-16-2014 02:03 AM)Joe Horn Wrote:  This is not a one-keystroke solution, but I think it works. CAS only.

Example:
(x,y)1 = (1,5)
(x,y)2 = (7,17)
(x,y)3 = (10,?)

subst(lagrange([1,7],[5,17]),x=3) --> 23, answer.

In general: subst(lagrange([x1,x2],[y1,y2]),x=x3) --> y3, where "x" is a literal x.

Can somebody sober verify this? Thanx. I'm currently under the influence of Nyquil.
I looks good to me :-)
Prompt recovery!
Find all posts by this user
Quote this message in a reply
02-19-2014, 03:16 AM
Post: #16
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
Hos do I do this? Sorry, for some reason Im an idiot when it comes to this calculator.

(02-15-2014 02:51 PM)Tim Wessman Wrote:  
(02-15-2014 12:16 PM)Tugdual Wrote:  - Tab the field Fit1 and [Shift][View] (for Copy)
- [Apps] Function
- Tap F1 field
- [Shift][Menu] (for Paste)

Now call F1(X) from Home and you're done.

No need for that. Use the app functions PredX and PredY.

I think a lot of people haven't noticed yet that each application can have its own functions. For example, Stat2Var has PredX,PredY, and Resid. The triangle solver has SSS, SAS, etc. Basically, we'd like to make it so anything that can be done in an application can be done directly with functions as well.
Find all posts by this user
Quote this message in a reply
02-20-2014, 05:46 AM (This post was last modified: 02-21-2014 06:52 AM by Joe Horn.)
Post: #17
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
(02-19-2014 03:16 AM)DeucesAx Wrote:  Hos do I do this?

Here's one way. If your Statistics 2Var app is still in its default state, then you can solve this:

(x,y)1 = (1,5)
(x,y)2 = (7,17)
(x,y)3 = (10,?)

by doing this, from the Home keyboard:

C1:={1,7} [the two X values]
C2:={5,17} [the two Y values]
PredY(10) Enter --> 23, answer.

As Tim mentioned, PredX also exists. It predicts an X from a Y value:
PredX(23) --> 10.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
02-21-2014, 01:49 AM
Post: #18
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
Thanks for explaining in detail how to use the App Functions per Tim's suggestion Joe. I figured out how to use the Stats 2Var Numeric form and the PredY function, but this walk-thru connected several dots for me on how to use App Functions directly from the Home Screen. The list is the form... now I get it!

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
02-21-2014, 02:28 AM
Post: #19
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
I ended up writing this little program:

export int2(xmin,xmax,ymin,ymax,yreal)
BEGIN
local xreal;
xreal:=xmin+((yreal-ymin)/(ymax-ymin))*(xmax-xmin);
return(xreal);
END;

As few keystrokes as it gets I suppose.
Find all posts by this user
Quote this message in a reply
Post Reply 




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