polynomial

63
! "# $ %&’ (

Upload: emmanuel-fuchs

Post on 12-Jan-2015

467 views

Category:

Education


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Polynomial

��������� ��������� ��� ���! ����"�#���� �������

$��������%&'�

���������������������� ���(���

Page 2: Polynomial

31

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 3: Polynomial

4

������������������ ������� ��

02 =++ cbxax

Page 4: Polynomial

5

������������������ ������� ��������)

aacbb

x2

42 −±−=

Page 5: Polynomial

6

������������������ ��� ��� � �����)

acb 42 −=∆

Page 6: Polynomial

7

X1 X2x

y

� ���� ����� ���)�" ��������� ��*

Page 7: Polynomial

8

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Initial Request

Page 8: Polynomial

9

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Few Weeks Later

1 Day After

Initial Request Evolution Request

Page 9: Polynomial

101

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 10: Polynomial

11

x

j

X1 X2

������� ����� ���)�" ��������� ��&

Page 11: Polynomial

12

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Initial Request

Page 12: Polynomial

13

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Few Weeks Later

1 Day After

Initial Request Evolution Request

Page 13: Polynomial

141

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 14: Polynomial

15

�� ��� ����� ���)�&���+��*����������,�

X1 X2

X XX

x

y

Page 15: Polynomial

16

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Initial Request

Page 16: Polynomial

17

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Few Weeks Later ?

1 Day After

Initial Request Evolution Request

Page 17: Polynomial

181

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 18: Polynomial

19

�������������� ��Start

Computes discriminantDelta = b * b – 4 * a * c

DiscriminantSign

Computes single rootComputes roots

print roots print root print no roots

Input coefficients a,b,c

End

< 0

= 0

> 0

Page 19: Polynomial

201

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 20: Polynomial

21

�����������

delta = (b*b) - (4*a*c); // discrimant computation

if (delta < 0.0) { System.out.println (" No roots");

}

else if (delta > 0.0) { System.out.println (" Two roots :"); System.out.println (" x1 = " + (-b + Math.sqrt(delta))/ (2.0 * a)); System.out.println (" x2 = " + (-b - Math.sqrt(delta))/ (2.0 * a));

}

else { System.out.println (“ Single root: "); System.out.println (" x = " + (-b / (2.0 * a)));

}

Page 21: Polynomial

221

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 22: Polynomial

23

�������������� ��Start

Computes discriminantDelta = b * b – 4 * a * c

DiscriminantSign

Computes single rootComputes roots

print roots print root print no roots

Input coefficients a,b,c

End

< 0

= 0

> 0

Page 23: Polynomial

24

�������������� ���&���(������

Start

Computes discriminantDelta = b * b – 4 * a * c

DiscriminantSign

Computes double rootComputes roots

print roots print root print roots

Input coefficients a,b,c

End

< 0

= 0

> 0

Computes Complex roots

Page 24: Polynomial

25

�����������

delta = (b*b) - (4*a*c); // discrimant computation

if (delta < 0.0) { System.out.println (" No roots");

}

else if (delta > 0.0) { System.out.println (" Two roots :"); System.out.println (" x1 = " + (-b + Math.sqrt(delta))/ (2.0 * a)); System.out.println (" x2 = " + (-b - Math.sqrt(delta))/ (2.0 * a));

}

else { System.out.println (“ Single root: "); System.out.println (" x = " + (-b / (2.0 * a)));

}

Page 25: Polynomial

26

������������" ������� " ��� ��

delta = (b*b) - (4*a*c); // discrimant computation

if (delta < 0.0) { System.out.println (" No roots");

}

else if (delta > 0.0) { System.out.println (" Two roots :"); System.out.println (" x1 = " + (-b + Math.sqrt(delta))/ (2.0 * a)); System.out.println (" x2 = " + (-b - Math.sqrt(delta))/ (2.0 * a));

System.out.println (" Complex roots"); System.out.println (" x1 real part = " + (-b / (2.0*a))); System.out.println (" x2 imaginary part = " + (-b - Math.sqrt(-delta))/ (2.0*a)+ "i"); System.out.println (" x2 real part = " + (-b / (2.0*a))); System.out.println (" x2 imaginary part= " + (-b - Math.sqrt(-delta))/ (2.0*a)+ "i");

}

else { System.out.println (“ Single root: "); System.out.println (" x = " + (-b / (2.0 * a)));

}

Page 26: Polynomial

271

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 27: Polynomial

28

����� �����,��� ���)�&���+��*����������,�

X1 X2

X XX

x

y

Page 28: Polynomial

29

DiscriminatSign

Computes roots case 2 2Computes root case 1

End

< 0

= 0

> 0

X == X1( /X1/ <= X & X <=

/X2/ )

Return True Return False Return True Return False Return False

F FTT

&���+��*����������,��)�������������� ��

Page 29: Polynomial

30

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Initial Request

Page 30: Polynomial

31

&�������*�������)�"�( ������� ��

1 Day After

1 Week After

Few Weeks Later ?

1 Day After

Initial Request Evolution Request

Page 31: Polynomial

32

�������&���

static boolean isInBetweenRoots(double x,double a,double b, double c) {

double delta, x1, x2; delta = (b*b) - (4*a*c);

if (delta < 0.0)

return false;

else if (delta > 0.0) {

System.out.print("delta > 0"); x1 = (-b + Math.sqrt(delta))/ (2.0*a); x2 = (-b - Math.sqrt(delta))/ (2.0*a); return (Math.abs(x1) <= Math.abs(x)) && (Math.abs(x) <= Math.abs(x2));

}

else { x1 = -b / (2.0 * a); return (x == x1);

} }

Page 32: Polynomial

331

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 33: Polynomial

34

� �����������-����)����� ��-���

