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

How to find $f(x)$ from $f(g(x))$, $g(x)$, ex:




use matlab code....I don't me thanks a lot!

share|cite|improve this question
When is $g(x)$ equal to $\frac12$? – Jonas Meyer Dec 28 '12 at 6:54
Assuming you just want to use it for numeric calculations you do not need the symbolic toolbox, you can just define functions f and g, and then you can call them as f(g(x)) – Dennis Jaheruddin Dec 28 '12 at 9:24

I give you an example, and hope you can translate it to Matlab. I don't know Matlab much but I think you can do it by yourself.

Assume you have $$h(x)=f(g(x))=4x^2+4x+7$$ and $$g(x)=2x+1$$ and want to find $f(x)$. Define $h(x)$ and $g(x)$ in Matlab environment and solve $$g(x)=t$$ respect to $x$(which $t$ is a parameter) You get: $$x=0.5t-0.5$$ Now put what you got into $h(x)$, so you get: $$h(0.5t-0.5)=t^2+6$$ This is your desired function $f(x)$ if you replace $t$ to $x$.

share|cite|improve this answer
Nice suggestion, to try without Matlab! And good direction for doing just that! – amWhy Mar 1 '13 at 1:04

For $g(x) = 1 - x^2$ to be equal to $1/2$, $x = 1/\sqrt{2}$.

So: $$f(1/2) = \frac{1/4 + 1/2}{1 + 1/2} = 0.75/1.5 = 1/2$$

share|cite|improve this answer
I want code matlab,do you understand ???ex EX syms x; input('gx ') input(' f(gx) ') f(1/2)=????? – Nguyễn Hoàng Thiên Phước Dec 28 '12 at 7:58
@nubis It makes no calculation difference, but you should technically have $x=\pm1/\sqrt{2}$ in the first line. – Daryl Dec 28 '12 at 8:47
@user50980 - I want a pony. – nbubis Dec 28 '12 at 16:41

A simple solution is to notice that $$f(g(x)) = \dfrac{x^4+x^2}{x^2+1} = \dfrac{x^2(x^2+1)}{x^2+1}= x^2 = 1 - g(x)$$ so if $g(x)=\frac{1}{2}$ then $f(g(x))=1-\frac{1}{2} = \frac{1}{2}$.

share|cite|improve this answer
Agh, 4 months too late. Ali's answer(???) bumped the thread. I hate it when this happens. – Clive Newstead May 9 '13 at 19:02
syms f g x;
S = solve('g = 1 - x ^ 2', 'g = 1 / 2')
x = S.x(1);
f = (x ^ 4 + x ^ 2) / (1 + x ^ 2);
double (f)
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.