Skip to main content
Wow, haven't been on this site in a while; Saw this and had to fix the latex translation error
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real \$x\$ greater than or equal to \$1 (\$1 ≤ x$). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate \$x^\frac1x\$, this takes advantage of the fact that:

$$x^\frac1x = e^\frac{\ln x}x$$

So, to calculate \$\ln(x)\$, this also takes advantage of the fact that:

$$\int \frac1x dx = \ln(x) + c$$

whose definite integral from \$1\$ to \$b = x\$ is numerically-approximated in increments of \$10^{-5}\$ using the following summation formula:

$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{-5}(b-1)} \frac 1 {10^5 + i}$$$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{5}(b-1)} \frac 1 {10^5 + i}$$

The resulting sum is then multiplied by \$\frac1x\$ to get \$\frac{\ln(x)}x\$. \$e^{\frac{\ln(x)}x}\$ is then finally calculated using the \$e^x\$ Maclaurin Series to 100 terms as follows:

$$e^x=\sum^{10^2}_{n=0}\frac{x^n}{n!}$$

This results in our relatively accurate output of \$x^\frac1x\$.

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real \$x\$ greater than or equal to \$1 (\$1 ≤ x$). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate \$x^\frac1x\$, this takes advantage of the fact that:

$$x^\frac1x = e^\frac{\ln x}x$$

So, to calculate \$\ln(x)\$, this also takes advantage of the fact that:

$$\int \frac1x dx = \ln(x) + c$$

whose definite integral from \$1\$ to \$b = x\$ is numerically-approximated in increments of \$10^{-5}\$ using the following summation formula:

$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{-5}(b-1)} \frac 1 {10^5 + i}$$

The resulting sum is then multiplied by \$\frac1x\$ to get \$\frac{\ln(x)}x\$. \$e^{\frac{\ln(x)}x}\$ is then finally calculated using the \$e^x\$ Maclaurin Series to 100 terms as follows:

$$e^x=\sum^{10^2}_{n=0}\frac{x^n}{n!}$$

This results in our relatively accurate output of \$x^\frac1x\$.

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real \$x\$ greater than or equal to \$1 (\$1 ≤ x$). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate \$x^\frac1x\$, this takes advantage of the fact that:

$$x^\frac1x = e^\frac{\ln x}x$$

So, to calculate \$\ln(x)\$, this also takes advantage of the fact that:

$$\int \frac1x dx = \ln(x) + c$$

whose definite integral from \$1\$ to \$b = x\$ is numerically-approximated in increments of \$10^{-5}\$ using the following summation formula:

$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{5}(b-1)} \frac 1 {10^5 + i}$$

The resulting sum is then multiplied by \$\frac1x\$ to get \$\frac{\ln(x)}x\$. \$e^{\frac{\ln(x)}x}\$ is then finally calculated using the \$e^x\$ Maclaurin Series to 100 terms as follows:

$$e^x=\sum^{10^2}_{n=0}\frac{x^n}{n!}$$

This results in our relatively accurate output of \$x^\frac1x\$.

added 157 characters in body
Source Link

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real x\$x\$ greater than or equal to 1 (1 ≤ x\$1 (\$1 ≤ x$). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dcdc does not support raising numbers to non-integer exponents to calculate x^(1/x)\$x^\frac1x\$, this takes advantage of the fact that:

Advantage$$x^\frac1x = e^\frac{\ln x}x$$

So, to calculate ln(x)\$\ln(x)\$, this also takes advantage of the fact that:

Advantage2$$\int \frac1x dx = \ln(x) + c$$

whose definite integral from 1 to (b = x)\$1\$ to \$b = x\$ is numerically-approximated in increments of 10^-5\$10^{-5}\$ using the following summation formula:

Summation Formula.$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{-5}(b-1)} \frac 1 {10^5 + i}$$

The resulting sum is then multiplied by 1/x\$\frac1x\$ to get ln(x)/x\$\frac{\ln(x)}x\$. e^(ln(x)/x)\$e^{\frac{\ln(x)}x}\$ is then finally calculated using the e^x\$e^x\$ Maclaurin Series to 100 terms as follows:

e^x Maclaurin Series.$$e^x=\sum^{10^2}_{n=0}\frac{x^n}{n!}$$

