Engineering Problem Solving With Matlab and Maple: Ms-Espm
This document discusses using MATLAB's Symbolic Math Toolbox to perform algebraic and trigonometric calculations such as factoring polynomials, simplifying expressions, and solving equations. It provides examples of using syms to declare symbolic variables and commands like expand, factor, simplify, solve, and fzero to perform symbolic math operations and solve equations both algebraically and numerically. User-defined functions can also be created using inline.
Engineering Problem Solving With Matlab and Maple: Ms-Espm
This document discusses using MATLAB's Symbolic Math Toolbox to perform algebraic and trigonometric calculations such as factoring polynomials, simplifying expressions, and solving equations. It provides examples of using syms to declare symbolic variables and commands like expand, factor, simplify, solve, and fzero to perform symbolic math operations and solve equations both algebraically and numerically. User-defined functions can also be created using inline.
AND MAPLE MS-ESPM 2014 MODULE 2 Using MATLABs Symbolic Math Toolbox, you can carry out algebraic and trigonometric or symbolic calculations such as factoring polynomials , simplification or solving algebraic equations. 2 MATLAB 1. Algebra and Trigonometry To perform symbolic computations, you must use syms to declare the variables you plan to use to be symbolic variables. Example >> syms x y >> (x+y)*(x-2*y) >> expand(ans) >> factor(ans) >> sin(pi) >> sin(sym(pi)) >> sym('1/3')+sym('5/8') >> factor(ans) >> simplify ((x^3-y^3)/(x-y)) >> simplify(((sin(x))^2+(cos(x))^2)) 3 MATLAB 2. Solving Equations MATLAB has a more robust command, called simple, that sometimes does a better job than simplify. You can solve equations involving variables with solve . >> solve('x^2-3*x+2') >> solve('x^3-3*x^2*y+2*y','y') >> solve('x^2-3*x-5') To get numerical solutions, type double(ans), or vpa(ans) to display more digits. >> solve('x*cos(y)-2*sin(y)','x') >> solve('exp(x)*y-x','y') 4 MATLAB Simultaneous Equations >> sol=solve('x+2*y-3','3*x-5*y+6') >> [x,y]=solve('x+2*y-3','3*x-5*y+6') >> sol.x >> sol.y You can numerically find the solutions shown on the graph with fzero, which looks for a zero of a given function near a specified value of x. fzero >> fzero('exp(-2*x)-sin(x)',0.5) 5 MATLAB 3. User Defined Function You can use inline to define your own functions. >> f=inline('x^3+2*x^2-5*x+6','x') >> f(2)