将参数方程x=x(t),y=y(t)中的x看作自变量,对y,t求解方程组即可
但上面做法的前提是y与x的函数关系存在显式:y=y(x).否则,无解
1. 例如单位圆的参数方程: x=cos(t), y=sin(t).
其对应的隐函数方程为x^2+y^2=1
输入:
clear
syms x y t
f1=x-cos(t);
f2=y-sin(t);
s=solve(f1,f2,y,t);
y=s.y
输出:
y=(1-x^2)^(1/2) (实际上,y=±(1-x^2)^(1/2))
2. 例如笛卡儿叶形线的参数方程: x=3*a*t/(1+t^3), y=3*a*t^2/(1+t^3).
其对应的隐函数方程为x^3+y^3-3*a*x*y=0
输入:
clear
syms x y t a
f1=x-3*a*t/(1+t^3);
f2=y-3*a*t^2/(1+t^3);
s=solve(f1,f2,y,t);
y=s.y;
y=y(1); %第1个解为实根,第2个和第3个解为共轭复根
输出:
y=(1/2/x*((-4*x+4*(-(4*a^3-x^3)/x)^(1/2))*x^2)^(1/3)+2*a/((-4*x+4*(-(4*a^3-x^3)/x)^(1/2))*x^2)^(1/3))*x
3. 例如摆线的参数方程: x=a*(t-sin(t)),y=a*(1-cos(t)).
不存在显函数:y=y(x)
输入:
syms x y t a
f1=x-a*(t-sin(t));
f2=y-a*(1-cos(t));
s=solve(f1,f2,y,t);
x=s.x
无解
从摆线的参数方程不难看出,虽然不存在显式y=y(x),但存在显式x=x(y)
输入:
syms x y t a
f1=x-a*(t-sin(t));
f2=y-a*(1-cos(t));
s=solve(f1,f2,x,t);
x=s.x
输出:
x =a*acos((-y+a)/a)-a*(y*(-y+2*a)/a^2)^(1/2)
问题简化后如下:y = t^3 , x=t^2 ;如何得到x y 的关系 :
代码如下 :
clc,syms t
y = t^3 ;x=t^2 ;
y=subs(compose(y,finverse(x)),'t','x')
y =
x^(3/2)
解释如下:
subs : 替换变量
例如
subs('x^2+1','x','y')
ans =
y^2 + 1
compose : 实现函数的复合
>> y=x^2
x=t
>> compose(y,x)
ans =
t^2
>>
compose 函数
compose Functional composition.
compose(f,g) returns f(g(y)) where f = f(x) and g = g(y).
Here x is the symbolic variable of f as defined by SYMVAR and
y is the symbolic variable of g as defined by SYMVAR.
If f and g are symbolic functions the x and y are the respective
inputs.
Examples:
syms x y z t u;
f(x) = 1/(1 + x^2); g(y) = sin(y); h = x^t; p = exp(-y/u);
compose(f,g) returns 1/(sin(y)^2 + 1)
compose(f,g,t) returns 1/(sin(t)^2 + 1)
compose(h,g,x,z) returns sin(z)^t
compose(h,g,t,z) returns x^sin(z)
compose(h,p,x,y,z) returns (1/exp(z/u))^t
compose(h,p,t,u,z) returns x^(1/exp(y/z))
finverse
求反函数
Functional inverse
Syntax
g = finverse(f)
g = finverse(f,var)
Description
g = finverse(f) returnsthe functional inverse of f. Here f isan expression or function of one symbolic variable, for example, x.Then g is an expression or function, such that f(g(x))= x. That is, finverse(f) returns f–1,provided f–1 exists.
g = finverse(f,var) usesthe symbolic variable var as the independentvariable. Then g is an expression or function,such that f(g(var)) = var. Use this form when f containsmore than one symbolic variable.
Input Arguments
f
Symbolic expression or function.
var
Symbolic variable.
Output Arguments
g
Symbolic expression or function.
Examples
Compute functional inverse for this trigonometric function:
syms x
f(x) = 1/tan(x);
g = finverse(f)g(x) =
atan(1/x)