Wednesday, April 26, 2017

HP Prime and TI-84 Plus: Basic Wheatstone Full Bridge Circuit

HP Prime and TI-84 Plus:  Basic Wheatstone Full Bridge Circuit

The program WHEATSTONE (HP Prime) and WHTSTONE (TI-84 Plus CE) deals with the full Wheatstone circuit:



Formulas

EA = E * (1 – R4/(R4 + R3))
EB = E * (1 – R1/(R1 + R2))
eO = EA – EB

Variables used:  A = R1, B = R2, C = R3, D = R4, L = EA, R = EB, O = eO

Resistance is measured in ohms (Ω), current in volts (V).

HP Prime Program WHEATSTONE

EXPORT WHEATSTONE()
BEGIN
// 2017-04-25 EWS

LOCAL K,A,B,C,D,L,R,O;

INPUT({A,B,C,D,E},
"Basic Wheatstone",
{"R1: ","R2: ","R3: ","R4: ",
"E: "});
L:=E*(1-D/(D+C));
R:=E*(1-A/(A+B));
O:=L-R;
PRINT();
PRINT("EA: "+L);
PRINT("EB: "+R);
PRINT("e0: "+O);
END;

TI 84 Plus CE Program WHTSTONE

"2017-04-25 EWS"
Input "R1: ",A
Input "R2: ",B
Input "R3: ",C
Input "R4: ",D
Input "E: ",E
E*(1-D/(D+C))→L
E*(1-A/(A+B))→R
L-R→O
Disp "EA: ",L
Disp "EB: ",R
Disp "EO: ",O

Example

Inputs:  R1:  200 Ω, R2:  150 Ω, R3:  180 Ω, R4:  200 Ω, E:  16 V

Results:   EA ≈ 7.57895 V, EB ≈ 6.85714 V, eo ≈ 0.742180 V

Source:

Strain Gages and Instruments.  Tech Note TN-514  Vishay Precision Group.  February 1, 2013.  Link:  http://www.vishaypg.com/docs/11064/tn514.pdfhttp://www.vishaypg.com/docs/11064/tn514.pdf

Note:

