Calculation Method of the error range in the previous example of the project (this method is also known as the stupid method, also known as the yugong mountain transfer method or the yugong war wisdom method)

Source: Internet
Author: User
-- 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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.