answersLogoWhite

0

Can someone tell you what is wrong with these programs?

Updated: 8/19/2019
User Avatar

Gretzky82

Lvl 1
13y ago

Best Answer

//Newton's Method

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

double f(double x);

double df(double x);

int main()

{

double Delta = 1E-6;

double Epsilon = 1E-6;

double Small = 1E-6;

int Max = 99;

int Cond = 0;

int K;

double P0;

double P1;

double Y0;

double Y1;

double Df;

double Dp;

double RelErr;

printf("Enter initial value\n");

scanf("%lf", &P0);

Y0 = f(P0);

for (K = 1; K <= Max ; K++)

{

if(Cond) break;

Df = df(P0);

if( Df == 0)

{

Cond = 1;

Dp = 0;

}

else

{

Dp = Y0/Df;

}

P1 = P0 - Dp;

Y1 = f(P1);

RelErr = 2 * fabs(Dp) / (fabs(P1) + Small);

if( (RelErr < Delta) && (fabs(Y1) < Epsilon) )

{

if(Cond != 1)

{

Cond = 2;

}

}

P0 = P1;

Y0 = Y1;

}

printf("\nIteration: %d > %lf\n", K-1, P1);

system("PAUSE");

return 0;

}

double f(double x)

{

return tan(x) - x - 1;

}

double df(double x)

{

return -cos(x);

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can someone tell you what is wrong with these programs?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is it wrong to tell on a bully?

No, you should always tell someone if you or someone you know is being bullied.


Is it wrong to not say something about someone that might harm others.?

wellyou should tell someone


What does tell on someone mean?

Are you 5 years old? Tell on someone, is to tell someone else that someone is doing something wrong. But don't do that, other wise you'll be a dibber dobber cindy, and you'll go to kindy.


What do you do when my parents keep asking you what's wrong and there's nothing wrong but they keep asking?

Tell them what is wrong, because it's better to tell someone than keep it to yourself xx


What is a word to tell some someone angrily that they did something wrong?

berate, scolded


Is it right to tell your brother about your girlfriend?

ya you need to tell someone and if you trust your brother enough then there is nothin wrong with that.


I can't download any games with winwar can someone tell me what is wrong?

you can download WinWar games!! If not, then something is wrong with your computer.


Is it wrong to tell someone that something they condone would be forbidden in your religion?

Yea, think so. -- another answer -- No, it is not wrong to tell them. But - it would be wrong to try to force them to change their views purely because of your religious opinions.


What does it mean if someone 'is a sucker for you'?

It means that they will do whatever you tell them, even if they know it's wrong.


What is the means critise?

Do you mean 'criticize?' That means to tell what is wrong, what is bad about someone or something.


Do you kiss and tell?

Yes there is nothing wrong with telling a freind when you kiss someone I always do.


how to get stronger personality?

If you mean mentally always think you are right if someone says your wrong THINK YOU ARE NOT unless I tell you, you are wrong than you ARE