Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() //please take note, this is not the full version. i cannot understand the f_left/f_right parts
- { //so i just left it as is first. the upper parts should be all inside
- printf("Hello world!\n");
- float stepsize; //should be the subinterval gap
- int p,q,r,s; //to replace a0,a1,a2,a3 because it is conflicitng with the end points
- float endpointax,endpointbx;
- float ay,by;
- int k=0;
- float L,M;
- int n;
- printf("the cubic polynomial has the form of 'f(X)=(a0)x^3 + (a1)x^2 +(a2)x + (a3)'\n\n");
- printf("what is the value of a0?\t");
- scanf("%d",&p);
- printf("what is the value of a1?\t");
- scanf("%d",&q);
- printf("what is the value of a2?\t");
- scanf("%d",&r);
- printf("what is the value of a3?\t");
- scanf("%d",&s);
- printf("\n\nWhat is the x value of interval endpoint A?\t");
- scanf("%f",&endpointax);
- printf("What is the x value of interval endpoint B?\t");
- scanf("%f",&endpointbx);
- printf("\nWhat is the step size?\t");
- scanf("%f",&stepsize);
- n=(endpointbx-endpointax)/stepsize; //to find number of subintervals
- ay= p* endpointax*endpointax*endpointax + q* endpointax*endpointax + r*endpointax + s;
- by= p* endpointbx*endpointbx*endpointbx + q* endpointbx*endpointbx + r*endpointbx + s;
- printf("\nA= %.2f,%.2f and B=%.2f,%.2f\n\n",endpointax,ay,endpointbx,by);
- while(k<=n-1)
- {
- L=endpointax + k*stepsize;
- M=L+stepsize;
- ay= p* L*L*L + q* L*L + r*L + s;
- by= p* M*M*M + q* M*M + r*M + s;
- /*
- check_roots(ay,by,endpointbx+k);*/
- printf("The %dth interval is %.2f,%.2f to %.2f,%.2f\n",k+1,L,ay,M,by);
- k++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement