473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Too few arguments on ~approx. lines 29 and 32 on fp and newton statements

Too few arguments error around lines 29 and 32

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. double f(double a, double b, double c, double x)
  5. {
  6. return pow(x,3)+a*pow(x,2)+b*x+c;
  7. }
  8. double fp(double a, double b, double c, double x)
  9. {
  10. return 3*pow(x,2)+(2*a*x)+b+0*c;
  11. }
  12. double newton(double a, double b, double c, double x)
  13. {
  14. return x - (f(a,b,c,x)/fp(a,b,c,x));
  15. }
  16. int main()
  17. {
  18. double a,b,c,x1,x2; 
  19. int i;
  20. char *input = getenv("QUERY_STRING");
  21. sscanf(input, "coeff1=%lf &coeff2=%lf &coeff3=%lf &x=%lf", &a, &b, &c, &x1);
  22. if (fp(x1)==0.0)
  23. {
  24. printf("No convergence.\n");
  25. return 0;
  26. }
  27. for (i=0;i<100;i++)
  28. {
  29. x2=newton(x1);
  30. if (fabs(x1-x2)<= pow(10,-10)) break;
  31. x1=x2;
  32. }
  33. printf("iteration = %d\n", i);
  34. printf("x= %lf\n", x1);
  35. return 0;
  36. }
Nov 21 '13 #1
0 938

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: vegetax | last post by:
if i have a dictionary: d = {'a':2,'b':3 } l = (1,2) how can i pass it to a generic function that takes variable keywords as arguments? same thing with variable arguments, i need to pass a list...
19
by: Alex Vinokur | last post by:
Is there any tool to count C-program lines except comments? Thanks, ===================================== Alex Vinokur mailto:alexvn@connect.to http://mathforum.org/library/view/10978.html...
39
by: slogging_away | last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script...
9
by: horizon5 | last post by:
Hi, my collegues and I recently held a coding style review. All of the code we produced is used in house on a commerical project. One of the minor issues I raised was the common idiom of...
13
by: dtshedd | last post by:
I am having trouble with arguments in a javascript routine. What I am trying to do is to limit the size of numbers to ten digits but make use of the significant places if the number is less than...
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
19
by: Pavan | last post by:
Hi, I want to know if there is any software for measuring lines of code of my c++ application. I found out a tool, sloccount, but it gives only physical lines of code. I found out one more...
3
by: DrVitoti | last post by:
On that program the compiler says "parse error" on line 8, 10, 12 and 21, it also says "too many arguments" on lines 10, 12 and finally it says "at this port in" on lines 13, 14, 20 . How could I...
9
by: vivek | last post by:
Hi i have used some debug macro and called several times(hundreds) in the code. The purpose of the macro was to print the values at that time to the screen Now that i have finished...
6
by: pauldepstein | last post by:
Let double NR( double x, double(*)(const double&) f ) be the signature of a Newton-Raphson function NR. Here, f is a function which returns a double and accepts a const double&. The aim of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.