Pascal Implementation of the function value in the binary method

Source: Internet
Author: User
Returns the approximate value of a monotonic function on (a, B) using the bipartite method.

The expression in the eighth row can be changed. The accuracy is determined by the kexi in the third row. A small value can be used to increase the extended value of the fifth row to real or double.

Program equantion (input, output );

Const

Kexi = 0.0000001;

VaR

A, B, C: extended;

Function FX (X: Extended): extended;

Begin

FX: = ln (X)/ln (2 );

End;

Begin

Writeln ('Please input a and B ', 'produced by chaos ')

Read (A, B );

C: = (a + B)/2;

If FX (c) = 0

Then writeln ('X = ', c)

Else repeat

If FX (a) * FX (c) <0

Then B: = C

Else A: = C;

Until ABS (a-B) <kexi;

If FX (c) <> 0

Then writeln ('X = ', );

End.

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.