Rewrite a symbolic function in terms of a defined function

3 views (last 30 days)
How can I rewrite a symbolic expression or function in terms of another defined function? Specifically, I want to rewrite df in terms of f:
syms z
f=1/(1+exp(-z))
df=diff(f)
The result should be
f(1-f)
  1 Comment
Amin Yahyaabadi
Amin Yahyaabadi on 3 Nov 2018
I know function subexpr, which automatically selects the common subexpression (I can not define my subexpression), and it uses exp(z).
subexpr(df)
sigma =
exp(-z)
ans =
sigma/(sigma + 1)^2
, and rewrite, which uses predefined functions like sin or exp
, and has, which only says if that subexpr exist in the function!
has(df,f)
ans=
1
also the following does not work:
syms a
subs(df,1/(1+exp(-z)),a)
ans =
a^2*exp(-z)

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 3 Nov 2018
Edited: madhan ravi on 3 Nov 2018
syms z
f=1/(1+exp(-z))
df=diff(f)
isolate(df==1,f)
  4 Comments
Amin Yahyaabadi
Amin Yahyaabadi on 3 Nov 2018
It does not what I want. There is no equation in my case! Maybe, I can write an equation to do this for me indirectly, but it does not give f(1-f) directly.
madhan ravi
madhan ravi on 3 Nov 2018
As far as I know ,I don't think there is a command to do that

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!