Advanced Mathematics(10/34) Symbolic Mathematics Symbolic variables can also store expressions. For example:the variables b and c store symbolic expressions: >>b=sym('x^2'): >>c=sym('x^4'): All basic mathematical operations can be performed on symbolic variables and expressions: >>c/b >>bA3 >>C*b >>b+sym('4*x^2') ans= ans= ans= ans= X^2 x^6 x^6 5*x^2 细同两大学 TONGJI UNIVERSITY
Symbolic variables can also store expressions. For example: the variables b and c store symbolic expressions: All basic mathematical operations can be performed on symbolic variables and expressions: Advanced Mathematics(10/34) Symbolic Mathematics
Advanced Mathematics(11/34) Symbolic Mathematics > The subs function will substitute a value for a symbolic variable in an expression. For example: >>myexp=x^3+3*x^2-2 myexp ×^3+3*x^2-2 >subs (myexp,3) ans= 52 @日济大学 TONGJIUNIVERSITY
➢ The subs function will substitute a value for a symbolic variable in an expression. For example: Advanced Mathematics(11/34) Symbolic Mathematics
Advanced Mathematics(12/34) Symbolic Mathematics The subs function will substitute a value for a symbolic variable in an expression. For example:If there are multiple variables in the expression, one will be chosen by default for the substitution (in this case,x), or the variable for which the substitution is to be made can be specified: >>syms a bx >varexp=a *x2+b*x; >subs (varexp,3) ans= 9*a十3*b CDHAW >subs(varexp,'a',3) ans= @月停大学 3*X^2十b*8 TONGJI UNIVERSITY
➢ The subs function will substitute a value for a symbolic variable in an expression. For example: If there are multiple variables in the expression, one will be chosen by default for the substitution (in this case, x), or the variable for which the substitution is to be made can be specified: Advanced Mathematics(12/34) Symbolic Mathematics
Advanced Mathematics(13/34) Symbolic Mathematics >However,by making the expression symbolic,the result is symbolic also.Any numeric function (e.g.,double)could change that. For example: >>sym(1/3+1/2) ans= 5/6 >double(ans) ans= 0.8333 @日济大学 TONGJI UNIVERSITY
➢ However, by making the expression symbolic, the result is symbolic also. Any numeric function (e.g., double) could change that. For example: Advanced Mathematics(13/34) Symbolic Mathematics