Skip to main content
deleted 29 characters in body
Source Link
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Maxima, 4493 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.

93 bytes, it can be golfed much more.


Golfed version. Try it online!Try it online!

b(n):=if=block([o],o:fpprec,fpprec:n,r:if n<2 then bfloat(n )else bfloat(cos(b(n-1))),fpprec:o,r)

The above Maxima code is equivalent to the following Mathematica code:Ungolfed version. Try it online!

b[n_Integer] := Nest[Cos, 1, n - 1];
NumberForm[N[b[1000], 200], {51, 50}] //Print
/* Define the recursive function with dynamic precision */
b(n) := block(
    [old_prec],
    /* Save the old precision */
    old_prec: fpprec,
    /* Set the precision relative to n */
    fpprec: n,
    /* Perform the calculation with the new precision */
    result: if n < 2 then bfloat(n) else bfloat(cos(b(n-1))),
    /* Restore the old precision */
    fpprec: old_prec,
    /* Return the result */
    result
);

/* Print the results from 1 to 1000 */
for i:1 thru 1000 do (
    print(b(i))
);

Maxima, 44 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.


Golfed version. Try it online!

b(n):=if n<2 then n else bfloat(cos(b(n-1)))

The above Maxima code is equivalent to the following Mathematica code:

b[n_Integer] := Nest[Cos, 1, n - 1];
NumberForm[N[b[1000], 200], {51, 50}] //Print

Maxima, 93 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.

93 bytes, it can be golfed much more.


Golfed version. Try it online!

b(n):=block([o],o:fpprec,fpprec:n,r:if n<2 then bfloat(n)else bfloat(cos(b(n-1))),fpprec:o,r)

Ungolfed version. Try it online!

/* Define the recursive function with dynamic precision */
b(n) := block(
    [old_prec],
    /* Save the old precision */
    old_prec: fpprec,
    /* Set the precision relative to n */
    fpprec: n,
    /* Perform the calculation with the new precision */
    result: if n < 2 then bfloat(n) else bfloat(cos(b(n-1))),
    /* Restore the old precision */
    fpprec: old_prec,
    /* Return the result */
    result
);

/* Print the results from 1 to 1000 */
for i:1 thru 1000 do (
    print(b(i))
);
added 182 characters in body
Source Link
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Maxima, 44 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.


Golfed version. Try it online!

b(n):=if n<2 then n else bfloat(cos(b(n-1)))

The above Maxima code is equivalent to the following Mathematica code:

b[n_Integer] := Nest[Cos, 1, n - 1];
NumberForm[N[b[1000], 200], {51, 50}] //Print

Maxima, 44 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.


Golfed version. Try it online!

b(n):=if n<2 then n else bfloat(cos(b(n-1)))

Maxima, 44 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.


Golfed version. Try it online!

b(n):=if n<2 then n else bfloat(cos(b(n-1)))

The above Maxima code is equivalent to the following Mathematica code:

b[n_Integer] := Nest[Cos, 1, n - 1];
NumberForm[N[b[1000], 200], {51, 50}] //Print
Source Link
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Maxima, 44 bytes

A port of @MarcMush's Julia 1.0 answer in Maxima.


Golfed version. Try it online!

b(n):=if n<2 then n else bfloat(cos(b(n-1)))