\(% Differentiation % https://tex.stackexchange.com/a/60546/ \newcommand{\Diff}{\mathop{}\!\mathrm{d}} \newcommand{\DiffFrac}[2]{\frac{\Diff #1}{\Diff #2}} \newcommand{\DiffOp}[1]{\frac{\Diff}{\Diff #1}} \newcommand{\Ndiff}[1]{\mathop{}\!\mathrm{d}^{#1}} \newcommand{\NdiffFrac}[3]{\frac{\Ndiff{#1} #2}{\Diff {#3}^{#1}}} \newcommand{\NdiffOp}[2]{\frac{\Ndiff{#1}}{\Diff {#2}^{#1}}} % Evaluation \newcommand{\LEvalAt}[2]{\left.#1\right\vert_{#2}} \newcommand{\SqEvalAt}[2]{\left[#1\right]_{#2}} % Epsilon & Phi \renewcommand{\epsilon}{\varepsilon} \renewcommand{\phi}{\varphi} % Sets \newcommand{\NN}{\mathbb{N}} \newcommand{\ZZ}{\mathbb{Z}} \newcommand{\QQ}{\mathbb{Q}} \newcommand{\RR}{\mathbb{R}} \newcommand{\CC}{\mathbb{C}} \newcommand{\PP}{\mathbb{P}} \renewcommand{\emptyset}{\varnothing} % Probabililty \DeclareMathOperator{\Cov}{Cov} \DeclareMathOperator{\Corr}{Corr} \DeclareMathOperator{\Var}{Var} \DeclareMathOperator{\Expt}{E} \DeclareMathOperator{\Prob}{P} % Distribution \DeclareMathOperator{\Binomial}{B} \DeclareMathOperator{\Poisson}{Po} \DeclareMathOperator{\Normal}{N} \DeclareMathOperator{\Exponential}{Exp} \DeclareMathOperator{\Geometric}{Geo} \DeclareMathOperator{\Uniform}{U} % Complex Numbers \DeclareMathOperator{\im}{Im} \DeclareMathOperator{\re}{Re} % Missing Trigonometric & Hyperbolic functions \DeclareMathOperator{\arccot}{arccot} \DeclareMathOperator{\arcsec}{arcsec} \DeclareMathOperator{\arccsc}{arccsc} \DeclareMathOperator{\sech}{sech} \DeclareMathOperator{\csch}{csch} \DeclareMathOperator{\arsinh}{arsinh} \DeclareMathOperator{\arcosh}{arcosh} \DeclareMathOperator{\artanh}{artanh} \DeclareMathOperator{\arcoth}{arcoth} \DeclareMathOperator{\arsech}{arsech} \DeclareMathOperator{\arcsch}{arcsch} % UK Notation \DeclareMathOperator{\cosec}{cosec} \DeclareMathOperator{\arccosec}{arccosec} \DeclareMathOperator{\cosech}{cosech} \DeclareMathOperator{\arcosech}{arcosech} % Paired Delimiters \DeclarePairedDelimiter{\ceil}{\lceil}{\rceil} \DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor} \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} \DeclarePairedDelimiter{\ang}{\langle}{\rangle} % Vectors \newcommand{\vect}[1]{\mathbf{#1}} \newcommand{\bvect}[1]{\overrightarrow{#1}} % https://tex.stackexchange.com/a/28213 % \DeclareMathSymbol{\ii}{\mathalpha}{letters}{"10} % \DeclareMathSymbol{\jj}{\mathalpha}{letters}{"11} % \newcommand{\ihat}{\vect{\hat{\ii}}} % \newcommand{\jhat}{\vect{\hat{\jj}}} \newcommand{\ihat}{\textbf{\^{ı}}} \newcommand{\jhat}{\textbf{\^{ȷ}}} \newcommand{\khat}{\vect{\hat{k}}} % Other Functions \DeclareMathOperator{\sgn}{sgn} \DeclareMathOperator{\tr}{tr} % Other Math Symbols \DeclareMathOperator{\modulo}{mod} \newcommand{\divides}{\mid} \newcommand{\notdivides}{\nmid} \newcommand{\LHS}{\text{LHS}} \newcommand{\RHS}{\text{RHS}} \newcommand{\degree}{^{\circ}}\)
Since we have \(x = r \cos \theta \) and \(y = r \sin \theta \), and \(r = f(\theta )\), we have \begin {align*} \DiffFrac {x}{\theta } & = \DiffFrac {r}{\theta } \cdot \cos \theta + r \cdot \DiffFrac {\cos \theta }{\theta } \\ & = f'(\theta ) \cos \theta - f(\theta ) \sin \theta , \end {align*}
and \begin {align*} \DiffFrac {y}{\theta } & = \DiffFrac {r}{\theta } \cdot \sin \theta + r \cdot \DiffFrac {\sin \theta }{\theta } \\ & = f'(\theta ) \sin \theta + f(\theta ) \cos \theta , \end {align*}
Therefore, \begin {align*} \DiffFrac {y}{x} & = \frac {\DiffFrac {y}{\theta }}{\DiffFrac {x}{\theta }} \\ & = \frac {f'(\theta ) \sin \theta + f(\theta ) \cos \theta }{f'(\theta ) \cos \theta - f(\theta ) \sin \theta } \\ & = \frac {f'(\theta ) \tan \theta + f(\theta )}{f'(\theta ) - f(\theta ) \tan \theta }. \end {align*}
For the two curves, we must have \[ \LEvalAt {\DiffFrac {y}{x}}{f} \cdot \LEvalAt {\DiffFrac {y}{x}}{g} = -1 \] for them to meet at right angles. Therefore, \begin {align*} \frac {f'(\theta ) \tan \theta + f(\theta )}{f'(\theta ) - f(\theta ) \tan \theta } \cdot \frac {g'(\theta ) \tan \theta + g(\theta )}{g'(\theta ) - g(\theta ) \tan \theta } & = -1 \\ \left (f'(\theta ) \tan \theta + f(\theta )\right ) \cdot \left (g'(\theta ) \tan \theta + g(\theta )\right ) & = -\left (f'(\theta ) - f(\theta ) \tan \theta \right ) \cdot \left (g'(\theta ) - g(\theta ) \tan \theta \right ) \\ f'(\theta ) g'(\theta ) (1 + \tan ^2\theta ) + f(\theta ) g(\theta ) (1 + \tan ^2\theta ) & = 0 \\ f'(\theta ) g'(\theta ) + f(\theta ) g(\theta ) & = 0. \end {align*}
We have \(f\left (-\frac {\pi }{2}\right ) = 4\). Let \[ g_a(\theta ) = a(1 + \sin \theta ). \]
Therefore, \[ g_a'(\theta ) = a \cos \theta , \] and we have \[ f'(\theta ) (a \cos \theta ) + f(\theta ) a (1 + \sin \theta ) = 0, \] and therefore \[ \DiffFrac {f(\theta )}{\theta } \cos \theta = - f(\theta ) (1 + \sin \theta ). \]
By separating variables we have \[ \frac {\Diff f(\theta )}{f(\theta )} = - \frac {\Diff \theta (1 + \sin \theta )}{\cos \theta }. \]
Notice that \[ -\frac {1 + \sin \theta }{\cos \theta } = - \frac {(1 - \sin \theta ) (1 + \sin \theta )}{(1 - \sin \theta ) \cos \theta } = - \frac {\cos \theta }{1 - \sin \theta } = \frac {\cos \theta }{\sin \theta - 1}, \] integrating both sides gives us \[ \ln f(\theta ) = \ln \abs *{\sin \theta - 1} + C = \ln \left (1 - \sin \theta \right ) + C, \] which gives \[ f(\theta ) = A (1 - \sin \theta ). \]
Since \(f\left (-\frac {\pi }{2}\right ) = 4\), we have \(2A = 4\) and \(A = 2\), therefore \(f(\theta ) = 2 (1 - \sin \theta )\).