Maple

您所在的位置:网站首页 maple怎么计算表达式的值 Maple

Maple

2023-11-12 04:01| 来源: 网络整理| 查看: 265

matlab的符号计算内核采用Maple。

使用maple进行公式推导的好处(出自https://blog.csdn.net/qq_45330313/article/details/104511285)

① 公式显示形式能够实现与纸面书写完全一致; ② 不怕推导过程中出现的错误,因为只需重新计算一遍即可; ③ 推导出来的成果,易于课题组传承; ④ 推导结果能够自动转成Matlab代码,用于编程计算,Maple+Matlab实为绝配;

TP5450 datasheet中对buck有如下推导公式,用maple进行简单的推导。

如下:

 

可将俩步替换,综合为一步,如下

 

备注: 

(1)maple选择哪个函数进行变量替换?

subs函数,algsubs函数和simplify函数。

表示先替换Toff 然后在替换Ton。

而上花括号表示同时替换。

注意二者的差别。当有需替换表达式有内部交叉的变量时候,容易出错。

algsubs函数把一个表达式带入另外一个表达式,subs函数仅仅只能替换一个变量而已。如下

要替换a+b 则使用algsubs

(2)isolate --- isolate a subexpression to left side of an equation

Calling Sequence isolate(eqn, expr) isolate(eqn, expr, iter)Parameters eqn   -  equation or algebraic expression expr  -  any algebraic expression iter   -   (optional) positive integer(可选,正整数)Description         " The procedure isolate attempts to isolate the second argument expr in the first argument eqn and solves eqn for expr.          " If the first argument is not an equation, then the equation      eqn = 0is assumed.        " The optional third argument iter controls the maximum number of transformation steps that isolate performs.  The default is 100000.        " For direct solutions of equations, solve may be more efficient than isolate, which is intended, primarily, for use in an interactive Maple session.         Furthermore, whereas isolate returns an equation equivalent to its input, solve returns solutions to its input equations, and can handle systems of equations with multiple solutions.

第三个可选的参数iter 表示转换的步数,如下图中,

公式(3)表示转换第0次的结果,公式(4)表示转换第1次的结果

案例 A.subs 单变量替换

p := (x+y)^2 + 1/(x+y)^2;

我们希望p的分子上包含(x+y)^4的项,我们可以令 z = (x + y),然后代入p的表达式。如下操作

op([2,1], q);    (*op是取出表达式q中的operand,前面[2,1]是个列表,表示以q的第二个操作数为新的子表达式,取出该子表达式中的第一个操作数,具体分解见下面执行结果*)

如下:

op([2,1], eq); 取出eq第二个操作数中的第一个操作数。

subsop([2,1] = x-y,eq); 将eq中嵌套的操作数 [2,1] = 2 用(x-y)替换 

B. expand 命令

p := (a+b+c)*(x^3 + 9*x + 8); 如何使第二个操作数不变,展开公式。也可用algsubs 此处用另外一种办法

C.商,余数

alias 相当于宏定义,Quo是求商,Rem是求余数

Compute the quotient(商) q and remainder(余数) r of a divided by b such that a = bq + r

 

 

 

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3