CurveP - J E Patterson

Description

J E Patterson - jepspectro.com - version 20180413

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 = scale*xorder + slope*x*e-factor*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.

x is first normalised, the equation solved and un-normalised to get y.
The equation parameters, scale, order, slope and factor are found by entering some standard data.

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 - y 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.

Enter f USER so the A to E keys can be pressed directly during data input without using GSB or f.

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]
Enter y data in A and x data in Y. eg. y1 ENTER y2 ENTER y3 GSB A.
The last data set relates X-ray fluorescence k line energy in keV to the element atomic number - see Moseley's Law.

In this update I have improved the starting values for the iteration and added a refined guess to the stack for Solve. Order is limited to 10.

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