Q:

Find i and find n

The question is: One bond of face value 100 with semiannual coupons and r =0.025 costs 75.74.  A similar bond with semiannual coupons and r=0.04 costs 112.13.  Both are redeemable at par in n years and have the same yield rate i. (a) find i, (b) find n.
I know that the answers are supposed to be i=0.035 and n=27.5 years. 
I got this but I think I am doing it wrong and I am not sure where to go next with it.  Thank you.  
i= i2 (yield)
j=i/2 rate per half year
Face value= 100
r=0.25
cost of first bond = =75.74
r=0.04
Cost of second bond = 112.13
Semi annual yield to maturity of 1st bond = $\text {(face value-price)}n - C \div \text {(Face value +Bond)}/2$
$= (100-75.74)/2 - 0.025 \div (100+75.74)/2$
$= 12.11/87.87 = 0.14$
Semi annual yield to maturity of 2st bond $= \text{(face value-price)}n - C \div \text{(Face value +Bond)}/2$
$= (100-112.13)/2-0.04) \div (100+112.13)/2$
$= -6.11/106.07 = -0.005$
Yield to maturity = 2* semi annual yield to maturity
1st bond = $2*0.14 = 0.28$
2nd Bond = $2*(-0.005) = -0.01$

A:

Let be $P$ the price of the bond,  $F$ the face value (par value) of the bond, 
$C$ the amount paid at maturity, $r$ the coupon rate, $m$ number of coupon payment periods. 
The price of a bond is
$$P=Fr\,a_{\overline{m}|i}+Cv^{m}$$
where $a_{\overline{m}|i}=\frac{1-v^m}{i}$ and $v=\frac{1}{1+i}$.
In the problem $F=C=100$, $P_1=75.74$, $r_1=2.5\%$, $P_2=112.13$, $r_2=4\%$ and $m=2n$. So we have the system of equation
$$\left\{
\begin{align*}
P_2&=Fr_2\,a_{\overline{2n}|i}+Cv^{2n}\\
P_1&=Fr_1\,a_{\overline{2n}|i}+Cv^{2n}
\end{align*}\right. 
$$
that is
$$
\begin{align}
112.13&=4\,a_{\overline{2n}|i}+100v^{2n}\tag 1\\
75.74&=2.5\,a_{\overline{2n}|i}+100v^{2n}\tag 2
\end{align}
$$
From $(1)-(2)$ we find $a_{\overline{2n}|i}=\frac{112.13-75.74}{4-2.5}=24.26$ and substituting in $(1)$ or $(2)$ we find $v^{2n}=0.1509$
$$
\begin{align}
v^{2n}&=0.1509\tag 3\\
1-v^{2n}&=i\times 24.26 \tag 4
\end{align}
$$
and then $$\boxed{i=\frac{1-0.1509}{24.26}=3.5\%}$$
and from $$
v^{2n}={(1+i)^{-2n}}={1.035^{-2n}}=0.1509
$$
we have
$$\boxed{
n=-\frac{1}{2}\times \frac{\log 0.1509}{\log 1.035}\approx 27.5}
$$

