CurveP - J E Patterson

Description

J E Patterson - jepspectro.com - version 20191006

The program fits data that may be linear at low x,y amplitudes but y falls off at higher x values. This is a common issue in many physical systems. x1, y1 should preferably be on the linear part of the curve. CurveP is not a regression. It assumes that the data is reasonably precise. Linear and power fit data sets also work well.

The equation used is:

y = a.xb + c.x.e-d.x

See Curve Fitting at jepspectro.com.

Originally chart recorders were used to obtain data which occupied the y axis, leaving interpreted results naturally plotted on the x axis, when graphed on the same paper. Here we are using y as the equation output axis.

The parameters a = scale, b = order, c = slope and d = factor are calulated by iteration using 3 standards and a blank. x is first normalised, the equation solved and un-normalised to get y. This limits the magnitude of calculated values in the iteration.

y1, y2 and y3 are known standards with respective readings of x1, x2 and x3.

y1 ENTER, y2 ENTER, y3 GSB A
x1 ENTER, x2 ENTER, x3 GSB B

Do not press ENTER after y3 or x3.
Note that y3>y2>y1 and x3>x2>x1.
After normalisation y3 = x3 = 10 so x3 is not saved. y3 is used instead in the program.

The curve runs through the origin and three points (x1,y1) (x2,y2) (x3,y3). The order of the upper part of the curve is displayed.

y GSB C to get x. This uses SOLVE to run GSB D until zero, the solution x is obtained
x GSB D to get y.

If there is a blank value, enter it as data and subtract the output from all the results.

Test [x,y] data sets [2,2 4,5 5,8] [1,1 2,4 3,9] [1,1 2,2 3,3] [20,3.69 30,8.64 47,22.16]
The last data set relates X-ray fluorescence k line energy in keV to the element atomic number - see Moseley's Law.

Notes:

In this update I have improved the starting values for the iteration and added a refined guess to the stack for SOLVE. A second guess is created by entering the first twice and multiplying by 1.1.

Order is limited to 10.

Because only 3 standards and a blank are used a regression approach is not suitable. The iteration attempts to fit the standards and blank exactly. The standards need to be accurately prepared. The calibration curve can be validated by running other standards as samples.

Program Resources

Labels

Name Description
 A Enter y1, y2, y3 from stack
 B Enter x1, x2, x3 from stack, normalise, label 1 loop
 C Enter y to get x. Also entered on stack for guess
 D Enter x to get y
 1 Iteration loop runs from B to find parameters
 4 RCL .5 (temp1) 1/x STO .5 (temp1)
 5 Curve function-x = 0 for solve

Storage Registers