I will be taking some time off from blogging in early May. I am going to work on a presentation that I hope to present in HHC 2017 this September (link: http://hhuc.us/2017/ ).  I encourage anyone to come attend the HHC conferences, they are a lot of fun.  This year the conference will be in Nashville.

Eddie

This blog is property of Edward Shore, 2017



Sunday, April 23, 2017

HP Prime and TI-84 Plus CE: Shallow Wave Analysis

HP Prime and TI-84 Plus CE:  Shallow Wave Analysis

Introduction



The program H2OWAVES calculates wave speed, impedance, and wave flux for shallow ocean waves.  The following are assumed:

1. The criteria of λ < D/20 is assumed where λ is the length of the wave.
2. The water assumed to be 0°C, where the density (ρ) is 1,000 kg/m. 
3. SI units are used.  For gravity, g = 9.80665 m/s^2 is used.

Formulas Used

Wave Speed (m/s):  v = √(g * D)
Wave Impedance (Mks):  Z = ρ * v
Wave Energy Flux (W/m):  I = (ρ * g * H)^2/(2 * Z)
Maximum Possible Length (m):  λ = 20 * D

HP Prime Program H2OWAVES

EXPORT H2OWAVES()
BEGIN
// EWS 2017-04-21
// Shallow Wave Analysis
// for D/L<1/20
// SI Units

LOCAL D,H;
LOCAL v,Z,I;

INPUT({D,H},
"Wave Analysis",
{"D: ","H: "},
{"Depth (m)","Wave Height (m)"});

v:=√(9.80665*D);
Z:=1000*v;
I:=(9806.65*H)^2/(2*Z);

PRINT();
PRINT("Wave speed (m/s): "+v);
PRINT("Impedance (Mks): "+Z);
PRINT("Wave Flux (W/m): "+I);

RETURN {v,Z,I};

END;

TI-84 Plus CE Program H2OWAVES

"EWS 2017-04-23"
"SHALLOW WAVES"
"D<F/20"
Disp "SHALLOW WAVES"
Input "DEPTH (M): ",D
Input "HEIGHT (M): ",H
√(9.80665*D)→V
1000*V→Z
(9806.65*H)^2/(2*Z)→I
Disp "WAVE SPEED (M/S):",V
Disp "IMPEDANCE (WKS):",Z
Disp "WAVE FLUX (W/M):",I

Example

Input: 
Depth:  3.2 m
Height:  0.49 m

Output:
Wave Speed: 5.601899678 m/s
Impedance:  5601.899678 Wks
Wave Flux:  2060.953478 W/m

Source:

Ingard, K.U. Fundamental of Waves and Oscillations Cambridge University Press:  New York 1988.  IBSN 0 521 32734

Surf’s up!  Eddie


This blog is property of Edward Shore, 2017.

Wednesday, April 19, 2017

HP Prime and TI-84 Plus CE: Simple Logistic Regression

HP Prime and TI-84 Plus CE:  Simple Logistic Regression

The program SIMPLOGI attempts to fit two lists of data (X, Y) to the equation:

y = 1 / (A + B*e^(-x))

by using the translation:  X’ = e^-X and Y’ = 1/Y and performing linear regression analysis on X’ and Y’.   This is good for all data except when y = 0.

HP Prime Program SIMPLOGI

EXPORT SIMPLOGI(L1,L2)
BEGIN
// EWS 2017-04-18

LOCAL S:=SIZE(L1);
LOCAL L0:=MAKELIST(1,X,1,S);
L1:=e^(−L1);
L2:=1/L2;

LOCAL M1,M2,M3;
M1:=list2mat(CONCAT(L0,L1),S);
M1:=TRN(M1);
M2:=list2mat(L2,S);
M2:=TRN(M2);
M3:=CAS.LSQ(M1,M2);


RETURN {"Y=1/(A+Be^(−X))",M3};

END;

TI-84 Plus CE Program SIMPLOGI

Disp "LOGISTIC FIT"
Disp "Y=1/(A+B*e^(­X))"
Input "X: ",L
e^(­L)→L
Input "Y: ",L
1/L→L
LinReg(a+bx) L,L
Disp "A=",a
Disp "B=",b

Example

Data:  (X’ and Y’ are provided for reference)

X
Y
X’ = e^(-X)
Y’ = 1/Y
0.5
0.384
0.6065306597
2.604166667
1.0
0.422
0.3678794412
2.369668246
1.5
0.450
0.2231301601
2.222222222
2.0
0.468
0.1353352832
2.136752137
2.5
0.480
0.0820849986
2.083333333

X = {0.5, 1, 1.5, 2, 2.5}, Y = {0.384, 0.422, 0.45, 0.468, 048}

Results (Matrix [ [ A ]. [B ] ]):

A = 2.00185929
B = 0.9942654005

Hence y = 1 / (2.00185929 + 0.9942654005*e^(-x))

Eddie



This blog is property of Edward Shore, 2017

Wednesday, April 12, 2017

Approximating y = sin x (0 to 90 degrees, 0 to pi/2 radians)



Approximating y = sin x (0 to 90 degrees, 0 to pi/2 radians)


Calculation

I used the HP Prime to fit polynomials to data by using the vandermonde and LSQ commands.

vandermonde(vector):  creates the matrix consisting of rows [ 1, (n_i), (n_i)^2, (n_i)^3, …, (n_i)^(n-1) ] where the vector has n elements for each i.  Available from the Math-Matrix-Create submenu.

LSQ(X, y):  returns the coefficients [ [a_0], [a_1], [a_2], … , [a_n] ], the minimum norm least squares vector from the system X*a=y.  In this case, the vector a can also be estimated by the operation (X^T X)^-1 X^T y.  Available from the Math-Matrix-Factorize submenu.

Case 1:  Four Points of Data

Fit cubic polynomial to the following data.  Remember we are working with the range of 0° ≤ x ≤ 90° or 0 ≤ x ≤ π/2 radians

X
sin(x)
0
30°
1/2 = 0.5
60°
√3/2 ≈ 0.866025403785
90°
1

Example 1:  Full precision approximation

y = 1.78098409219E-2 x – 1.99435471445E-5 x^2 – 6.05408712068E-7 x^3

Note:  E-n stands for 10^(-n).

Absolute maximum error, data measured in 5° tick marks:  0.002371558429
Absolute maximum error, data measured in 1° tick marks:  0.002392465593



Example 2:  If we round all coefficients to six digits, we get:

y = 0.017810 x – 0.000020 x^2 – 0.000001 x^3

Absolute maximum error, data measured in 5° tick marks:  0.2881 

In comparison between Example 1 and Example 2, keeping the decimal places makes a big difference. 



Example 3:  Let’s see if we do better with using radians instead of degrees.

X
sin(x)
0
0
π/6
1/2 = 0.5
π/3
√3/2 ≈ 0.866025403785
π/2
1

y = 1.02042871863 x – 0.065470803224 x^2 – 0.113871899065 x^3

Maximum absolute error, data measured in π/36 radian tick marks: 0.002371558428
Maximum absolute error, data measured in π/180 radian tick marks: 0.002392465661

The maximum error in Example 3 matched Example 1.

Example 4:  Round the coefficients to six digits:

y = 1.020429 x – 0.065471 x^2 – 0.113872 x^3

Maximum absolute error, data measured in π/36 radian tick marks:  0.002371292924
(2 decimal places)

The difference between Example 2 and Example 4 is that less information is “lost” when rounding the coefficients to a set amount of digits, in this case, 6.

Case 2:  Seven Points of Data

x (degrees)
x (radians)
sin(x)
0
0
15°
π/12
(√6 - √2)/4 ≈ 0.258819045102
30°
π/6
1/2 = 0.5
45°
π/4
√2/2 ≈ 0.707106781185
60°
π/3
√3/2 ≈ 0.866025403785
75°
5π/12
(√6 + √2)/4 ≈ 0.965925826288
90°
π/2
1

Example 5:  Full Precision – Degrees

y = 1.74539026131E-2 x – 1.00636910048E-7 x^2 – 8.79821584089E-7 x^3 – 1.93973162632E-10 x^4 + 1.66950110845E-11 x^5 – 2.72879457224E-14 x^6

Absolute maximum error, data measured in 5° tick marks:  1.2072093E-6
(pretty darn good)

Example 6:  Full Precision – Radians

y = -6.98792887569E-12 + 1.0000349642 x – 3.30435720904E-4 x^2 – 0.165486304503 x^3 – 2.09062241321E-3 x^4 + 1.03087220879E-2 x^5  - 9.65423458482E-4 x^6

Maximum absolute error, data measured in π/36 radian tick marks:  0.00049429473
(3 decimal places)

I think the degrees approximation wins.  But what if we round the radians version (Example 6) to 6 decimal places?

Example 7:  6 Decimal Places – Radians

y = 1.000035 x – 0.00033 x^2 – 0.165486 x^3 – 0.002091 x^4 + 0.010309 x^5 – 0.000965 x^6

Maximum absolute error, data measured in π/36 radian tick marks:  9.03153E-6

Interesting result here, and a nice one at that!



Eddie

This blog is property of Edward Shore, 2017

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...