shuitumu 发表于 2006-7-20 20:22

请教三角函数所有解的问题

现在有这样一个三角函数:
T21=-sin(s/delta)*cos(s*delta)+sin(s*delta)*cos(s/delta)/delta^2
T21是s的函数.当把其中的参数delta设为1.5时,用solve得到如下解:
ans =

18.8496         
      0         
   7.3959         
-7.3959         
11.4537         
-11.4537         
   3.3698         
-3.3698         
15.4798         
-15.4798         
   4.8744 - 0.7749i
-4.8744 + 0.7749i
13.9752 + 0.7749i
-13.9752 - 0.7749i
   9.4248 - 0.8593i
-9.4248 + 0.8593i
   9.4248 + 0.8593i
-9.4248 - 0.8593i
   4.8744 + 0.7749i
-4.8744 - 0.7749i
13.9752 - 0.7749i
-13.9752 + 0.7749i
我们知道,T21的所有根远远不止这些.根据T21的曲线图,该函数"大致"具有拍频现象,
但在具体的每一个小周期内,函数并不光滑,也不规则,这也即是我强调的"大致"的原因.
在这种情况下,如何才能得到更多的解?

同时,如果将参数delta设为1.501时,用同样的方法,solve只能得到这样一个结果:
ans =

   0
这个差异似乎太大了.T21并没有什么特殊性,为什么很小的参数改变量却能导致很大的结
果差异?请教这是solve的问题还是函数本身的问题?

谢谢!
BOW//

siyanger 发表于 2006-7-21 08:52

我也想搞懂这个问题,能不能给s设个范围,解出某个范围内有值。不然因为三角函数的周期性,那解不是有无穷多个了?
我用最简单的一个sin(t)=0.5试了一下,也只有一个解。
用sin(t)=1.5试了一下,也出来一个复数解,按道理,它是没有解的吧?这里的复数是什么意思呢?

shuitumu 发表于 2006-7-21 11:15

原帖由 siyanger 于 2006-7-21 08:52 发表
我也想搞懂这个问题,能不能给s设个范围,解出某个范围内有值。不然因为三角函数的周期性,那解不是有无穷多个了?
我用最简单的一个sin(t)=0.5试了一下,也只有一个解。
用sin(t)=1.5试了一下,也出来一个复数 ...

如果是复数的话,就可以表示成双曲函数,这个是允许的.

但关键是如何求出所有的解.也许是solve的功能太有限,不知道除了solve,还有什么命令可以求出所有的实根和复根.

siyanger 发表于 2006-7-21 15:03

你是怎么求的啊?用符号求解的吗?

bainhome 发表于 2006-7-21 15:57

理论上fsolve可以求解所有的实数解,复数解貌似没有什么官方命令可以实现。
function SolveTriFun
x0=0;
delta=1.5;
str=['-sin(s/',num2str(delta),').*cos(s*',num2str(delta),')+sin(s*',num2str(delta),').*cos(s/',num2str(delta),')/',num2str(delta),'^2'];
T21=inline(str,'s');
for i=1:5:300
    Results(i)=fsolve(T21,x0);
    x0=i;
end
Results1=unique(Results);
save Results.mat
plot(Results1)

shuitumu 发表于 2006-7-21 17:33

原帖由 bainhome 于 2006-7-21 15:57 发表
理论上fsolve可以求解所有的实数解,复数解貌似没有什么官方命令可以实现。
function SolveTriFun
x0=0;
delta=1.5;
str=;
T21=inline(str,'s');
for i=1:5:300
    Results(i)=fsolve(T21,x0);
    x0=i ...

非常感谢您提供的代码,运行后除了能看到以下的输出和一张图外,看不到解.敢问要看到解的话,是不是还有其他的操作?谢谢.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimizer appears to be converging to a minimum that is not a root:
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.
Optimization terminated: first-order optimality is less than options.TolFun.

shuitumu 发表于 2006-7-21 17:34

原帖由 siyanger 于 2006-7-21 15:03 发表
你是怎么求的啊?用符号求解的吗?

我用的是如下的代码:
function =ST21(delta)

% mu=0.5;
% delta=sqrt(1+0.5*mu+sqrt((1+0.5*mu)^2-1));
delta=1.501;
syms s;
T21=-sin(s/delta)*cos(s*delta)+sin(s*delta)*cos(s/delta)/delta^2;

=solve(T21);
s0=eval(s0);

siyanger 发表于 2006-7-21 19:14

我在书上看到这样一个例子:
qcc=inline('cos(t).*cosh(t)-1','t');
options=optimset('display','off');
% plot(t,qcc(t))
%axis()
xo=;
for n=1:5
    q(n)=fzero(qcc,xo,options);
    xo=;
end

disp()

他是这样做的,画出这个函数的图形,看一下解的大概位置,然后求出大周期内的解。
我觉得 这样也有道理。我准备试一下,我的三角函数比你的简单:cos(t)+sin(t)+cos(2*t)+sin(2*t)-0.2
但因为是迭代过程中要用到的,所以更不好处理。
你可以试一下这个方法。

bainhome 发表于 2006-7-21 19:42

command windows中运行:
load Results.mat
在workspace中看,其中有个别几个不是解

siyanger 发表于 2006-7-21 21:07

原帖由 bainhome 于 2006-7-21 15:57 发表
理论上fsolve可以求解所有的实数解,复数解貌似没有什么官方命令可以实现。
function SolveTriFun
x0=0;
delta=1.5;
str=;
T21=inline(str,'s');
for i=1:5:300
    Results(i)=fsolve(T21,x0);
    x0=i ...

对于sin(t)+cos(t)+sin(2t)+cos(2t)这样的方程,这里的300可以设为2*pi,当做一个周期也可以吧? 谢谢你!

shuitumu 发表于 2006-7-21 22:09

原帖由 bainhome 于 2006-7-21 19:42 发表
command windows中运行:
load Results.mat
在workspace中看,其中有个别几个不是解



其中您说的个别不是解的问题,请教是怎么会产生的?
另外,我把得到的结果和1楼的结果对照了一下,除了多出解外,还少了解,难道说solve也会得到多余的解?还是两种命令都存在缺陷?

由于我想得到一定量的实根和复根,请教solve是否有初值一说?

谢谢指点!

[ 本帖最后由 shuitumu 于 2006-7-21 23:09 编辑 ]

bainhome 发表于 2006-7-22 01:28

solve的是maple的符号计算引擎,使用solve基本是对maple的外部调用,maple本身应该就没有初值参数的设定。基本原理不详。
Sum of squares of the function values is > sqrt(options.TolFun).
Try again with a new starting point.
这句话说得应该比较明白了,函数值收敛条件没有达到,原因是初值选择不好,至于少解,随便调一下循环次数即可,fsolve应可以得到所有实数解。复根不行。
另外在MAPLE中的solve也无法求解所有根

shuitumu 发表于 2006-7-22 12:57

原帖由 bainhome 于 2006-7-22 01:28 发表
solve的是maple的符号计算引擎,使用solve基本是对maple的外部调用,maple本身应该就没有初值参数的设定。基本原理不详。
Sum of squares of the function values is > sqrt(options.TolFun).
Try again wit ...

知道了.谢谢!
页: [1]
查看完整版本: 请教三角函数所有解的问题