Name Description Name Description Name Description
 1 y1  7 xscale to normalise x data .4 a - scale parameter
 2 y2  8 yscale to normalise y data .5 temp1
 3 y3  9 c - slope parameter = x1/y1 .6 temp2
 4 b - order parameter - calculated .1 x1 .7 temp3
 5 d - factor parameter - first guess = 1 .2 x2 .8 xinput
 6 count - use to modify convergence rate .3 b - Order parameter - first guess ln(y3/y2)/ln(x3/x2) .9 yinput

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 055 16 CHS 110 44 .7 STO . 7
001 42,21,11 f LBL A 056 12 111 45,20, 4 RCL × 4
002 44 8 STO 8 057 45,20, 3 RCL × 3 112 44 4 STO 4
003 33 R⬇ 058 45,20, 9 RCL × 9 113 45 .7 RCL . 7
004 44 2 STO 2 059 30 114 1 1
005 33 R⬇ 060 45 3 RCL 3 115 30
006 44 1 STO 1 061 45 4 RCL 4 116 43 16 g ABS
007 45 8 RCL 8 062 43,30, 2 g TEST x<0 117 1 1
008 1 1 063 45 .3 RCL . 3 118 26 EEX
009 0 0 064 44 4 STO 4 119 16 CHS
010 44 3 STO 3 065 14 120 6 6
011 10 ÷ 066 10 ÷ 121 43,30, 8 g TEST x<y
012 44,10, 2 STO ÷ 2 067 44 .4 STO . 4 122 22 1 GTO 1
013 44,10, 1 STO ÷ 1 068 45,10, 1 RCL ÷ 1 123 45 4 RCL 4
014 43 32 g RTN 069 45 .1 RCL . 1 124 43 32 g RTN
015 42,21,12 f LBL B 070 45 4 RCL 4 125 42,21,14 f LBL D
016 44 7 STO 7 071 14 126 44 .8 STO . 8
017 33 R⬇ 072 20 × 127 45,10, 7 RCL ÷ 7
018 44 .2 STO . 2 073 44 .5 STO . 5 128 45 3 RCL 3
019 33 R⬇ 074 1 1 129 20 ×
020 44 .1 STO . 1 075 43,30, 8 g TEST x<y 130 44 .8 STO . 8
021 45 7 RCL 7 076 32 4 GSB 4 131 45 4 RCL 4
022 45 3 RCL 3 077 1 1 132 14
023 10 ÷ 078 45 .5 RCL . 5 133 45,20, .4 RCL × . 4
024 44,10, .2 STO ÷ . 2 079 30 134 45 5 RCL 5
025 44,10, .1 STO ÷ . 1 080 43 12 g LN 135 45,20, .8 RCL × . 8
026 45 3 RCL 3 081 16 CHS 136 16 CHS
027 45 2 RCL 2 082 45,10, .1 RCL ÷ . 1 137 12
028 10 ÷ 083 44 5 STO 5 138 45,20, .8 RCL × . 8
029 43 12 g LN 084 45,20, .2 RCL × . 2 139 45,20, 9 RCL × 9
030 45 3 RCL 3 085 16 CHS 140 40 +
031 45 .2 RCL . 2 086 12 141 45,20, 8 RCL × 8
032 10 ÷ 087 45,20, .2 RCL × . 2 142 45 3 RCL 3
033 43 12 g LN 088 45,20, 9 RCL × 9 143 10 ÷
034 10 ÷ 089 45 .4 RCL . 4 144 43 32 g RTN
035 44 4 STO 4 090 45 .2 RCL . 2 145 42,21,13 f LBL C
036 44 .3 STO . 3 091 45 4 RCL 4 146 44 .9 STO . 9
037 1 1 092 14 147 36 ENTER
038 44 5 STO 5 093 20 × 148 36 ENTER
039 0 0 094 40 + 149 1 1
040 44 6 STO 6 095 44 .6 STO . 6 150 48 .
041 45 1 RCL 1 096 45 2 RCL 2 151 1 1
042 45,10, .1 RCL ÷ . 1 097 45,10, 3 RCL ÷ 3 152 20 ×
043 44 9 STO 9 098 3 3 153 42,10, 5 f SOLVE 5
044 42,21, 1 f LBL 1 099 0 0 154 43 32 g RTN
045 1 1 100 20 × 155 42,21, 4 f LBL 4
046 44,40, 6 STO + 6 101 45,10, 6 RCL ÷ 6 156 45 .5 RCL . 5
047 45 3 RCL 3 102 11 √x̅ 157 15 1/x
048 45 4 RCL 4 103 45,20, .6 RCL × . 6 158 44 .5 STO . 5
049 43,30, 7 g TEST x>y 104 45 .6 RCL . 6 159 43 32 g RTN
050 45 .3 RCL . 3 105 45,30, 2 RCL 2 160 42,21, 5 f LBL 5
051 44 4 STO 4 106 10 ÷ 161 32 14 GSB D
052 45 3 RCL 3 107 15 1/x 162 45,30, .9 RCL . 9
053 45 5 RCL 5 108 1 1 163 43 32 g RTN
054 45,20, 3 RCL × 3 109 40 +