Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
02-14-2014, 07:46 AM
Post: #1
 DeucesAx Junior Member Posts: 20 Joined: Feb 2014
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?
02-14-2014, 02:52 PM (This post was last modified: 02-14-2014 04:11 PM by Han.)
Post: #2
 Han Senior Member Posts: 1,817 Joined: Dec 2013
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
02-14-2014, 04:44 PM (This post was last modified: 02-14-2014 04:45 PM by Rich.)
Post: #3
 Rich Junior Member Posts: 47 Joined: Jan 2014
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.
02-14-2014, 09:48 PM
Post: #4
 DeucesAx Junior Member Posts: 20 Joined: Feb 2014
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.
02-15-2014, 01:21 AM
Post: #5
 patrice Member Posts: 180 Joined: Dec 2013
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
Just wandering.
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
02-15-2014, 08:22 AM
Post: #6
 DeucesAx Junior Member Posts: 20 Joined: Feb 2014
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.
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.
02-15-2014, 08:46 AM
Post: #7
 patrice Member Posts: 180 Joined: Dec 2013
RE: Linear Interpolation: Given a pair of (x1,y1), (x2,y2) and x3 predict (x3,y3)
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
02-15-2014, 10:53 AM
Post: #8
 CR Haeger Member Posts: 275 Joined: Dec 2013
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.
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
02-15-2014, 12:16 PM (This post was last modified: 02-15-2014 12:16 PM by Tugdual.)
Post: #9
 Tugdual Senior Member Posts: 751 Joined: Dec 2013
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

Now call F1(X) from Home and you're done.
02-15-2014, 02:51 PM
Post: #10
 Tim Wessman Senior Member Posts: 2,231 Joined: Dec 2013
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

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 the HP calculator group, the views and opinions I post here are my own.
02-15-2014, 03:33 PM
Post: #11
 Tugdual Senior Member Posts: 751 Joined: Dec 2013
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.
02-15-2014, 04:44 PM (This post was last modified: 02-15-2014 04:45 PM by CR Haeger.)
Post: #12
 CR Haeger Member Posts: 275 Joined: Dec 2013
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

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?
02-15-2014, 05:27 PM
Post: #13
 Tugdual Senior Member Posts: 751 Joined: Dec 2013
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.
02-16-2014, 02:03 AM (This post was last modified: 02-16-2014 02:07 AM by Joe Horn.)
Post: #14
 Joe Horn Senior Member Posts: 1,612 Joined: Dec 2013
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,?)

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-
02-16-2014, 02:13 PM
Post: #15
 Tugdual Senior Member Posts: 751 Joined: Dec 2013
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,?)

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!
02-19-2014, 03:16 AM
Post: #16
 DeucesAx Junior Member Posts: 20 Joined: Feb 2014
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

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.
02-20-2014, 05:46 AM (This post was last modified: 02-21-2014 06:52 AM by Joe Horn.)
Post: #17
 Joe Horn Senior Member Posts: 1,612 Joined: Dec 2013
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]

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

<0|ɸ|0>
-Joe-
02-21-2014, 01:49 AM
Post: #18
 rprosperi Senior Member Posts: 4,040 Joined: Dec 2013
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
02-21-2014, 02:28 AM
Post: #19
 DeucesAx Junior Member Posts: 20 Joined: Feb 2014
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.
 « Next Oldest | Next Newest »

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