problem with sin equation

Pages: 123
no the assignment isnt wrong. I dont know how you are getting 0 every time but this is the way we were told to do it
so if t = 5 then 2*pi*50*5 is not equal to 0 and getting the sin of that answer isnt 0 either

i need to find the angle then multiply the angle by sin then mulitply that answer by 0.22
2*pi*50*5 is not equal to 0

That is true.

sin of that answer isnt 0
That's wrong. sin (2*pi*50*5) does equal zero. Here's another link you can click to see that:
http://www.wolframalpha.com/input/?i=+sin+%282*pi*50*5%29

multiply the angle by sin

What are you talking about? sin is not some value that you multiply by. sin is an operation you apply to an angle.

sin (pi) = 0
sin (2 pi) = 0
sin (3 pi) = 0
sin (4 pi) = 0
sin (5 pi) = 0
sin (6 pi) = 0
sin (7 pi) = 0
sin (8 pi) = 0
sin (9 pi) = 0
sin (10 pi) = 0

Do you see the pattern yet? sin (any integer * pi ) = 0
Last edited on
if i say for example sin of 30 its equal to 0.5 not 0


ok then i need to apply sin to the angle. sorry im just wording it wrong. how would i do that then?
You need to make the angle range from zero to about 2pi to get a decent graph. I suggest something like

1
2
3
4
for (float i = 0; i < 2); i = i+0.1)
{
  value = sin ( i* pi);
}
Last edited on
where in the program would i put that for loop?

im putting those examples you gave into a calulator and none of the answers are 0
Perhaps your calculator thinks your angles are in degrees. When the value "pi" is involved, the angles are in radians.
ok so are you saying there is basically no way to do this assignment?
Not as you've explained it. If every value must be 0.22 * (sin(some integer * pi)) then value will always be zero.
i found this example online where there use sin and pi on line 43

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <math.h>


using namespace std;

float sk(float x);

float sk(float x)
{
    float y;
    
        y=sin(x);
    
    return y;
}

int main(int argc, char *argv[])
{

  int point[80][24];
  int j;
  float k,Pi;
  

  Pi=3.14159265358;
  
  for(int a=0;a<=23;a++)
  {
      for(int b=0;b<=80;b++)
      {
            point[b][a]=0;
      }
  }


  for(float i=-480;i<480;i++)
  {
      int z=int((i+480)/12);

      k = 12 + 4 *  -sk((i * Pi)/180);
      j=int(k);
      
      if (j <= 24 & j >0)
            point[z][j]=1;
  }   
  
  
  for(int y=1;y<=23;y++)
  {
      if (y == 12)
      for(int d=0;d<=79;d++)
            if (point[d][12] == 0)
                if (d==8)
                     cout << char(197);
                else
                     cout << char(196);
            else
				cout << "o";
      else
      {
            for(int x=0;x<=79;x++)
                  {
                        if (point[x][y] == 0)
                              if (x==8) // x-axis line
                                   cout << char(179);
                              else
                                   cout << " ";
                        else
                                  cout << "o";
                  }
      }
  }
  
  cin.get();cin.get();
  
 
  return 0;
}

this code makes a sine graph
Last edited on
Yes, but sin(n*pi/180) is quite different from sin(n*100*pi) where n is some integer.
i want to get the multiples of pi/2


I don't think you want that. I think you want a range of value of sin(angle), where angle runs from zero to 2*pi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "iostream"
#include "cmath"
#include <fstream>

using namespace std;

int main()
{
	ofstream outputFile;
	outputFile.open("sin_result.txt"); //output file

	float t;
	const double pi = 3.141592654;
	double value;
	double angle;

	for (t = 0; t < 2; t = t+0.1)
	{
		angle =  pi * t;

		value = sin(angle); //get sin of angle
                cout << "angle: " << "\t" << angle << "\t" << "sin(angle): " << value << endl;
                outputFile << "angle: " << "\t" << angle << "\t" << "sin(angle): " << value << endl;
	}




	outputFile.close();

	return 0;
}


If that's not a smooth enough graph, change the step size of t in the for loop.
Last edited on
With multiples of pi/2 (sin(n*pi/2)) you'll only get something like this:
1
2
3
4
5
6
7
8
9
10
11
        .                               .                               .       
                                                                                
                                                                                
                                                                                
                                                                                
.               .               .               .               .               
                                                                                
                                                                                
                                                                                
                                                                                
                        .                               .                       
In the last example you posted, the code is getting multiples of pi/180 (i.e. integer degrees).
ok. I was reading over these comments and as you were saying that 0.22 * (sin(some integer * pi)) will always equal to zero that is why i have 3 seperate equations

angle = 2 * pi * 50 * t; first one finds the angle

value = sin(angle); second get the sin of that angle

(i know this one is wrong i havnt changed it yet)
sin(angle)*0.22; last one multiplies the answer you get in the second equation by 0.22

so for example lets just say the answer to the first equation is 30
you then find the sin of that which equals 0.5
then multiply 0.5 by 0.22
sin and pi are never in the same equation
You get that pi = 3.14159, yes?

So, sin(3.14159) is the same as sin(pi).

Changing pi into the number 3.14159 doesn't change the answer. I think a big part of your issue with this task is that you don't understand the maths.

1
2
angle = 2 * pi * 50 * t;
value = sin(angle);
angle has pi already in it. The fact that you can't see the word "pi" doesn't change the maths.
Last edited on
but once i calulate the angle pi wont be there anymore ie 2 * pi * 50 * 2 = 628
sin (2 * pi * 50 * 2) is exactly the same thing as sin (628)

(Well, actually 628.318... but we'll call is 628, I get what you mean)

That's how maths works. Here's a simpler example.

3+2 is exactly the same thing as 5.
The number 5 doesn't have a 3 in it, or a 2, but it's still exactly the same thing.

So, sin (any integer * pi) is exactly the same thing as sin (any integer * 3.14159...)
so for example lets just say the answer to the first equation is 30
If this is the case, then t is not an integer. It would have to be 0.3/pi, or around 0.9425.

you then find the sin of that which equals 0.5
sin() accepts angles in radians, not degrees. sin(30) is approximately -0.988. Like Moschops said, if you enter that in a calculator, you will get 0.5 because calculators work by default in degrees. The trigonometric functions of every language I've ever seen work by default in radians.

sin and pi are never in the same equation
So, what you're saying is that you can prove that anything equals anything as long as you split your statements into more expressions? For example,
1
2
3
4
a=1+2
b=a*3;
if (b==5){ //should always be true
}


EDIT: If I appear to be sarcastic, I'm not trying to be. I'm trying to make you realize yourself the problem in your reasoning.
Last edited on
ok so what multiples of pi can i use?
still going from 0 to 40
I know 10 = pi
and 20 = 2pi
i need to get all the values inbetween going up in two so i need 20 values

and heres a website that uses some of the equation i'm trying to use
http://www.dspguide.com/ch13/4.htm
still going from 0 to 40
I know 10 = pi
and 20 = 2pi
i need to get all the values inbetween going up in two so i need 20 values
...
You mean n*pi/10?
If f(n)=n*pi/10 then
f(10)=pi
f(20)=2*pi
Pages: 123