0
$\begingroup$

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!

  • 2
    When is $g(x)$ equal to $\frac12$?2012-12-28
  • 0
    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))2012-12-28

4 Answers 4

3

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

  • 0
    Nice suggestion, to try without Matlab! And good direction for doing just that!2013-03-01
2

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

  • 0
    I want code matlab,do you understand ???ex EX syms x; input('gx ') input(' f(gx) ') f(1/2)=?????2012-12-28
  • 0
    @nubis It makes no calculation difference, but you should technically have $x=\pm1/\sqrt{2}$ in the first line.2012-12-28
  • 0
    @user50980 - I want a pony.2012-12-28
1

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

  • 1
    Agh, 4 months too late. Ali's answer(???) bumped the thread. I hate it when this happens.2013-05-09
0
clc;
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)