Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following matlab function:

function y=par(x,s)
%parabolic density function with basis = 2s
ind=-s<x & x< s;
y(-s<x & x< s)=(3/(4*(s^3)))*(s*s-x(ind).*x(ind));

This function implements

$$y_s(x) = \begin{cases} \frac{3}{4s^3}(s^2-x^2) & \text{if } -s<x<s, \\ 0 & \text{otherwise.} \end{cases}$$

The area under the parabola is always one. I tested it with the following matlab procedure:

s = 0.5:0.1:100.5;
for i=1:length(s)
    q =  quad(@(x)par(x,s(i)),-s(i),s(i));

q is always 1 here.

btw. quad is a matlab function to evaluate the integral. Here it calculates $q = \int_{-s}^s y_s(x)\,dx$.

Can somebody explain to me why it is always one ?

share|cite|improve this question
I'd appreciate if this were written in standard math format, withoug the matlab. I think your question is likely really mathematical, and has nothing to do with unravelling computer code. – coffeemath Oct 15 '12 at 12:11
that's true. I need some time to convert it into math format. – superbly Oct 15 '12 at 13:15
How much calculus do you know? – Rahul Nov 9 '12 at 12:52
up vote 3 down vote accepted

The integral of the function is $1$, which is the area under the parabola:

$\displaystyle\int_{-s}^s\frac{3}{4s^3}(s^2-x^2)dx= \frac{3}{4s^3}\left(\int_{-s}^{s}s^2dx-\int_{-s}^{s}x^2dx \right) =\frac{3}{4s^3}\left(2ss^2-2\int_{0}^{s}x^2dx \right)= \\ =\displaystyle\frac{3}{4s^3}\left(2s^3-2\frac{s^3}{3}\right)=1$

share|cite|improve this answer

It may help to rewrite your integrand as

$$ y_s(x) = \frac{3}{4s^3}(s^2 - x^2) = \frac 1s \frac 34 \left( 1 - \left( \frac xs \right)^2 \right). $$

Now, let's first consider the case $s = 1$, which simplifies the integrand to

$$ y_1(x) = \frac 34 (1 - x^2), $$

which is to be integrated from $-1$ to $1$. From high school calculus, I'm sure you'll remember that

$$ \int_0^1 x^2 \,dx = \frac 13 $$

which implies that

$$ \int_0^1 (1 - x^2) \,dx = 1 - \frac 13 = \frac 23 $$

and thus, since $(-x)^2 = x^2$,

$$ \int_{-1}^1 (1 - x^2) \,dx = 2 \cdot \frac 23 = \frac 43. $$

Multiply that by $\frac 34$, and you get $1$.

Now, what about $s \ne 1$? The rewritten integrand has a factor of $\frac 1s$ in front of it, so the height of the parabola is divided by a factor of $s$. On the other hand, the argument $x$ is also divided by $x$, which effectively multiplies the width of the parabola (and, not coincidentally, the range over which it is integrated) by $s$. Those two effects cancel out, leaving the area unchanged.

In fact, we can generalize this result: for any function $f$ integrable on $[a,b]$ and any non-zero constant $s$,

$$\begin{aligned} \int_a^b f(x) dx &= \frac 1s \int_{sa}^{sb} f\left(\frac xs\right) \,dx \\ &= \int_{sa}^{sb} \frac 1s f\left(\frac xs\right) \,dx . \end{aligned}$$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.