Solving a system of equations using R I'm trying to use R for my Macro practise and model solve for the equilibrium price where the inverse demand curve PD(q) and supply curve P.
How do i do this?
Thanks!
Note 1.: It is rude to edit a question after it was answered; I had to make significant edits to make my answer consistent.

Note 2.: this is not a system of equations. There are two functions defined, but only one equation:
$$P_D(q) - P_S(q) = 0$$

What helps here is that inverse demand is decreasing in quantity while inverse supply is increasing. So given any $q$, if $P_D(q) &gt; P_S(q)$ we know that $q$ is under the equilibrium value of $q^*$, and if $P_D(q) &lt; P_S(q)$ then $q &gt; q^*$.
You can also narrow down the range $q^*$ can be found in. Clearly $q^* \geq 0$.
Also $P_D(q)$ should not dip into negative territory, so you can find a very large $\bar{q}$ for which $P_D(q) \leq 0$. One can do this easily by starting from $\bar{q} = 1$, evaluating $P_D(\bar{q})$, and doubling $\bar{q} = 1$ iff $P_D(\bar{q}) &gt; 0$.
Given the interval $I = [0, \bar{q}]$ which we know contains $q^*$, you can now apply interval halving.
An algorithm for approximating $q^*$ with a desired level of precision $\epsilon$:

Define the interval $I = [0, \bar{q}]$.
Start of LOOP 
Select the midpoint of the interval as a &quot;guess&quot; for $q^*$. (In the first iteration this is $q = \bar{q}/2$.)
Evaluate the statement $P_D(q) &gt; P_S(q)$. 
If true, then

$q^*$ should be smaller, the solution is in the lower half of the interval, so in the next iteration we will use that as our new interval $I$. 
If false, then

$q^*$ should be larger, the solution is in the upper half of the interval, so in the next iteration we will use that as our new interval $I$.
Evaluate the statement new interval is very small, i.e. has length less than $2\epsilon$. 
If true, then 
select its midpoint and say that you have approximated $q^*$ with reasonable precision, end program. 
If false, then 
Go to start of LOOP.