Results 1 to 17 of 17

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Apr:2008
    Location: Bulgaria
    Posts: 3

    ++

    . .
    :



    Code:
    #include <iostream>
    
    using namespace std;
    
    #include <math.h>
    
    double F(double x)
    {
    double res = pow(x, 3) - pow(x, 2) + 8 * pow(x, 2) -12;
    
    return res;
    }
    
    void print_roots(){
    
    double low , high; //  
    cout<<"low=";cin>>low;
    cout<<"high=";cin>>high;
    
    for(int i = 0; i < 1000 ; ++i){
    
    double mid = (float)(low + high)/2;
    
    double val = F(mid);
    
    cout << mid << ":" << val << endl;
    
    if(val < 0.00001 && val > -0.00001){
    
    cout << "Root is " << mid << endl;
    
    return;
    
    }
    
    else if (val < 0 )
    
    low = mid;
    
    else
    
    high = mid;
    
    }
    
    }
    
    int main(int argc, char **argv){
    
    print_roots();
    
    system("pause");
    
    return 0;
    
    }
    . , , ( -1) ( - + ) :
    double res = pow(x, 9) - pow(x, 7) + 2 * pow(x, 2) -1;

    .
    .
    mid = 0.
    . 0 0. 6 .
    .
    .

  2. #2
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    , - (.. , 1, -1, 2 -1, 9, 7, 2 0. " " - - .

    , - 'x' F mid? , . , , mid for . .. "" . , cout << mid << ":" ...
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  3. #3
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    , ? ? :
    pow(x, 3) - pow(x, 2) + 8 * pow(x, 2) -12 = 0 ?!

    @anrieff , -:
    double F(double x), : .

    :
    Quote Originally Posted by TheTerrorist View Post
    .
    .
    , . !
    1) : double mid = (float)(low + high)/2; ( float?!), :
    double mid = (high - low)/2;

    , , , . , , , .

    Quote Originally Posted by TheTerrorist View Post
    mid = 0.
    , . , :
    pow(x,2)-1 = 0 [0,3] 10- 1 ( )

    .. , - . . + , .
    : ( ) -> .
    Last edited by Kaspirtov; 6th April 2008 at 11:53.
    " , , , , ."

  4. #4
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    Quote Originally Posted by Kaspirtov View Post
    1) : double mid = (float)(low + high)/2; ( float?!), :
    double mid = (high - low)/2;
    , , , "+" (mid low high, ). float , .

    , F(mid), F(low) F(high) , , .. . , F(low) < 0 F(high) > 0. , , low high , .

    - ( ), , , .
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  5. #5
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    Quote Originally Posted by icaci View Post
    , , , "+" (mid low high, ). float , .
    : double mid = low + (high - low)/2; , ....
    , ?! F(mid), Abs(F(mid))<0.00001., :
    if(val < 0.00001 && val > -0.00001)
    . (.. , - , )

    , , , "" ?!
    " , , , , ."

  6. #6
    Registered User
    Join Date: Dec:2007
    Location:
    Posts: 655
    Quote Originally Posted by Kaspirtov View Post
    : ( )
    . x^2 [-1;1]. , .

    Quote Originally Posted by icaci View Post
    , ?
    () , ...

    Quote Originally Posted by Kaspirtov View Post
    -> , , , , ....
    , , , ?

  7. #7
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    ?!?!?!?!?!?!?!?!?!
    , , ?!?! !

    :
    Quote Originally Posted by AK-85 View Post
    . x^2 [-1;1]. , .
    ... ... .
    (-inf, +inf) !
    "" !

    Next time :
    Quote Originally Posted by Kaspirtov
    , , , "" ?!
    -> !

    Quote Originally Posted by AK-85 View Post
    , , , ?
    ?!?!?
    , !
    - !
    Search google " "!
    Last edited by Kaspirtov; 10th April 2008 at 10:06.
    " , , , , ."

  8. #8
    Registered User
    Join Date: Dec:2007
    Location:
    Posts: 655
    Kaspirtov, , , , .

    Quote Originally Posted by Kaspirtov View Post
    ... ... .
    (-inf, +inf) !
    "" !
    - , , , , ... , , , , , .

    , , , "" "" , , , , . ...

    Quote Originally Posted by Kaspirtov View Post
    , !
    - !
    , , - ( , , !), . icaci , , , .

    - tan(x), [-1;1], , - 1, "" .

  9. #9
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    , , !
    Quote Originally Posted by AK-85 View Post
    - tan(x), [-1;1], , - 1, "" .
    tan(x) :
    ax^(2) + bx + c ?!
    , - . . .. - . () tan(x) , , , - .
    hint
    Quote Originally Posted by Kaspirtov
    Search google " "
    !

    , , " " ?! - , ,
    " , , , , ."

  10. #10
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    low/high , .
    , ? , ,
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  11. #11
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    Quote Originally Posted by icaci View Post
    , ? , ,
    ? , ?
    -> , , , , ....

    PM ?
    Last edited by Kaspirtov; 6th April 2008 at 19:52.
    " , , , , ."

  12. #12
    Registered User
    Join Date: Jul:2006
    Location:
    Posts: 480
    " ", . K ....
    , .
    [A;B], -
    Code:
     C=(A+B)/2
    . F(c)=0, . [A;C], [C;B], .
    E, : . [A;B], - E. X, - , - E, . . :

    Code:
    [  A, B  E]
    
      REPEAT
        C=(A+B)/2                     ; 
        IF F(C)=0 THEN BREAK          ;   
        ELSE IF F(C)*F(A)>0 THEN A=C  ;    
        ELSE B=C                      ;    
      UNTIL ABS(A-B)<=E               ;   
      PRINT "KORENYT E X=",C          ;  
    :
    IF A>B THEN [ ].

    :
    DO-WHILE - ABS(A-B)>E

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |