MMA-利用Methematica推导一阶线性微分方程

Methematica是一款符号运算的利器,可以完成各种复杂的符号运算。在这里我们尝试利用这一软件进行一阶微分方程的推导。首先回顾一下一阶微分方程的解法。

一阶线性微分方程

在这里插入图片描述

齐次方程通解

首先将非齐次方程存储到一个名为“非齐次方程”的符号中,然后求解相应齐次方程的通解并存储在“齐次方程通解”中。

DSolve[D[y[x], x] + p[x] y[x] == q[x], y[x], x]
(*即可获得非齐次方程的通解: *)
非齐次方程 = HoldForm[D[y[x], x] + p[x] y[x] == q[x]]
(*将非齐次方程存储到一个名为“非齐次方程”的符号中*)
齐次方程通解 = DSolve[D[y[x], x] + u[x] y[x] == 0, y[x], x]
(*求解相应齐次方程的通解并存储在“齐次方程通解”*)

在这里插入图片描述
非齐次方程的通:
在这里插入图片描述

非齐次方程通解

利用常数变易法。
常数变易法是解线性微分方程行之有效的一种方法。它是拉格朗日十一年的研究成果,我们所用仅是他的结论,并无过程。
常数变易法是个特殊的变量代换法。
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述



常数变易方程 = 齐次方程通解 /. C[1] -> C[1][x]
(*将通解中的常数项c1替换为C[x]并存储在“常数变易方程”中*)

非齐次方程 = HoldForm[D[y[x], x] + p[x] y[x] == q[x]]
(*将非齐次方程存储到一个名为“非齐次方程”的符号中*)

常数方程 = ReleaseHold[非齐次方程 /. 常数变易方程]
(*将变易后的方程代到非齐次方程中,可以得到含有常数函数的方程*)
常数解 = DSolve[常数方程, C[1], x]
(**)
特解 = 齐次方程通解 /. C[1] -> C[1][x] /. 常数解
(*使用常数函数替换齐次方程通解中的常数,可得特解*)
非齐次通解 = y[x] -> Simplify[((y[x] /. 特解) + (y[x] /. 齐次方程通解))]
(*非齐次方程的通解为特解+齐次通解:*)
ReleaseHold[非齐次方程 /. 非齐次通解]
(*验证一下,将非齐次通解带入原来的非齐次方程检验是否正确*)

常数变易方程:
在这里插入图片描述

在这里插入图片描述

接下来,将通解中的常数项c1替换为C[x]并存储在“常数变易方程”中:
将变易后的方程代到非齐次方程中,可以得到含有常数函数的方程:
使用常数函数替换齐次方程通解中的常数,可得特解:

1、将通解中的常数项c1替换为C[x]并存储在“常数变易方程”中*
在这里插入图片描述
2、将变易后的方程代到非齐次方程中,可以得到含有常数函数的方程:
在这里插入图片描述
在这里插入图片描述

附录

齐次方程通解 = DSolve[D[y[x], x] + u[x] y[x] == 0, y[x], x]
常数变易方程 = 齐次方程通解 /. C[1] -> C[1][x]
常数方程 = ReleaseHold[非齐次方程 /. 常数变易方程]
常数解 = DSolve[常数方程, C[1], x]
特解 = 齐次方程通解 /. C[1] -> C[1][x] /. 常数解
非齐次通解 = y[x] -> Simplify[((y[x] /. 特解) + (y[x] /. 齐次方程通解))]
ReleaseHold[非齐次方程 /. 非齐次通解]

在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Description of the algorithms used in the implementations of MMA and GCMMA in Matlab. Files for both MMA and GCMMA: ============================ subsolv.m kktcheck.m toy1.m toy2.m subsolv.m ========= The function subsolv.m makes an attempt to solve either the MMA subproblem generated by mmasub.m, or the GCMMA subproblem generated by gcmmasub.m. A straight-forward primal-dual interior-point method is used. kktcheck.m ========== The function kktcheck.m calculates the left hand sides of the KKT conditions for the optimization problem defined by the user. toy1.m and toy2.m ================= Define, together with mmatoyinit.m or gctoyinit.m, the users problem. ---------------------------------------------------------------- Files for MMA only: ================== mmasub.m mmatoymain.m mmatoyinit.m mmatoyresults mmasub.m ======== The function mmasub.m generates the MMA subproblem for the current iteration, and calls the function subsolv.m mmatoymain.m ============ The file mmatoymain.m makes an attempt to solve the users optimization problem which is defined by the files mmatoyinit.m and toy2.m. In each MMA iteration, mmatoymain.m calls toy2.m and mmasub.m. ---------------------------------------------------------------- Files for GCMMA only: ==================== gcmmasub.m asymp.m concheck.m raaupdate.m gctoymain.m gctoyinit.m gctoyresults gcmmasub.m ========== The function gcmmasub.m generates the GCMMA subproblem for the current outer/inner iteration, and calls the function subsolv.m. asymp.m =========== The function asymp.m calculates values on the parameters raa0, raa, low and upp in the beginning of each outer GCMMA iteration. concheck.m =========== The function concheck.m checks if the current GCMMA approximations are sufficiently conservative. raaupdate.m =========== The function raaupdate.m updates the parameters raa0 and raa in each inner iteration. gctoymain.m =========== The file gctoymain.m makes an attempt to solve the users optimization pr

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值