15,896,549 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by MalDrHoop (Top 38 by date)
MalDrHoop
26-Mar-14 15:46pm
View
I did as indicated in the algorithm... I do not know how to fix this.
MalDrHoop
26-Mar-14 13:13pm
View
I edited my program as you described:
#include <stdio.h>
#include <math.h>
#define num 20
double f(double x)
{
return (1/(x*sin(x*x)));
//return (2*x*x);
}
int main()
{
int i=1, N;
double b, APP, TOL[num], a[num], h[num], FA[num], FB[num], FC[num], S[num], S1, S2, L[num], FD, FE, v[num];
printf("Left Endpoint: ");
scanf("%lf", &a);
printf("Right Endpoint: ");
scanf("%lf", &b);
printf("Desired Tolerence: ");
scanf ("%lf", &TOL);
printf("Number of Levels: ");
scanf("%d", &N);
APP = 0;
TOL[num] = 10.0*TOL;
a[num] = a;
h[num] = (b-a)/2;
FA[num] = f(a);
FC[num] = f(a+h[num]);
FB[num] = f(b);
S[num] = h[num]*(FA[num]+4*FC[num]+FB[num])/3; //Simpsons approximation
L[num] = 1;
while (i>0)
{
FD = f(a[num] + h[num]/2);
FE = f(a[num] + 3*h[num]/2);
S1 = h[num]*(FA[num]+4*FD+FC[num])/6;
S2 = h[num]*(FC[num]+4*FE+FB[num])/6;
v[1] = a[num];
v[2] = FA[num];
v[3] = FC[num];
v[4] = FB[num];
v[5] = h[num];
v[6] = TOL[num];
v[7] = S[num];
v[8] = L[num];
i=i-1;
if (abs(S1 + S2 - v[7])<v[6])
{
="" app="APP" +="" (s1="" s2);
="" }
="" else
="" if="" (v[8]="">=N)
{
printf("Level Exceeded");
return;
}
else
{
i++;
a[num] = v[1] + v[5];
FA[num] = v[3];
FC[num] = FE;
FB[num] = v[4];
h[num] = v[5]/2;
TOL[num] = v[6]/2;
S[num] = S2;
L[num] = v[8] + 1;
i++;
a[num] = v[1];
FA[num] = v[2];
FC[num] = FD;
FB[num] = v[3];
h[num] = h[num-1];
TOL[num] = TOL[num-1];
S[num] = S1;
L[num] = L[num-1];
}
}
}
printf("The Integral Approximation is %lf." , APP);
}
Still Obtaining:
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c||In function 'main':|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|35|error: invalid operands to binary * (have 'double' and 'double *')|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|36|error: incompatible types when assigning to type 'double' from type 'double *'|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|37|error: invalid operands to binary - (have 'double' and 'double *')|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|39|error: incompatible type for argument 1 of 'f'|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|11|note: expected 'double' but argument is of type 'double *'|
C:\Users\Mal\Desktop\MTH 415\Adaptive Quadrature 2.c|40|error: invalid operands to binary + (have 'double *' and 'double')|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
MalDrHoop
14-Feb-14 20:54pm
View
Both outputs are similar cause the two codes are different. They aren't quite the same. If I copied and pasted the same outputs its because I got all jumbled trying to get everything straightened up lol. My bad on that part. I knew the tolerance was too big, I had just chose one to try and type the inputs quickly to have the results here for someone to look at. I had been running about .00001. All of my stuff came from my numerical analysis textbook and class. My class is using Faire's and Burden 7th edition. I don't have it with me right now to look it up
MalDrHoop
14-Feb-14 20:46pm
View
Beginner's mistake!
MalDrHoop
14-Feb-14 16:18pm
View
Did you see any problems?
MalDrHoop
14-Feb-14 13:50pm
View
As you can see, my program went through fine, but I think I may have set something up wrong that wasn't incorrect in relation to the debugging but is incorrect in relation to the program and its purpose. After trying larger amounts of iterations, my method continues to fail, and doesnt reach the value it should. I can not find the problem in my program, my eye is untrained at this sort of thing. I have done the best I can with what I have. I had no programming experience just a couple weeks ago so I am proud that I am this far, but that is besides the point. I should be converging to a value of -1.414325. It is possible to take quite a few iterations using Newtons method, but It should be pretty quick using the modified.
MalDrHoop
8-Feb-14 18:44pm
View
I think it turned out pretty good. Thank you for your help. :)
MalDrHoop
8-Feb-14 18:26pm
View
Enter approximate p: 1
Desired Tolerance: .01
Maximum Iterations: 10
Iteration 1: Current value = 1.565085
Iteration 2: Current value = 1.793573
Iteration 3: Current value = 1.885944
Iteration 4: Current value = 1.922848
Iteration 5: Current value = 1.937508
Process returned 1072693280 (0x3FF00020) execution time : 7.555 s
Press any key to continue.
MalDrHoop
8-Feb-14 18:13pm
View
I pasted the new one above
MalDrHoop
8-Feb-14 17:56pm
View
Thank you, I am going to try and see if I can piece this thing together now.
MalDrHoop
8-Feb-14 17:34pm
View
I quess I dont quite grasp the concept. Ive missed some class due to illness. Is g(x) basically a rewritten form of the given equation? The equation I have used here is x^4-3x^2-3. so does that mean I need an element of x-(x^4-3x^2-3)? Im sorry, I am trying to figure it out.
MalDrHoop
8-Feb-14 17:23pm
View
Deleted
Step 4 If |p-p0|
MalDrHoop
8-Feb-14 17:11pm
View
I just looked back at the algorithm, and it says to set p=g(p0). (compute pi.) so thats probablly part of where I messed up, I am just not sure exactly what I need to do for my g(p0).
Algorithm: (see question)
MalDrHoop
3-Feb-14 15:07pm
View
It's fine lol. I should have noticed before I implemented it.
MalDrHoop
3-Feb-14 13:00pm
View
I found the issue. I tried it before your edit. I did not realize you edited it before I came back to comment. But it was the %d instead of the %lf in correspondence with my p
MalDrHoop
3-Feb-14 12:48pm
View
From the first method im just getting:
Enter first endpoint: -2
Enter second/last endpoint: 1.5
Desired Tolerance: .01
Maximum Iterations: 20
Iteration 1: Current value = 0Iteration 2: Current value = 0Iteration 3: Current
value = 0Iteration 4: Current value = 0Iteration 5: Current value = 0Iteration
6: Current value = 0Iteration 7: Current value = 0Iteration 8: Current value = 0
Iteration 9: Current value = 0
Process returned 20 (0x14) execution time : 8.780 s
Press any key to continue.
Why is it giving me zero everytime?
MalDrHoop
3-Feb-14 12:37pm
View
Thank you. I've been trying to learn some programming while in this course that requires programming and, advisor mess up, and so I appreciate your help with this. I'm figuring it out though I got the majority of this code with some guidance from my professor or by myself. I'll be prepared when I do take my programming class next semester!
MalDrHoop
30-Jan-14 7:37am
View
Well, the button that said "I've solved this myself" took me straight to the solution box. So apparently everybody on the site just doesn't like to use it the way it is set up, or someone needs to make some changes somewhere, I just did exactly what it told me to do. And this is how he was wanting it done so that you could see each iteration as it approached closer to pi. And it isn't the same as the other way so why would I pair it with that? Oh well. People jump too quickly. I'm not into this for the reputation points. But I dislike people judging me unjustly. I get enough of that from other sources.
MalDrHoop
29-Jan-14 13:27pm
View
Your deduction is correct, 12 iterations was all that was necessary to get the desired outcome.
MalDrHoop
29-Jan-14 13:26pm
View
This works perfectly and someone gave me one star? Wow I guess I should just quit on here.
MalDrHoop
29-Jan-14 12:57pm
View
I promise you I am not like that! I hate the predicament I am in. I just want to learn and I fail, in the most epic sense, at learning just by reading. I need lectures and reinforcements, people explaining it to me. That is how it makes sense. I also am not looking for someone to do the work for me. Seeing code with explanations behind the different parts has been what has explained it to me the best thus far. I just met with an instructor from elsewhere who explained and helped me work through the solution to the question that I just posted and it made sense to me. I want to learn the material and do my work not be spoon-fed through the course. What's the point in going to class then right? I have gotten ambitious this semester and overloaded myself, once again, with my course load and work load. Sorry if that stress came off badly in my tone in any manner.
MalDrHoop
29-Jan-14 12:45pm
View
I have a better solution now. I will submit it in a moment.
MalDrHoop
28-Jan-14 23:22pm
View
Actually, I had used google and tried to figure this out on my own and everything I saw did not approach it the way my instructor instructed us to. I waited till now because I just now knew about the site, and did not know about the assignment very long to be honest. I have tried to work on it. You have to keep in mind I am a beginner in all respects to the world of programming. I can not help that I am. I just am.
MalDrHoop
28-Jan-14 22:51pm
View
Well, I am sorry, but I can not change the star. I am brand new to this site and must not have been clear on the process of the site. I did accept your solution however.
MalDrHoop
28-Jan-14 22:47pm
View
I did the program and finished up some things and ran it and got 2pi + 1 lol. I just subtracted one from my addition and divided by two. thank you. I will remove my one star if possible. I am sorry for the controversy. I did not know it was anything bad. Just thought it was a rating as to how well it answered my question and it honestly didnt at all at the time. And now everybody on here dislikes me :/ and now im receiving one stars and will likely never receive help on here after this it seems since everyone has a bad opinion of me now.
MalDrHoop
28-Jan-14 22:44pm
View
I gave my judgement based off of how well it answered my question. (It was before the edit btw). Why does me not having any programming experience due to no fault of my own give my question a one star? From my deduction I gave the star based on how well it answered my question at the time, and at the time it did not.
MalDrHoop
28-Jan-14 20:39pm
View
When I get a chance to look at the program on my computer and see how it goes. Now that my question has been given one star and I've been trash talked :-\
MalDrHoop
28-Jan-14 20:03pm
View
Its Numerical Analysis and the instructor already knows
MalDrHoop
28-Jan-14 19:58pm
View
I am a chemistry/math major. Programming is a pre req but I wasn't declared until more recent and my Chemistry advisor didn't think to put me in programming last semester. But I have to have this class while it's offered. I'm a junior and this is my only chance.
MalDrHoop
28-Jan-14 19:45pm
View
Thanks for putting up with me. And I wasn't asking you to do my homework. I just have no clue where to start since I was never exposed to programming before being thrown in. I guess I won't ask anymore questions on here so that I'm not such a bother
MalDrHoop
28-Jan-14 19:27pm
View
May I ask what the fabs and prevu means?
MalDrHoop
28-Jan-14 15:15pm
View
My question preceding the program is all that was given to me in the class.
MalDrHoop
28-Jan-14 15:15pm
View
Deleted
My question preceding the program is all that was given to me in the class.
MalDrHoop
28-Jan-14 14:39pm
View
Deleted
Iostream not upstream
MalDrHoop
28-Jan-14 14:39pm
View
Ok it removed it in my comment as well. The iostream and math.h
MalDrHoop
28-Jan-14 14:31pm
View
I've shown all I've done. Except for some reason it removed the <iostream> and <math.h> after the #include (s) respectively when I submitted. I've given all the instructor supplied. They placed me in the course because it is the only time I can take it and it is a requirement.
MalDrHoop
28-Jan-14 14:15pm
View
I know its a Taylor series. I just don't know what to do. I don't know programming
MalDrHoop
28-Jan-14 14:15pm
View
I was told to use float. I have NO programming background. I know the code is incomplete but I have no idea what I am doing therefore your hint does not help me. I was not taught ANY c++ and do not have hardly any time to teach myself.
Show More