sin(5x)

How do I program sin(5x) using the Math.class?
[60 byte] By [Shurela] at [2007-10-1 6:08:14]
# 1
Math.sin(5 * x);
Adeodatusa at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 2
> > Math.sin(5 * x);> Or just for fun.....Math.sin(x * 5);
jschella at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 3
I am sure you can do better than that
Shurela at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 4

> I am sure you can do better than that

Okay...

sin(5x) = sin(x + x + x + x + x)

ergo, as sin(A + B) = sinAcosB + sinBcosA

sin(5x) = sin4xcosx + sinxcos4x

...//cos(2x) => 1, by the way

sin(5x) = (sin2xcos2x + sin2xcos2x)cosx + sinx(sin(2x)^2 + cos(2x)^2)

sin(5x) = (sinxcosx + sinxcosx + sinxcosx + sinxcosx)cosx + sinx

sin(5x) = 4(sinxcosx)cosx + sinx

sin(5x) = sinx(4cos(x)^2 + 1)

sin(5x) = sinx(4(1 - sin(x)^2) + 1)

sin(5x) = sinx(4 - 4sin(x)^2 + 1)

sin(5x) = -4sinx(sin(x)^2 - 1.25)

sin(5x) = -4sin(x)^3 + 5sin(x)

Yeah... there's no way that's all correct...

So, anyway, my several answers for your question.

~Cheers

Adeodatusa at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 5
> > I am sure you can do better than that> > Okay...> > sin(5x) = sin(x + x + x + x + x)y = xsin(5x) = sin(x + y + x + y + x)
jschella at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 6
Aww, ****, I knew I messed something up...cos(2x) = cos(x)^2 - sin(x)^2>.< doh...
Adeodatusa at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 7

What about properties of addition and multiplication?

sin(5 * x) =

sin(1 * 5 * x)

sin(0 + 5 * x)

sin(5 * 1 * (x + 0))

sin(0 + 1 * 5 * 1 + 0) * (0 + 1 * x * 1 + 0))

sin(cos(0) * 5 * x * cos(0))

sin((cos(0) + cos(0) + cos(0) + cos(0) + cos(0)) * x)

Or inverse sin function, arcsin?

sin(arcsin(sin(arcsin(sin(arcsin(sin(arcsin(sin(5 * arcsin(sin(x)))))))))))

Or... Java?

int y = 0;

for(y = 0; y <= 5; y++);

int z = x * y;

result = sin(z)

But... what was your *real* intention? get an efficient implementation of sin(5 * x) or create a crazy math tournament?

@dm@a at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 8
Feb 24, 2005 12:05 AM (reply 6 of 7) Dec 09, 2005 11:31 AM (reply 7 of 7)You missed.
Adeodatusa at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 9
> > Feb 24, 2005 12:05 AM (reply 6 of 7)> > Dec 09, 2005 11:31 AM (reply 7 of 7)> > > You missed.What did I miss?
@dm@a at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 10
> What did I miss?I'd guess a couple of months.; )
prometheuzza at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 11
As we say in my country, Meglio tardi che mai!(I may translate it in English with "Late is better than never")
@dm@a at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 12
> (I may translate it in English with "Late is better than never")"Better late than never" is the common English way of saying that.
DrClapa at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...
# 13
Thanks! Translating correctly idiomatic expressions like this between different languages is always hard. The correct version is surprisingly closer to Italian one than mine...
@dm@a at 2007-7-9 14:54:48 > top of Java-index,Other Topics,Algorithms...