Substitute function into other functions

6 views (last 30 days)
Gina
Gina on 13 Mar 2014
I have three function depending p1, p2, p3 this is: k1(p1,p2,p3), k2(p1,p2.p3) and tau(p1,p2,p3) each one is a very complicated functions, what I want is to become tau a function of k1 and k2 this is tau(k1,k2).
Example:
Suppose we have three functions:
a=p1+p2+p3
b=p1*p2*p3
c=p1+p2+p3+p1*p2*p3
so c could be a function of a and b
c=a+b
but my funcions are very complicated, that's why I need some command that do that? Do it exist in Matlab?
Here you have my own functions.
syms p1 p2 p3
k1= p1 + p2 + p3 - p1*p2 - p1*p3 - p2*p3 + p1*p2*p3 - 1
k2=-(p1^2*p2^2*p3^2 + 2*p1^2*p2^2*p3 + p1^2*p2^2 + 2*p1^2*p2*p3^2 - 12*p1^2*p2*p3 + 2*p1^2*p2 + p1^2*p3^2 + 2*p1^2*p3 + p1^2 + 2*p1*p2^2*p3^2 - 12*p1*p2^2*p3 + 2*p1*p2^2 - 12*p1*p2*p3^2 + 32*p1*p2*p3 - 4*p1*p2 + 2*p1*p3^2 - 4*p1*p3 - 6*p1 + p2^2*p3^2 + 2*p2^2*p3 + p2^2 + 2*p2*p3^2 - 4*p2*p3 - 6*p2 + p3^2 - 6*p3 + 9)^(1/2)/2
tau= -(p1 + p2 + p3 + (p1^2*p2^2*p3^2 + 2*p1^2*p2^2*p3 + p1^2*p2^2 + 2*p1^2*p2*p3^2 - 12*p1^2*p2*p3 + 2*p1^2*p2 + p1^2*p3^2 + 2*p1^2*p3 + p1^2 + 2*p1*p2^2*p3^2 - 12*p1*p2^2*p3 + 2*p1*p2^2 - 12*p1*p2*p3^2 + 32*p1*p2*p3 - 4*p1*p2 + 2*p1*p3^2 - 4*p1*p3 - 6*p1 + p2^2*p3^2 + 2*p2^2*p3 + p2^2 + 2*p2*p3^2 - 4*p2*p3 - 6*p2 + p3^2 - 6*p3 + 9)^(1/2) + p1*p2 + p1*p3 + p2*p3 - 3*p1*p2*p3 - 3)/(2*(p1 + p2 + p3 - p1*p2 - p1*p3 - p2*p3 + p1*p2*p3 - 1))
What I did was looking at tau and by hand converting tau in terms of k1 and k2 but for more complex functions it is very complicated.
Thanks
Gina
  1 Comment
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 13 Mar 2014
This is for your example, where a and b are functions of p1 p2 p3 and c is a fnction of a and b
a=@(p1,p2,p3) p1+p2+p3
b=@(p1,p2,p3) p1*p2*p3
c=@(a,b) a(p1,p2,p3)+b(p1,p2,p3)

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!