# Help me matlab,find $f(x)$ from $f(g(x))$…thanks a lot!

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

$g(x)=1-x^2$

$f(g(x))=(x^4+x^2)/(1+x^2)$

$f(1/2)=$

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

-
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$.

-
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$$

-
I want code matlab,do you understand ???ex EX syms x; input('gx ') input(' f(gx) ') f(1/2)=????? –  user50980 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}$.

-
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
clc;