Question

Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initia...

Hi, I need help with a fixed-point method program. It has to be done in C.

The inputs are: Initial approximation ρo, tolerance ε, and the maximum number of iterations MAXIT.

The outputs are: Approximate solution ρ or "solution not found".

STEP 1

Do i=1

STEP 2

While i≤ MAXIT, execute steps 3-6

STEP 3

Do ρ=ϕ(p) (calculate pi)

STEP 4

If |ρ-ρo|<ε then

output(ρ) (operation sucessful)

END

STEP 5

Do i=i+1

STEP 6

Do po=p (update po)

STEP 7

output (solution not found after MAXIT iterations)

END

0 0
Add a comment Improve this question Transcribed image text
Answer #1

main.c

#include<stdio.h>

#include<math.h>

float fixedPointIter(float);

int main()

{

float arr[100],arr1[100],arr2=100.0;

int x=1,y=0;

arr1[0]=(cos(0)-3*0+1);

printf("\nPlease enter initial guess:\n");

scanf("%f",&arr[0]);

printf("\n\n Values of iterations are:\n\n ");

while(arr2>0.00001)

{

arr[y+1]=fixedPointIter(arr[y]);

arr2=arr[y+1]-arr[y];

arr2=fabs(arr2);

printf("%d\t%f\n",y,arr[y]);

y++;

}

printf("\n Root of the function is %f",arr[y]);

  

  return 0;

}

float fixedPointIter(float x)

{

float y;

y=(cos(x)+2)/3;

return y;

}

Output:

Values of iterations are: 0 3.000000 1 0.336669 2 0.981287 3 0.851985 4 0.886164 5 0.877463 6 0.879701 7 0.879127 8 0.879275

Add a comment
Know the answer?
Add Answer to:
Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initia...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need someone to fix my C Program Code Firstly I will post the Q and...

    I need someone to fix my C Program Code Firstly I will post the Q and the input and the outputs Then the code Secondly the code =================================== #include <stdio.h> #include <math.h> int main() {    double a,b,c,d,l,x,x_0,x_1,x_mid,p_x,p_0,p_1,p_mid,E=1e-6; int i1,i2;          printf("Enter a,b,c,d of ax^3+bx^2+cx+d=0: "); scanf("%lf%lf%lf%lf",&a,&b,&c,&d); x_0=-50;x_1=-50;x=-50;p_0=a*(pow(x_0,3))+b*(pow(x_0,2))+c*x_0+d;i1=0;i2=0; do{        p_x=a*x*x*x+b*x*x+c*x+d;        l=p_x*p_0;        if(l<0){        x_1=x;}        i1=i1+1;x++;}        while(fabs(p_x)>=E && x<50);           if(fabs(p_x)<E){    printf("the polynominal has root...

  • Hi, I need some help with the a Mealy and Moore Logisim circuit drawings for part...

    Hi, I need some help with the a Mealy and Moore Logisim circuit drawings for part of a project, the details are below. Also here is an example of the mealy (I think) circuit that should work if the gates are changed to two inputs. If that is the case please confirme, then I really only need the Moore... The Clean Laundry Company (CLC) is interested in reducing the risk of personal injury to their customers while operating their washing...

  • Matlab & Differential Equations Help Needed I need help with this Matlab project for differential equations. I've got 0 experience with Matlab other than a much easier project I did in another...

    Matlab & Differential Equations Help Needed I need help with this Matlab project for differential equations. I've got 0 experience with Matlab other than a much easier project I did in another class a few semesters ago. All we've been given is this piece of paper and some sample code. I don't even know how to begin to approach this. I don't know how to use Matlab at all and I barely can do this material. Here's the handout: Here's...

  • Hi I need a fix in my program. The program needs to finish after serving the...

    Hi I need a fix in my program. The program needs to finish after serving the customers from the queue list. Requeriments: Headers: DynamicArray.h #ifndef DynamicArray_h #define DynamicArray_h #include using namespace std; template class DynamicArray { V* values; int cap; V dummy; public: DynamicArray(int = 2); DynamicArray(const DynamicArray&); ~DynamicArray() { delete[] values; } int capacity() const { return cap; } void capacity(int); V operator[](int) const; V& operator[](int); DynamicArray& operator=(const DynamicArray&); }; template DynamicArray::DynamicArray(int cap) { this->cap = cap; values =...

  • Please, I need help with program c++. This is a chutes and ladders program. The code...

    Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of the problem statement. Thank you very much. Assignment Overview This program will implement a variation of the game “chutes and ladders” or “snakes and ladders:” https://en.wikipedia.org/wiki/Snakes_and_Ladders#Gameplay. Just like in the original game, landing on certain squares will jump the player ahead or behind. In this case, you are trying to reach to bottom of the...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • PLEASE ONLY DO D IN MATLAB. I DID A B AND C, dont need them. Intro...

    PLEASE ONLY DO D IN MATLAB. I DID A B AND C, dont need them. Intro to Computers for Engineers Recitation 11 In today's class, we are modeling a spacecraft. Please submit all functions you write. Pay very careful attention to names. If you name a function differently from what you are instructed, things might not work. Test your code using the scripts siml.m and sim2.m before trying to submit on zyLabs. A. [Submit on zyLabs] Write a function that...

  • Need C programming help. I've started to work on the program, however I struggle when using...

    Need C programming help. I've started to work on the program, however I struggle when using files and pointers. Any help is appreciated as I am having a hard time comleting this code. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE 100 #define MAX_NAME 30 int countLinesInFile(FILE* fPtr); int findPlayerByName(char** names, char* target, int size); int findMVP(int* goals, int* assists, int size); void printPlayers(int* goals, int* assists, char** names, int size); void allocateMemory(int** goals, int** assists, char*** names, int size);...

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A*...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class. For more information, please read the wiki page of 15-puzzle problem at https://en.wikipedia.org/wiki/15_puzzle, and the wiki page of...

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* s...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. Please include pictures that the code runs and shows the different states as it reaches goal state please. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT