Compute median of continuous distribution using integrate() in R sorry if this may sound very silly or stupid, but I'm following a stats course in my uni and I have some exercises in which I have to compute the median of a continuous distribution.
I know that, if for example I have a pdf such as:
$$f(x)=\frac{1}{2(1-x)^{1/2}}$$
where $x\in(0,1)$.
I can find its median simply by solving this equation for $m$:
$$\frac{1}{2}=\int_{0}^{m}\frac{1}{2(1-x)^{1/2}}dx$$
My professor wrote in an exercise that we can also try and solve these problems in R using the integrate() function. While I know how to use integrate() to solve definite integrals, I wouldn't know how to tackle this problem. Does someone have any useful pointer?
Thank you all in advance!

CAUTION!
As was pointed out and explained by whuber in the comments, the current code below does not check if it is fed a density that integrates to one (or to some other finite value which we could use to renormalize). It is therefore useful to call ff(1)+0.5 (or whatever the support for a given density is) as a sanity check!
E.g. a previous version of the question had an exponent of 2 rather than 1/2, which has integral
$$
\frac{1}{2(1-x)}+C
$$
For such a function, the median is not defined, in that there cannot be a value with 0.5 of the probability mass to the left and to the right of it.
One could play around with upperbound ever closer to one to illustrate why...:
upperbound <- .99
x <- seq(0, upperbound, .00001)
ff <- function(x) 1/(2*(1-x)^2)
plot(x, ff(x), type="l")

The following code works for the "Beta(0,0.5) density" of the OP (and, with suitable modification of the support, also for other proper densities), i.e., a limiting case of a Beta density with first argument tending to zero.
ff1 <- function(x) 1/(2*(1-x)^(1/2))
ff <- function(m) integrate(ff1, 0, m)$value-0.5
uniroot(ff, c(0, 1))

