Maple,数值函数的最大值

时间:2016-03-19 11:23:36

标签: function numeric maple

我正在尝试使用Maple计算具有两个ODE的系统解的最大值。我首先解决了系统本身:

func bypassURLAuthentication() {
        let manager = Alamofire.Manager.sharedInstance
        manager.delegate.sessionDidReceiveChallenge = { session, challenge in
            var disposition: NSURLSessionAuthChallengeDisposition = .PerformDefaultHandling
            var credential: NSURLCredential?
            if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
                disposition = NSURLSessionAuthChallengeDisposition.UseCredential
                credential = NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!)
            } else {
                if challenge.previousFailureCount > 0 {
                    disposition = .CancelAuthenticationChallenge
                } else {
                    credential = manager.session.configuration.URLCredentialStorage?.defaultCredentialForProtectionSpace(challenge.protectionSpace)
                    if credential != nil {
                        disposition = .UseCredential
                    }
                }
            }
            return (disposition, credential)
        }
    }

我在xt和yt上得到了系统的解决方案,但它们是数字解决方案。因此,Maple maximize()的功能不起作用:

> with(DEtools):with(plots):
> a1:=0.00875;a2:=0.075;b1:=7.5;b2:=2.5;d1:=0.0001;d2:=0.0001;g:=4*10^(-8);K1:=5000;K2:=2500;n:=2;m:=2;

> dsol:= dsolve({
diff( x(t), t ) = a1+b1*x(t)^n/(K1^n+x(t)^n)-g*x(t)*y(t)-d1*x(t), 
diff( y(t), t ) = a2+b2*x(t)^m/(K2^m+x(t)^m)-d2*y(t), 
x(0) = 1000, y(0) = 1000}, numeric, output = listprocedure);

> xt:= eval( x(t), dsol );
yt:= eval( y(t), dsol );


> X:=plot(xt(t),t=0..50000,color=blue,legend="x(t)"):
Y:=plot(yt(t),t=0..50000,color=green,legend="y(t)"):
> display([X,Y]);

是否可以使用Maple计算数值函数的最大值?

1 个答案:

答案 0 :(得分:2)

您的两条曲线xtytt=0..50000范围内都有一个局部最大值,因此您可以直接使用Optimization

restart;
with(plots):
a1:=0.00875: a2:=0.075: b1:=7.5: b2:=2.5: d1:=0.0001:
d2:=0.0001: g:=4*10^(-8): K1:=5000: K2:=2500: n:=2: m:=2:
dsol:= dsolve({diff(x(t),t)=a1+b1*x(t)^n/(K1^n+x(t)^n)-g*x(t)*y(t)-d1*x(t),
               diff(y(t),t)=a2+b2*x(t)^m/(K2^m+x(t)^m)-d2*y(t),
               x(0)=1000, y(0)=1000}, numeric, output=listprocedure):
xt:= eval(x(t), dsol):
yt:= eval(y(t), dsol):
X:=plot(xt(t), t=0..50000, color=blue, legend="x(t)"):
Y:=plot(yt(t), t=0..50000, color=green, legend="y(t)"):
xmax:=Optimization:-Maximize(xt, 0..50000):
[xmax[2][1],xmax[1]];

               [9460.78688552799, 11193.0618953179]

ymax:=Optimization:-Maximize(yt, 0..50000):
[ymax[2][1],ymax[1]];

               [21471.8648785947, 19006.6009784691]

display( Y, pointplot([[ymax[2][1],ymax[1]]], symbolsize=20),
         X, pointplot([[xmax[2][1],xmax[1]]], symbolsize=20) );

enter image description here

对于你的简单例子,这很好。

如果您的xtyt有多个本地最大值,您可以尝试使用Maximize选项调用method=branchandbound

然后还有其他一些方法可以用新的因变量来扩充您的DE系统,例如xd(t)=diff(x(t),t)(以及相应的IC)并获得dsolve / numeric本身以注意何时变为零(极端)使用events工具,或在其上使用fsolve