如何用简单的术语强制 MATLAB 输出?
How to force the MATLAB output in the simple terms?
从课本上得到了答案yp_tb = exp(x)*(tan(x)-x)/2;
我从 Matlab 得到了答案:
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
我制作了以下脚本来检查它们是否相同。
clear all;
syms x
yp_tb = exp(x)*(tan(x)-x)/2;
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
% yp_tb = textbook output; yp_mt = matlab output
Equal = isAlways(yp_tb == yp_mt) % Equal is 1, it means they are equal
如何强制MATLAB输出为教科书输出?
添加答案,因为它适用于 OP。
使用以下代码将等式简化为所需的步骤:
syms x
yp_tb = exp(x)*(tan(x)-x)/2;
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
simplify(yp_mt, 3)
另请参阅 simplify
的文档
从课本上得到了答案yp_tb = exp(x)*(tan(x)-x)/2;
我从 Matlab 得到了答案:
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
我制作了以下脚本来检查它们是否相同。
clear all;
syms x
yp_tb = exp(x)*(tan(x)-x)/2;
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
% yp_tb = textbook output; yp_mt = matlab output
Equal = isAlways(yp_tb == yp_mt) % Equal is 1, it means they are equal
如何强制MATLAB输出为教科书输出?
添加答案,因为它适用于 OP。
使用以下代码将等式简化为所需的步骤:
syms x
yp_tb = exp(x)*(tan(x)-x)/2;
yp_mt = (x*exp(x)*tan(x)^2)/2 - (exp(x)*(2*x - sin(2*x)))/(4*cos(x)^2);
simplify(yp_mt, 3)
另请参阅 simplify
的文档