| | |
Calling Functions
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
for the XsineX function I have to calculate xsinx for each value in x then store in result. I need to call on the sin function to do calculations. I tried but I know its completely wrong, any help please??
#include <iostream>
#include <cmath>
using namespace std;
// uses Taylor series about x= 0 to find sine also finds limit//
double sine( double x, double tolerance, int & limit ) {
double term = x;
double lastTerm = 0.0;
int i = 1;
do {
term = -(lastTerm * x * x) / ((2 * i) * (2 * i + 1));
lastTerm = term;
i += 1;
}while(fabs(term - lastTerm) > tolerance);
limit = i;
return term;
}
int fillVector( double first, double last, double increment, int size, double data[ ] ) {
int i;
double min, max;
data[0]= min;
for( i = 1; i<size &&data[i-1]<max; i++){
data[i]= data[i-1]+increment;
return i;
}
int xSineX( double x[ ], double result[ ], int size, double tolerance, int limit )
{
int count;
count= (max-min)/increment +1;
for (i=1; i<count; i++){
x [0]= min + increment*i;
results[0]= x * sin (x); Last edited by jhanthem; 26 Days Ago at 7:32 pm.
0
#2 26 Days Ago
cant you just do this :
C++ Syntax (Toggle Plain Text)
void xSinX(int * A, int SZ, int lim){ for(int i = 0; i < lim && i < SZ; i++){ A[i] = i*sin( float(i) ); //xsin(x) } }
I give up!
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ]
2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
3) What is the 123456789 prime numer? 0
#3 26 Days Ago
results[0]= x * sin (x); x is an array - it cannot be used as the operand of a multiplication nor as the argument to sin( ).Did you mean to say
results[i]= x[i] * sin (x[i]); ? "We Americans got so tired of being thought of as dumb by the rest of the world that we went to the polls last November and removed all doubt."
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
![]() |
Other Threads in the C++ Forum
- Previous Thread: I need some help.
- Next Thread: what does single quote means ??
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






