-- Calculation Method of the error range in the previous example of the project (using the method of exhaustion, also known as the stupid method, also known as the yugong mountain migration method, or the yugong war, the smart Olay method)
Declare @ const_a decimal (8, 6), @ const_ B decimal (8, 6), @ const_c decimal (8, 6 ),
@ P decimal (16,6), @ Q decimal (16,6), @ C decimal (16,6), @ step_p float, @ step_q float
Declare @ t table (P decimal (16,6), Q decimal (16,6), c decimal (16,6 ))
Select @ const_a = 0.001, @ const_ B = 0.001, @ const_c = 0.02 -- Effective bit and error limit value settings
Select @ p = 1, @ q = 1, @ step_p = 0.001, @ step_q = 0.001 -- set the start value and step value
Select @ C = (Power (@ P + @ const_a, 2) + power (@ q + @ const_ B, 2), 0.5)-power (@ P, 2) + power (@ Q, 2), 0.5)/power (@ P, 2) + power (@ Q, 2), 0.5)
While (@ C <= @ const_c) and (@ P> = 0) and (@ q> = 0 ))
Begin
-- Select @ P, @ Q, @ C
Insert into @ T (p, q, c) Select @ P, @ Q, @ C
Select @ P = @ p-@ step_p, @ q = @ Q-@ step_q
Select @ C = (Power (@ P + @ const_a, 2) + power (@ q + @ const_ B, 2), 0.5)-power (@ P, 2) + power (@ Q, 2), 0.5)/power (@ P, 2) + power (@ Q, 2), 0.5)
End
-- Print 'P and Q variable value range :'
Select P as P value, Q As Q value, C as error value from @ t order by 1, 2