Let the trigonometry begin! Introduction:

The sine of x is given by the formula:

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - x^11/11! // and more follows...


The cosine of x is given by the formula:

cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - x^10/10! // and more follows...


Task:

Given the value of x and n, write a program (no functions, etc.) to output the value of sin(x) and cos(x) correct upto n terms of the formula above. Assume that x is in radians.

Input:

x n


A decimal number x (with upto 3 decimal places) and an integer n. Input must be on stdin or a prompt dialog box (iff your language doesn't support stdin)

Output:

[sin(x)]
[cos(x)]


The value of both sin(x) and cos(x) should be rounded to 6 decimal places. If sin(x) is 0.5588558855 (10 decimal digits), it should be rounded to 0.558856 (6 decimal digits). The rounding must take place to the nearest, as described in the fifth column, "Round to nearest", of the the table in this Wiki article.

Constraints:

1 &lt;= x &lt;= 20
1 &lt;= n &lt;= 20


Samples:

----
5 3

10.208333
14.541667
----
8.555 13

0.765431
-0.641092
----
9.26 10

-3.154677
-8.404354
----
6.54 12

0.253986
0.967147
----
5 1

5.000000
1.000000
----
20 20

-5364.411846
-10898.499385
----


Notes:


Standard loopholes are prohibited.
Built-in math functions and operators of trigonometry (sin, cos, tan, etc.), factorial, and exponentiation cannot be used. You are free to use a built-in rounding function for estimating the result of computing sin(x) and cos(x) to the 6-th decimal digit.
No need to handle wrong inputs.
Only ASCII characters can be used in the program, not the Chinese Unicode ones that allow code compression.
Your program must terminate, and display the output, within 3 seconds of input.
Your answer must accompany the ungolfed code, along with the explanation of the code (compulsory if the code is not immediately obvious to programmers-not-familiar-with-your-language, especially GolfScript, J, etc.).
Please include a link to an online compiler where your program can be tested.


Scoring:

The answer with lowest code length in characters, including white space, tabs, etc.  wins! Winner would be declared on 21 May 2014.

EDIT: 21/05/14
Winner is aditsu using CJam language. Runner up follows jpjacobs with J language, and second runner up is primo with Perl language. Congrats all!
Perl - 72 bytes



$~=&lt;&gt;=~$"+$'*2;$_=1-$_*$`/$~--/$~*$`for($,,$;)x$';printf'%f
%f',$`*$,,$;


Or, counting command line options as 1 byte each, in 70 bytes:

#!perl -n
$-=/ /+$'*2;$_=1-$_*$`/$---/$-*$`for($,,$;)x$';printf'%f
%f',$`*$,,$;


Or, if you'll allow me Perl 5.8, in 63 bytes:

#!perl -p
$.+=$'&lt;&lt;/ /;$_=1-$_*$`/$.--/$.*$`for($_=$#='%f
',$\)x$';$_*=$`


but why would you.

Edit: Compliance with the new rules. %f rounds to 6 places by default, how convenient!



Algorithm  

Examining the Taylor series for sin(x):



it can be seen that each term evenly divides every successive term. Because of this, it can be transformed rather effortlessly into a nested expression:



cos(x) transforms similarly, without the leading x, and denominator terms one smaller.

Additionally, this nested expression can be reformulated as a reverse recursive expression:



with s&#x221E; = 0 and sin(x) = x&middot;s1, which is ultimately what is used.



Ungolfed  

&lt;&gt; =~ m/ /;          # read one line from stdin, match a space
                     # prematch ($`) is now x, postmatch ($') is now n
($x, $n) = ($`, $'); # reassign, for clarity
$i = 2*$n + 1;       # counting variable (denominators)

for (($s, $c)x$n) {  # iterate over $s and $c, n times each
  # compute the next term of the recursive expression
  # note: inside this loop $_ is not the _value_
  # of $s and $c alternately, it _is_ $s and $c

  $_ = 1 - $_ * $x**2 / $i-- / $i;
}

# formated output
printf("%f\n%f", $x*$s, $c);




Sample Usage  

$ echo 5 3 | perl sin-cos.pl
10.208333
14.541667

$ echo 8.555 13 | perl sin-cos.pl
0.765431
-0.641092

$ echo 9.26 10 | perl sin-cos.pl
-3.154677
-8.404354

$ echo 6.54 12 | perl sin-cos.pl
0.253986
0.967147

$ echo 5 1 | perl sin-cos.pl
5.000000
1.000000

$ echo 20 20 | perl sin-cos.pl
-5364.411846
-10898.499385


If you want to test this online, I recommend using compileonline.com. Copy-Paste the code into main.pl, and the input into the STDIN box, then Execute Script.