Since the output of taylor has special properties, we need to convert it into a polynomial. Let's calculate the seriesĮxpansion of the sine function around x=0, up to the fifth power in x. If desired, they can be evaluated by setting SIMPSUM to TRUE. In cases where a closed form integral is unavailable, Maxima can compute the result numerically. Or definite integration, if we enumerate the lower and upper limit. We can also perform indefinite integration on a function (assuming a simple closed form for the answer exists and is computable by Maxima). Higher order differentiation is also readily available. We can differentiate any function with respect to a given variable
To calculate the limit from above, we simply add PLUS (or MINUS from below) to our entry. Let's create an interesting function, and calculate its limit as x approaches 0 First, we isolate the result we wish to substitute.
We can save ourselves quite a bit of typing by using substitutions. Substituting the Results of One Calculation Into Another In many cases, Maxima can simplify rational expressionsįullratsimp((x^2+2*x+1)/(x+1)+1/(4*x+3)) Much the same can be accomplished for trigonometric expressions. These are created as before, but using the plot3d command, and with separate lists for the ranges of the x and y axes. Multivariate functions are defined as before, but separating variables with commas in the definition. We repeat the process for the second root. sw/share/maxima/5.9.0rc3/share/numeric/newton.mac To get their exact values, we load the newton routine, and use it with a guess to the right of the root we wish to get. Let's first examine this seventh-order polynomial by plotting it. Let's use this feature to check the previous result.Įven when an analytic solution cannot be found, Maxima can in many cases solve the equation numerically. To plot multiple functions, we use a list of their names as the first argument in the plot2d function. Maxima can also solve systems of equations, if the equations and variables of interest are presented to it as lists. Thisparticularlist specifies the x-range of interest. The second argument used by the plot2d function is a list, and is indicated by square brackets ( ). Let's look at a plot of our function and see that the roots tally. In order to use any of the results from a solve step, we need to "extract" them from the output list. The variable assignment will now be used everywhere in place of the variable name.Īn equation can be readily solved for any of its variables, if a simple expression exists.Īnother example, yielding both roots of a quadratic. The : sign assigns a value to a variable. Once defined, you can use a function in an intuitive way. To define a function: give it a name, followed by its independent variable in parentheses, followed by the symbols :=, followed by its definition. To tell Maxima to calculate a floating point result, use the float function. The % symbol tells Maxima to use the result of the previous calculation.Īlternatively, you can refer to a result you wish to use by the name of its output line. Remember, use a semicolon and the enter key to terminate input. Note: in the third column some expressions have been typeset for greater ease of reading. Remember, you do not need to use or memorize all of this table at once - simply go up to the point that your current needs dictate, and return to this table when they become more extensive. You could also request that the function be updated to handle symbolic variables for the order of integration input.The following table develops progressively more sophisticateduses of Maxima as a symbolic math tool. I'd recommend that you file a service request with The MathWorks to report this issue. In my opinion, sym/diff should throw an error if it has this limitation rather than returning garbage. MuPAD's related functions have similar limitations as well unfortunately.
The order, n (or i in your code) is also limited to a scalar. In other words, the function doesn't support symbolic variables to specify the order of integration. Why does diff(f,x,i) evaluate to zero even though i is symbolic? From the documentation for sym/diff:ĭiff(S,n), for a positive integer n, differentiates S n times.ĭiff(S,'v',n) and diff(S,n,'v') are also acceptable. % Convert yi back to symfun so output is symfun % Calculate next derivative from previous Yi = % To index into array, yi cannot be symfun N = 0:2 % Increasing orders of differentiation Just use a for loop ( sym/diff is not vectorized in the third argument – see below): syms x y Īlternatively, you could try this form (in this case, for just three indexes, the above will probably be more efficient): syms x y
When using symsum, you need to be aware that, like with any Matlab function, the input arguments will be evaluated before being passed in. This occurs because diff(f,x,i) evaluates to zero.