Thread: method of halving the intervals

  1. #1
    Registered User
    Join Date
    Sep 2016
    Posts
    1

    method of halving the intervals

    I'm having some trouble with figuring out how to write a certain program. the program i am supposed to write is meant to read in values from a data file and use those methods to find the roots of a quartic equation (x^4+3*x^3......+4) using the method of halving the interval. I believe i have the right code to obtain values from a data file, but don't know how to proceed from there. Any help would be greatly appreciated.
    This is what i have so far.

    Code:
    #include "stdafx.h"
    
    
    int main()
    {
        double  upperlimit, lowerlimit, b, c, d, e;
    
    
        double high, root;
        FILE *inp;
    
    
        int file_open = fopen_s(&inp, "U:\\GENG1003\\data.dat", "r");
    
    
    
    
        int file_read = fscanf_s(inp, "%lf %lf %lf %lf %lf %lf", &b, &c, &d, &e, &lowerlimit, &upperlimit);
    
    
        if (file_read == 6)
    
    
        {
            printf("For quartic polynomial a=1; b=%lf; c=%lf; d=%lf; e=%lf \n", b, c, d, e);
    
    
            printf("Within the domain of %lf < x < %lf \n", lowerlimit, upperlimit);
    
    
            high = upperlimit;
        }
    
    
        else
            printf("Invalid data \n");
    
    
    
    
        return 0;
    Thank you.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [ISO] Notation for mathematical intervals
    By Mario F. in forum General Discussions
    Replies: 12
    Last Post: 07-07-2015, 03:28 AM
  2. openMP - intervals assigned to threads
    By überfuzz in forum C++ Programming
    Replies: 6
    Last Post: 02-10-2014, 05:42 AM
  3. Replies: 4
    Last Post: 08-08-2012, 01:05 PM
  4. Replies: 77
    Last Post: 10-15-2011, 04:45 PM
  5. Connecting intervals together
    By kaspari22 in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2011, 11:32 AM

Tags for this Thread