
Aram Manaselian shows how Wolfram Language's symbolic calculus tools work with control systems. He covers four model types, demonstrates DSolveValue for linear systems, introduces UnilateralConvolve for computing outputs via impulse responses, and explains discrete-time models using RSolveValue.
Questions this video answers
Aram Manaselian (Calculus Algebra team, Wolfram Research).
February 15, 2024.
Wolfram Language version 14.0.
Chapters
Hello everyone. I am Aram Manaselian from Calculus Algebra team of Wolfram Research. And the title of my today's talk is Calculus and Control Systems. Here is the outline of my talk. At first I will give a brief introduction about control systems and its connections with calculus. Then I will speak about system models and their implementation in Wolfram language. The next part of my talk will be about how we can solve some linear system models using symbolic calculus tools such as Dissolve value. Next I will speak about one of the new features of version 14.0, about unique convolution and its application in control systems. And the last part of my talk will be about discrete time models and various solution methods using symbolic calculus tools. So let's start. Recently, control systems and control theory is becoming more and more popular and attractive not only for engineers, but also for researchers from different areas such as physics, chemistry, biology, mathematics, etc. And here in Wolfram we have a great team which is working on implementation of control systems functionalities in Wolfram language. But today I don't want to speak about only control systems, but I want to speak about connections between control systems and calculus. So let's consider a simple schematic picture of a simple control system. We have a input here which goes to system model and system model generates some output response. We also have a controller which checks the output and makes changes in the input in order to achieve for example more stability or accuracy or optimization or something else of the system model. And here one of the most important elements of this control system is the system model. And for dynamical systems with system models are mostly can be governed by differential equations. And as far as I know, in most of softwares which are working with control systems, this type of differential equations mostly can be solved using numerical methods. But in Wolfram language, since we have quite powerful tools for solving such differential equations symbolically, we think that it will be useful and also important to implement this type of system models our symbolic calculus tools. These system models are already implemented in Wolfram language by Control System team. We have four types of system models here. State space model, transfer function model, Affine state space model, nonlinear state space model. The first two models are for linear systems, so they can be governed by linear differential equations. Last two are for nonlinear systems, so they can be governed only by nonlinear differential equations. And for the case of nonlinear systems, we can solve these differential equations only by numerical methods. So we are beyond the scope of my today's talk. That is why I will concentrate my attention only on first two months state space Model and transfer function model. So in order to understand what is state space model, let's consider a simple dynamical system which can be governed by a simple differential equation presented here. In this equation, X is the dependent variable or in other words, state function U is the input function. And suppose we want to get a response function of this form. Then we can generate the state space model for this system using this simple command state space model, equation, state function, input function, response function and T or independent variable. And if I evaluate these lines, we will get an expression for our state space model. Here this S means that we have a state space model. And as you can see, we don't have any state functions, input functions or independent variables inside the state space model. All of them are defined internally inside the model. Alternatively, we can generate this state space model using another more simple command. Here we can put only the coefficient matrices A, B, C, D of the equation and response function. And this will do the same job. Again we will get the same state space model. So with state space model is another representation of differential equation together with response function. And now if we have a state space model and we want to solve it, we have to go back, extract the equation from the model and we have to introduce input function. In this example it's unit step function. Then we can solve the equation using dissolve or dissolve value and we will get an expression for state function. Then we can use this state function to calculate the actual output response from the system using this simple command. So this will be the output response. Of course this is a very simple state space model, but in general X and U can be vectors and these coefficients A, b, c, D can be matrices. And in that case we can get more complicated state space model with multiple inputs and multiple outputs. The other linear states. The other liner model is transfer function model. In this case we are using Laplace transform to get this model. Again let's consider a dynamical system which can be governed with similar differential equation. We can calculate the Laplace transform of differential equation. And in this case it will be a non differential algebraic equation. We can easily solve this equation to find an expression for X which is the Laplace transformation of state function x. And we can calculate xs divided by U where U of S is the Laplace transform of input function. We will get following expression which can be used as argument for the transfer function model which is defined in Wolfram language. And this function will create the transfer function model for our system. Here is T means that we have a transfer function model. Again we don't see any state functions and input functions in the model, we are defined internally again and if you want to solve this model again, we have to extract back the equation from it and we have to introduce input function and solve it using dissolve or dissolve value or maybe nd solve and in version 14.0 of Wolfram language, we have implemented support for these two linear system models, state space model and transfer function model inside this all value which means that now you can simply enter these models into this all value and you can introduce the input function also inside this old value and and that's it. Dissolve value will get the equations, will solve and will return responses which we need. But before continue I want to answer one question. Why dissolve value and not dissolve? As you know, there are two main functions for solving differential equations in Mathematica. Dissolve and dissolve value. For the case of this song, we always get all possible solutions of differential equations in most general forms as rules. For example, if you want to solve this differential equation using B solve, we will get this type of expression which is a rule Y of X goes to some expression which is the general solution of the differential equation. And if we try to solve the same equation using bisson value, we will get only the solution as an expression, not a rule. But this is not the main difference between dissolve and dissolve value. For the case of dissolve we have some strict rules which cannot be broken. For example, first argument of dissolve must be the equation or list of equations together with initial and boundary conditions which are also equations. The second argument of this solve must be the dependent variable or list of dependent variables in the case of systems and first argument of this solve must be the independent variable or list of independent variables in case of PDEs. In contrast to this, in the case of this all value of course first argument also must be the equation or list of equations. But second argument in this all value can be almost any expression. To demonstrate this difference, let's consider following simple example. Suppose we want to solve a system of two differential equations, but we want to return only solution for one of the dependent functions. For example, we have here two differential equations and we want to get the solution only for yfx. If I try to do that using DSolve, I will get an error message and this all will fail. But I can easily do that using dissolve value. So I put here only via fix. But I have two equations with two dependent variables Y and z, and this all value will return only the solution for via fix. And even more, I can ask this all value to solve A differential equation and return for example square of the solution. I can easily do that by putting just yeah, which is not allowed for the case of dsolve. And as a result I will get the square of solution. And the second argument of dissolve value can be also for example number, which is demonstrated in following example. We can ask this all value to solve a differential equation and return one instead of solution. And of course this makes no sense, but it also will work. And finally the second argument of this solvalue can also be a string. For example, I can ask this all value to solve a differential equation and instead of solution return a text I know the solution of this od and this also will work. And this flexibility of this all value happens because inside this all value we have a special algorithm which determines the dependent variables from the equations by itself. And this flexibility makes it easier for us to implement some new objects or new features inside dissolve value without breaking any dissolve rules. So now I can return to my system models and will demonstrate you how we can solve linear system models using this all value. So here is the design, we can just write this all value and first argument in this case will be input function goes to system model and system model can be state space model or transfer function model. The second argument here will be a string which in this case can take only two values. State response to generate state response of the system and output response to generate output response of the system. And the third argument is time or any other independent variable. And here are a few examples to demonstrate this new feature. As an example one, let's try to calculate output response and state response of the state space model for sinusoidal input. So at first we have to generate the state space model. It's a simple one when we want to get the responses for sinusoidal input. So we have to write this all value sin t goes to the model and we want to get output response. We put output response here. And that's it. Here is the output response of the system. And if you want to get state response, we just have to put state response as second argument here. And as a second example, let's try to calculate the output response from transfer function model again for sinusoidal input. So here is the input function, this is the model and we want to get output response. And that's it, Here is the response. And as an example 3, let's try to calculate the output response of a state space model from non zero initial conditions. In this case we don't have input function, so I put zero Here, but instead we have some non zero initial conditions defined after the model and we want to get again output response. And here it is. And finally, example four demonstrates how we can calculate output responses for multiple input multiple output transfer function model. Here we have a more complicated model and this model needs two input functions. So I defined these two input functions as a list again before the system. Of course I have to evaluate this first. And here are two output responses. And here is the plot. And I want to mention here that we also have three special cases which are most commonly used. These three cases are when the input function is Dirac delta. In that case we will get impulse response and if the input is unit step function, we will get step response and the input is ramp function, we will get ramp response. And since these three cases are most commonly used by our users, we prepare more simplified design for these three cases. So here we can use dissolve value and the first argument will be the system without any input function. And system again can be only transfer function model or state space model. And response will be a string which in this case can have three values. Impulse response to get the response from Dirac delta, step response for unit step and ramp response for ramp T. And here is an example demonstrating this. Let's try to calculate the step response, input response and drum response for a transfer function model presented here. So let me evaluate the transfer function model. And now to get the step response I will write this all value, the model, step response and T which will be the step response. Next line will evaluate impulse response and third line will evaluate ramp response. And also we can plot all the replices together to get the picture. And I want to say that we have updated the ref page of this all value in version 14.0 and you can find more details and much more examples about these new features. About solution of system models using dissolve value in this updated page. But now I want to speak about a new feature of dissolve new feature in version 14.0 which is called unilateral convolution. This new feature has been implemented by our team member Racha khachatran in version 14.0. And the function name which was implemented is unilateral convolve and this function gives the unilateral convolution with respect to U of the expressions f and g. F and G can be some functions. The concept of unilateral convolution arises naturally when examining causal systems. The output of such systems at any time depends only on values of the input and the present Type and in the past. So the unilateral convolution F g t of two functions F and G can be calculated with this integral expression presented here. And here is a simple picture which demonstrates unilateral convolution of exponential function and unit box functions. The first row are the functions. The blue line is the exponential function F tau and the yellow line is the unit box function with g t minus tau. We are plotted for different times. In the second row you can see the product of these two functions. And third line is actual unilateral convolution for these two functions. And you can find more details about this new function and many examples about its usage in a ref page of unitratic convolf in version 14.0. But why I discuss this here because this unit convolution can have very interesting application in control systems. To demonstrate this, let's try to calculate the output response of some transfer function model from sinusoidal input. But to do that first we have to evaluate the model. To do it, I want to start from calculation of impulse response of the model. So I'm trying to calculate the response of the system from Dirac delta input instead of sine. So that will be the impulse response presented here when I simply can calculate the unilateral convolution between sine function and impulse response of the model. And that will be the output response of the model to sinusoidal input. So let's try to calculate this convolution between impulse response and sine function. We have to wait a few seconds until it will finish. Yeah. Here is the response or convolution. And in this animation you can see how how convolution works. In the first plot you can see both functions plotted together. Impulse response blue line and sine function yellow line. Next picture demonstrates the product of two functions. And last picture demonstrates actual convolution between these two functions which is the response of our model to sinusoidal input. And to check that this is correct, we can calculate the response to sinusoidal input also using dissolve value. So I write here dissolve value sin T goes to model output response T. And if I evaluate this, I will get slightly different result. But if I compare both results together, you will see that they are identical. So this technique or this method is somehow similar to Green's function technique. So we are using Dirac delta to solve the equation first and the solution is the green function when we are using green function to find the solution for other inputs. So this is very similar to that method. And finally, I want to speak a little bit about discrete time models. It is not possible to solve discrete time system models with dissolve value because we cannot use discrete variables inside dissolve value. Instead we can use rsol value and recurrence table functions. So if we want to solve a system model using rsol value, here is the design. It's very similar to dissolve value. We should write rsol value input function goes to discrete time system and response which is a string and time. And the resp here again can have only two values state response and output response. And here are examples. Let's try to calculate output response and state response of discrete time state space model for sinusoidal input. At first we have to generate discrete time model. We can do that using sampling period option in state space model. As a result we will get this type of expression and with one here means that we have a discrete time system model. For discrete time system models we don't have differential equations, instead we have difference or recurrence equations. So we have to solve them using rsolve or rsolveal. In this case and with this command we can calculate the state response from the discrete time model and next command will return the output response. And next example is for transfer function model. Again we have a discrete time transfer function model and we we can get its response using this also value command. And here is another example. Let's try to calculate the state response of a single input system to unit step input. So here our input function is a unit step and we want to get state response. And here is the response and here is the plot. And in cases when we have discrete system and we want to solve it for given interval of a time from t, mine and tmux, then we have to use recurrence table. Again design is similar and here is an example. This will calculate the state response for state space function and in this case we will get list of numbers instead of function. And here is the plot and the other example. For output response and again the plot. And again I want to mention that we have updated ref pages for rsolvalue and recurrence table and added much more examples for these cases also. So that's all I want to say. And now let me check if we have any questions. So we have few questions here. Jesus asks, how does dissolve value perform for larger systems, say eight order systems? Yeah, I think it depends. It depends on which type of input you have, which type of equations you have. If it's solvable, I think it will be solved. But in some cases it can take more time. But I have to mention that if you solved the model using TSOL value, your results are symbolic and exact. And we have one more question. What does step response do for multiple inputs? Does it send a step for all inputs? I think so. Okay, we still have few minutes, so I will wait if there are any other questions. Otherwise I will close. Okay, if you don't have more questions, thank you for attending my talk and goodbye.
More from Guy

Cheryl Strauss Einhorn | The Human Edge: Smarter Decisions in the Age of AI | Talks at Google

Rachel Glennerster | Innovation and the Center for Global Development | Talks at Google

Rebecca Winthrop | Rethinking the Purpose of Education in the Age of AI | Talks at Google

Dr. Robert Wachter | A Giant Leap: How AI Is Transforming Healthcare... | Talks at Google