���������� �� � �� � � �

�� �� � ��� ������������� �� � �� � � �

� � ��� ��� ����������� �� � �� � � �

� ��� ������������� �� � �� � � �

Page 34: Polynomial

35

� �����������-����)����� ��-���

���������� �� � �� � � �

�� �� � ��� ������������� �� � �� � � �

� � ��� ��� ����������� �� � �� � � �

� ��� ������������� �� � �� � � �

� � � �� � �� ��

Page 35: Polynomial

36

� ������� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 36: Polynomial

37

��� ���-����&���� ���# �������������

���������� �� � �� � � �

computeRoots()create()

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

Page 37: Polynomial

381

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 38: Polynomial

39

���� ��-���

���������� �� � �� � � �

� � � �� � �� ��

Page 39: Polynomial

40

���� ��-���)������� ������������������� �� � �� � � �

� � � �� � �� ��

���������� �� � �� � � �� � �� �� ������

Page 40: Polynomial

41

���� ��-���)������� ������������������� �� � �� � � �

� � � �� � �� ��

���������� �� � �� � � �� � �� ��

Page 41: Polynomial

42

� ������� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 42: Polynomial

43

� ��� � ����

class Discriminant {

private double delta;

public Discriminant (double a, double b, double c) {

delta = (b * b) - (4.0 * a * c);

}

public double value () {

return delta; }

}

Page 43: Polynomial

44

�������)��� � ��*��� �������

static Polynome create( double a, double b, double c) {

Discriminant theDiscriminant = new Discriminant(a,b,c); double delta = theDiscriminant.value();Polynome polynome;

if (delta == 0.0) {

return polynome = new SingleRootPolynome(a,b,c,theDiscriminant) ; } else if (delta > 0.0) {

return polynome = new TwoRootsPolynome(a,b,c,theDiscriminant) ; } else {

return polynome = new NoRootPolynome(a,b,c,theDiscriminant); }

}

Page 44: Polynomial

45

�����������*��� ��������&�����

static Polynome create( double a, double b, double c) {

Discriminant theDiscriminant = new Discriminant(a,b,c); double delta = theDiscriminant.value(); Polynome polynome;

if (delta == 0.0) {

return polynome = new SingleRootPolynome(a,b,c,theDiscriminant) ; } else if (delta > 0.0) {

return polynome = new TwoRootsPolynome(a,b,c,theDiscriminant) ; } else {

return polynome = new ComplexRootsPolynome(a,b,c,theDiscriminant); }

}

Page 45: Polynomial

461

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 46: Polynomial

47

��� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 47: Polynomial

48

&������������)�� ����*���������� �

void computesRoots() {

System.out.println (" Single root: ");

System.out.println (" x = " + (-b / (2.0*a)));

}

Page 48: Polynomial

49

��� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 49: Polynomial

50

&������������)��#��*����������� �

void computesRoots() {

System.out.println (" Two roots :");

System.out.println (" x1 = " + (-b + Math.sqrt(discriminant.value()))/ (2.0*a));

System.out.println (" x2 = " + (-b - Math.sqrt(discriminant.value()))/ (2.0*a));

}

Page 50: Polynomial

51

��� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 51: Polynomial

52

&������������)�.��*���������� �

void computesRoots() {

System.out.println (" No roots");

}

Page 52: Polynomial

531

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 53: Polynomial

54

��� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� ��� ������������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 54: Polynomial

55

��� ���-����# �������� ��

���������� �� � �� � � �

computeRoots()

Double aDouble bDouble c

�� �� � ��� ������������� �� � �� � � �

computeRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()

� � � � �� �� ��� ����������� �� � �� � � �

computeRoots()

� � � �� � �� ��

Page 55: Polynomial

56

&������������)�&���(�*����������� �

void computesRoots() {

System.out.println (" Complex roots");

System.out.println (" x1 real part = " + (-b / (2.0*a)));

System.out.println (" x1 imaginary part = “

+ (-b + Math.sqrt(-discriminant.value()))/ (2.0*a)+ "i");

System.out.println (" x2 real part = " + (-b / (2.0*a)));

System.out.println (" x2 imaginary part = “

+ (-b - Math.sqrt(-discriminant.value()))/ (2.0*a)+ "i");

}

Page 56: Polynomial

571

������������������ �

� ���������

� ������� ��������������

� ������� ��������������

� �������������� ��

� �� � ������ �������

� ������� ��������������

� ������� ��������������

� ����������� ��

� ������ ���������

� �� � ������ �������

� ������� ��������������

� ������� ��������������

Page 57: Polynomial

58

��� ���-���

���������� �� � �� � � �

computeRoots()isInBetweenRoots()

�� �� � ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()isInBetweenRoots()

� ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

Page 58: Polynomial

59

/���+����������������)�� ��������

boolean isInBetweenRoots(double x) {

return (x == x1);

}

Page 59: Polynomial

60

��� ���-���

���������� �� � �� � � �

computeRoots()isInBetweenRoots()

�� �� � ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()isInBetweenRoots()

� ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

Page 60: Polynomial

61

/���+����������������)��#�������

boolean isInBetweenRoots(double x) {

return (Math.abs(x1) <= Math.abs(x)) &&

(Math.abs(x) <= Math.abs(x2));

}

Page 61: Polynomial

62

��� ���-���

���������� �� � �� � � �

computeRoots()isInBetweenRoots()

�� �� � ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

� � ��� ��� ����������� �� � �� � � �

computeRoots()isInBetweenRoots()

� ��� ������������� �� � �� � � �

computeRoots()isInBetweenRoots()

Page 62: Polynomial

63

/���+����������������)���������

boolean isInBetweenRoots(double x) {

return false;

}

Page 63: Polynomial

64

����0�� ��111