# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
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 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.
Just wandering.
Since this kind of problem is usually a primary school problem, it is surprising to see you asking the question.
(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.
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.
(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
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 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-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 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 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.
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.
(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!
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-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.
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!
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.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :