I have this code:

(* Expenditure share on all other goods *)
(* Cost share of housing capital in housing production function *)
(* Scaling on housing production function *)
(* Radians available for construction *)
(* benchmark \[Theta] is 3 *)

p[x_,y_,t_,u_,f_,ta_,fa_]:=(((\[Alpha]^\[Alpha])((1-\[Alpha])^(1-\[Alpha])) (y-(t+ta)*x-(f+fa))/u)^(1/(1-\[Alpha]));
q[x_,y_,t_,u_,f_,ta_,fa_]:=(((1-\[Alpha]) (y-(t+ta)*x-(f+fa))/(((\[Alpha]^\[Alpha])((1-\[Alpha])^(1-\[Alpha])) (y-(t+ta)*x-(f+fa)))/u)^(1/(1-\[Alpha])));
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(xbar\)]\(\[Theta]\ x\ Density[x, y, t, u, \[Tau], f, ta, fa] \[DifferentialD]x\)\);
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(xbar\)]\(\[Theta]\ x^2\ Density[x, y, t, u, \[Tau], f, ta, fa] \[DifferentialD]x\)\);

enter image description here

The gist of it is that I'm creating a city, where x is the distance from the central business district, p is price of housing, ptax is price of housing after property tax, q is quantity of housing demanded, S is structural density, r is rental price of land, h is floor to area ratio, density is the population density, and L is the total population. The last function is my addition.

I want to find out what the average distance is to the CBD. Xbar is where the city ends. So between the values where x is 0 and xbar there is a population of people whose distribution is defined by Density. I want to know what the average x is for these people in this interval. I thought the function would be what the L function is, but that gives the total population. What am I doing wrong?

  • $\begingroup$ There seems to be multiple problems in the code. 1. What is $\alpha, \beta, g, \theta$? 2. Remove x from the definition of xavg: xavg[xbar_, pop_, y_, t_, u_, \[Tau]_, f_, ta_, fa_] := .... 3. If you care only about the numerical value, try NIntegrate instead of Integrate. $\endgroup$
    – Domen
    Oct 14, 2021 at 11:38
  • $\begingroup$ I updated the code. $\endgroup$ Oct 14, 2021 at 11:48
  • $\begingroup$ The code now works and xavg gets evaluated, but it's still difficult to provide any help (the question now seems more of a "mathematical" one). Are you sure your definitions and expressions are all correct (they are probably copied from a book or an article?). Can you give an example of your calculation (e.g. xavg[5, .1, .1, .1, .1, .1, .1, .1]) that you think is incorrect, and explain what the correct answer should be? Technically speaking, your approach seems correct, i.e. $\langle x \rangle = \int x \ \rho(x) \, \mathrm{d} x$. $\endgroup$
    – Domen
    Oct 14, 2021 at 12:01
  • $\begingroup$ Yeah my question is more whether the xavg function actually gives the number I'm looking for. Whether it's the correct function to use to get the average distance from the centre. $\endgroup$ Oct 14, 2021 at 12:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.