Algebraic simplification 您所在的位置:网站首页 MATLAB的collect函数 Algebraic simplification

Algebraic simplification

#Algebraic simplification| 来源: 网络整理| 查看: 265

Open Live Script

In most cases, to simplify a symbolic expression using Symbolic Math Toolbox™, you only need to use the simplify function. But for some large and complex expressions, you can obtain a faster and simpler result by using the expand function before applying simplify.

For instance, this workflow gives better results when finding the determinant of a matrix that represents the Kerr metric [1]. Declare the parameters of the Kerr metric.

syms theta real; syms r rs a real positive;

Define the matrix that represents the Kerr metric.

rho = sqrt(r^2 + a^2*cos(theta)^2); delta = r^2 + a^2 - r*rs; g(1,1) = - (1 - r*rs/rho^2); g(1,4) = - (rs*a*r*sin(theta)^2)/rho^2; g(4,1) = - (rs*a*r*sin(theta)^2)/rho^2; g(2,2) = rho^2/delta; g(3,3) = rho^2; g(4,4) = (r^2 + a^2 + rs*a^2*r*sin(theta)^2/rho^2)*sin(theta)^2;

Evaluate the determinant of the Kerr metric.

det_g = det(g)det_g = 

-sin(θ)2 a6 cos(θ)4+a4 r2 cos(θ)4+2 a4 r2 cos(θ)2+rs a4 r cos(θ)2 sin(θ)2-rs a4 r cos(θ)2+2 a2 r4 cos(θ)2+a2 r4-rs a2 r3 cos(θ)2+rs a2 r3 sin(θ)2-rs a2 r3+r6-rs r5a2+r2-rs r

Simplify the determinant using the simplify function.

D = simplify(det_g)D = -sin(θ)2 a2 cos(θ)2+r2 -a2 sin(θ)2+a2+r2

Instead, flatten the expression using the expand function, and then apply the simplify function. The result is simpler with this extra step.

D = simplify(expand(det_g))D = -sin(θ)2 -a2 sin(θ)2+a2+r22


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有