microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
katas/content/complex_arithmetic/complex_powers_real/solution.md
14lines · modecode
| 1 | Rewrite the expression $r^x$ to use Euler's constant, which will allow us to use an approach similar to the solution to the previous exercise. |
| 2 | |
| 3 | First, rewrite $r^x$ into a product of two powers: $$ r^{a+bi} = r^a \cdot r^{bi} $$ |
| 4 | |
| 5 | Given that $r = e^{\ln r} $ ($\ln$ is the natural logarithm), we can rewrite the second part of the product as follows: |
| 6 | $$ r^{bi} = e^{bi\ln r} $$ |
| 7 | |
| 8 | Now, given $e^{i\theta} = \cos \theta + i\sin \theta$, we can rewrite it further as follows: |
| 9 | $$ e^{bi\ln r} = \cos( b \cdot \ln r) + i \sin(b \cdot \ln r) $$ |
| 10 | |
| 11 | When substituting this into the original expression, we get: |
| 12 | $$ \underset{real}{\underbrace{r^a \cos(b \cdot \ln r)}} + \underset{imaginary}{\underbrace{r^a \sin(b \cdot \ln r)}} i $$ |
| 13 | |
| 14 | @[solution]({"id": "complex_arithmetic__complex_powers_real_solution", "codePath": "Solution.qs"}) |
| 15 | |