This results in our relatively accurate output of x^(1/x)\$x^\frac1x\$.

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real x greater than or equal to 1 (1 ≤ x). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate x^(1/x), this takes advantage of the fact that:

Advantage

So, to calculate ln(x), this also takes advantage of the fact that:

Advantage2

whose definite integral from 1 to (b = x) is numerically-approximated in increments of 10^-5 using the following summation formula:

Summation Formula.

The resulting sum is then multiplied by 1/x to get ln(x)/x. e^(ln(x)/x) is then finally calculated using the e^x Maclaurin Series to 100 terms as follows:

e^x Maclaurin Series.

This results in our relatively accurate output of x^(1/x).

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real \$x\$ greater than or equal to \$1 (\$1 ≤ x$). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate \$x^\frac1x\$, this takes advantage of the fact that:

$$x^\frac1x = e^\frac{\ln x}x$$

So, to calculate \$\ln(x)\$, this also takes advantage of the fact that:

$$\int \frac1x dx = \ln(x) + c$$

whose definite integral from \$1\$ to \$b = x\$ is numerically-approximated in increments of \$10^{-5}\$ using the following summation formula:

$$\int_1^b \frac1x dx = \sum_{i=1}^{10^{-5}(b-1)} \frac 1 {10^5 + i}$$

The resulting sum is then multiplied by \$\frac1x\$ to get \$\frac{\ln(x)}x\$. \$e^{\frac{\ln(x)}x}\$ is then finally calculated using the \$e^x\$ Maclaurin Series to 100 terms as follows:

$$e^x=\sum^{10^2}_{n=0}\frac{x^n}{n!}$$

This results in our relatively accurate output of \$x^\frac1x\$.

Commonmark migration
Source Link

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real x greater than or equal to 1 (1 ≤ x). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

###Explanation

Explanation

As dc does not support raising numbers to non-integer exponents to calculate x^(1/x), this takes advantage of the fact that:

Advantage

So, to calculate ln(x), this also takes advantage of the fact that:

Advantage2

whose definite integral from 1 to (b = x) is numerically-approximated in increments of 10^-5 using the following summation formula:

Summation Formula.

The resulting sum is then multiplied by 1/x to get ln(x)/x. e^(ln(x)/x) is then finally calculated using the e^x Maclaurin Series to 100 terms as follows:

e^x Maclaurin Series.

This results in our relatively accurate output of x^(1/x).

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real x greater than or equal to 1 (1 ≤ x). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

###Explanation

As dc does not support raising numbers to non-integer exponents to calculate x^(1/x), this takes advantage of the fact that:

Advantage

So, to calculate ln(x), this also takes advantage of the fact that:

Advantage2

whose definite integral from 1 to (b = x) is numerically-approximated in increments of 10^-5 using the following summation formula:

Summation Formula.

The resulting sum is then multiplied by 1/x to get ln(x)/x. e^(ln(x)/x) is then finally calculated using the e^x Maclaurin Series to 100 terms as follows:

e^x Maclaurin Series.

This results in our relatively accurate output of x^(1/x).

dc, 125 bytes

15k?ddsk1-A 5^*sw1sn0[A 5^ln+_1^+ln1+dsnlw!<y]syr1<y1lk/*sz[si1[li*li1-dsi0<p]spli0<p]so0dsw[lzlw^lwlox/+lw1+dswA 2^!<b]dsbxp

Unlike the other dc answer, this works for all real x greater than or equal to 1 (1 ≤ x). Accurate to 4-5 places after the decimal.

I would have included a TIO link here, but for some reason this throws a segmentation fault with the version there (dc 1.3) whereas it does not with my local version (dc 1.3.95).

Explanation

As dc does not support raising numbers to non-integer exponents to calculate x^(1/x), this takes advantage of the fact that:

Advantage

So, to calculate ln(x), this also takes advantage of the fact that:

Advantage2

whose definite integral from 1 to (b = x) is numerically-approximated in increments of 10^-5 using the following summation formula:

Summation Formula.

The resulting sum is then multiplied by 1/x to get ln(x)/x. e^(ln(x)/x) is then finally calculated using the e^x Maclaurin Series to 100 terms as follows:

e^x Maclaurin Series.

This results in our relatively accurate output of x^(1/x).

deleted 8 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
added 10 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
edited body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
Fixed Explanation
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
Added Explanation
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading