c++,floating-point,floating-accuracy,sin

In C++, sin has an overload float sin(float f). And overload resolution is done on argument type, rather than return type. To force the use of double sin(double d) you need to cast the argument: sin(static_cast<double>(x)). (2) vs (3): the FP standard allows implementations to store intermediate results with greater...

No need to loop, just compute the point between the center of the circle and the mouse that is on the circle. var dx = x - 200, dy = y - 200, dist = Math.sqrt(dx*dx + dy*dy), newX = 200 + dx * radius / dist, newY = 200...

you need to do double sinFita = sin(fita * M_PI / 180); to convert degrees to radians. Which is the conversion factor from degrees to radians....

You didn't initialize at least DS at the beginning of your code. Look: .MODEL small .486 .STACK 1000h .DATA _180 dw 180 _25 dw 25 degrad dd ? tempvar dw ? alpha dw ? buf dw 8 dup (?) .CODE start PROC mov ax, @data mov ds, ax mov es,...

matlab,matrix,frequency,noise,sin

Added following line on top of your code: t = 0:186.52/(373046-1):186.52 ; Above vector hold time instants where we want to calculate the value of signal. Length of signal in time is 186.52 and want 373046 samples during time. So separation between two samples is 186.52/(373046-1) seconds....

python,animation,matplotlib,sin

step explicitly plots steps between the input data points. It can never plot a partial "step". You're wanting an animation with "partial steps" in between. Instead of using ax.step, use ax.plot, but make a stepped series by plotting y = y - y % step_size. In other words, something like:...

javascript,random,sin,random-seed

So, I looked at your method, t1wc, and I found that it isn't actually evenly distributed. It is significantly more likely to spit out numbers near 0 or near 1 than it is to spit out numbers near 0.5, for example. This is just a consequence of the way that...

python,audio,concatenation,sin

EDIT I'm also a little confused by your choice of sine function, it doesn't look like the coefficients or duration are tied to real-world values, I would expect to see something like this: p = np.concatenate((p, np.sin((2 * np.pi * f / sampling_rate) * np.arange(total_tone_time * sampling_rate) + phase))) phase...

If you have a Fourier series (i.e. f_i = i f for some f) you can use the Clenshaw recurrence relation which is significantly faster than computing all the sines (but it might be slightly less accurate). In your case you can consider the sequence: f_k = exp( i (...

It looks to me like M_PI isn't exactly pi (we know it can't be), and the result from sin isn't exactly zero. printf with %f represents output numbers rounded as a "normal" decimal while cout uses an adaptive format (roughly %g in printf as I recall) that uses scientific notation...

What you're describing is a signal processing problem called aliasing. Basically, if you don't sample a sine wave often enough, the discretized sine wave can appear to have a lower frequency than the actual continuous wave did: To fix this problem you must sample at least twice as often as...

A couple of things. First, your generating a sine that is only 1Hz so you're never going to be able to hear it. t = 0:1:1600 fs = 1000 freq = 440 senial = sin(2*pi*t*freq/fs) play(senial, 1000) The next issue is with your quantization. You're almost there except you didn't...

javascript,math,trigonometry,sin

You can know the angle of any sin with this formula: Math.asin(sinOfAngleX) * 180/Math.PI With sinOfAngleX = 0.5, Math.asin(sinOfAngleX) would give 0.5235987755982989. This is expressed in radians. To pass it to degrees you can multiply by 180/Math.PI, which results in 30ยบ...

r,datetime,time-series,dayofweek,sin

Format your dates and you're done: x <- as.Date(c("1990-1-1","1990-1-10","2010-06-16")) as.numeric(format(x,"%j")) #[1] 1 10 167 ...

That's actually not the amplitude changing. That is due to the numerical imprecisions of floating point arithmetic. Bear in mind that you are specifying an integer sequence from 0 to 100000 in steps of 1000. If you recall from trigonometry, sin(n*x*pi) = 0 when x and n are integers, and...

You chose n in such a unlucky manner, that by chance you sample only points where both waves are identical. Try n = [0 :0.25: 63]; Here are both plots with an increased sample rate. In red the identical points you sampled: ezplot is a good choice to avoid such...

java,android,math,android-studio,sin

sin, cos, log and a bunch of other stuff is included in the Math class. You would need to use it like Math.sin(angleInRadians);...

The issue has to do with an implied phase change the goes along with changing the frequency. In short, when you calculate the response relative to each point in a timeline, it's important to note that the phase of the oscillation will be different for each frequency at each time...