 So, the first thing is that if you really look at the competing packages available, if you went to compiled programming languages like C or Fortran, they are much faster. On the other hand, if you went to dedicated plotting programs, no plot is public domain but there are much better ones, they are better again. So, why do we want to use Sylab at all? So, to me there are two reasons. One is that Sylab takes us very quickly from concept to a practical output, that is it's a fast implementation of algorithms and ideas that we come up with. And the second thing that I find even more useful is that very often I have to develop complicated codes and most of my time, maybe 90% of my time is spent doing the irrelevant stuff, the stuff that takes in data from the user, the stuff that plots the plots, rather than the stuff which I'm interested in which is the algorithm. So, what Sylab does is it simplifies the stuff I don't like and makes it possible for me to concentrate on what I do want to concentrate. So, what the rest of this talk is going to do is it's going to talk about these two aspects. So, you have two dielectric regions, epsilon 1 and epsilon naught and the wall has a sinusoidally varying potential and I want to solve for the field inside. So, I take them through the derivation and you can show that the solution looks like the equation at the bottom. But unfortunately when you do that, students follow the maths step by step but have no idea what the answer is like. So, when you give it to them this way on the board, they very patiently listen to you but they are not able to use that knowledge. So, what you immediately need to do is to visualize what this answer looks like. Now what I do in this lecture note is that I embed Sylab into latex. I use what is called literate programming which means that you write a document, a single document where you put your derivation, your theory and the code is part of the document and depending on whether you ask for a DVI file or you ask for the Sylab code, the same document gives you both. I have condensed that document but this is what it looks like. So, for instance the same document has the picture, it derives the equation and then has the Sylab code as well. Unfortunately the code does not look quite nice, it have expanded parts of it later on. The students can run the code and they will see the answers as well. When you do it this way, the code is self-documenting. The program can be run and the students see the answer and the answer is very interesting. Despite the fact that you have a sinusoidal potential on the surface, the field inside is uniform. After they see the answer, it becomes obvious. Yes, of course, if you look at the equation, the equation says that the solution depends on r sin theta which is a Cartesian coordinate. So naturally the field is uniform inside the inner region. That is the power of visualization because once they see the answer, they can go back to the equation and understand where this answer came from. So, to me the usefulness of something like Sylab and not just Sylab but Sylab with suitable in platform for creating documentation is that it makes a very powerful teaching tool. So it gives us quick implementation of scientific expressions but if you add literate programming then you can mix code, graphs, equations and the visualized output. That gives extremely powerful impact on students. One point which I do not think really I need to restate but students when they use MATLAB and Sylab have great difficulty understanding why Sylab is different from C. C is a sequential programming language and Sylab is a matrix language and we have to keep dinning into students minds that they have to use array operations wherever they can and by using Sylab as sample code everywhere, this lesson keeps getting reinforced. As only after about 5, 10 examples that they begin to understand that yes you need to use commands like find which greatly speed up Sylab code. The speed up can be factor of 100 if you use the proper kinds of code. So I am saying the same thing again. The power of being able to put the equation and put the code is that with the equation in front of you the code becomes very obvious. If this code was by itself and the equation was in a piece of paper the chances of making errors are much greater. Now in general the code development problem, the second part of my talk is that we have a theory, we work out the mathematical algorithms then we would like to make a simple version in MATLAB or Sylab. When we do that we put stubs, we put non-functioning routines for the complicated parts and we get the structure out. Usually it is very inefficient but the first thing we do is we create the overall structure, we put some graph, graphics program because we like to see something coming out of the code as quickly as possible. But then if this program is to do anything you have to make the crucial parts very efficiently coded. Sylab has something called a profiler and it has to be used continuously because the profiler tells you where which routines are the ones you need to optimize. Those routines have to be moved to a better language, typically C. Once you have done that then the user input output still remains in Sylab and the graphical output still remains in Sylab which you can then improve as you like and you can call your C program via system calls or you can make a interface and call the C program as a built-in Sylab function. So this was done by students of mine and this is a particular example I'm showing. We wanted to simulate Erbium doped fiber sources. These are basically lasers, broadband lasers. So the diagram is here, you have a pump laser, this is a active medium, the medium amplifies signal, there's a filter here, signal comes right back, there's some very complicated interaction going on here and the output comes out from the back end. So how does one solve such a problem? The system of equations is quite complicated, I won't go into it but a hundred wavelengths each direction, so 200 plus equations and highly non-linear. Well, my students like all students don't like Sylab. First thing that he did was he went to MATLAB and he coded it and the worst thing about MATLAB is that it gives you black boxes for everything. So he said I can solve this problem in 10 minutes, he put it in and it didn't work. Naturally if it worked it wouldn't have been a master's problem for him. It was a boundary value problem, the equations were stiff, so naturally he put it in and a black box never works with difficult problems. So then by force I pushed him to Sylab and made him write his own solver and the first few efforts were not very good because really an explicit solver doesn't work well for such problems. The main problem was it wasn't converging for long lengths and it was very slow. The slow part of it we could tackle, we moved the solver to C and the fast part, the convergence part we had to do some more work that got him his master's degree. But now let's look at what Sylab was doing in all this. The code now was in C, but the user interface and the visualization was still in Sylab. So the first thing that the user interface had to do was to make it more user-friendly. So we needed to make menus and menus are built into Sylab, they're very easy to do. The second thing we needed to do was to, when a code runs for half an hour, you need to tell the user what's happening. You can't just have a blank screen for half an hour. So you needed to have dynamic updates of the code's progress. So how did we do that? Well, I'm showing here the code for the menu. It's very straightforward, but I'm just showing it so that you can understand how easy it is. All the work gets done in this XM dialogue. You have to give it a title, you have to give it a set of names which are the prompts and you have to give it a set of default values. It returns back the user-corrected default values. But there are one or two things you have to take care of. First of all, typically the user has been running this program before, so you should take the previous defaults from a file. But if you do this and the file doesn't exist, Sylab will abort. So you have to make sure the file exists. If it doesn't exist, you use default values. If it already exists, you show them the default values and you get them to update them. I mean, the logic can be changed. But the point is that you have to take care of such things when you're dealing with a random user. Now the dynamic interaction is almost as easy. Basically, all you have to do is polling. In fact, that's all you can do because Sylab doesn't support inter-process communication as far as I know. So you can't have a named pipe or you can't have semaphores and things like that, which allows Sylab to talk back and forth. So all you have to do is you keep asking every now and then. And whenever an iteration has happened, you update the curve. So here's the code for that. The particular curves are being stored. These are the old curves. I sleep for, these are in milliseconds, I think. So I sleep for two seconds at a time and then update. I read in the data. Then this is interesting because if you want to update a curve, you don't want to redraw the whole graph because every time Sylab redraws a graph, it takes a long time. So you would like to just draw the curve. That's much faster. And there's a command for that. It's called x poly s. The invocation is there in the help. So what you do is you write the new curve, add it to the list of already existing curves and the user can see how curves are evolving. The problem is pretty soon, you've got a very busy plot. So what you want to do is you want to actually deemphasize the old curves and make the new curves bright. So what I've done here is I've used soft colors for the old curves and bright colors for the new curves. So you can see, I think you can see for instance, black and blue are the new curves, whereas the softer green and light blue are showing you the older iterations. So you can see how the progress is happening. These techniques are very useful because they make using just standard Sylab, they make actually quite an effective tool. Another example, using graphs to present network traffic. So I have to store a lot of data about the problem and I need to plot this graph. Well, one problem is that Sylab doesn't support associative memory like Perl does. So you have to store it in arrays. But luckily, Sylab has both numeric and string arrays. So you can do almost as good a job as you would do with some of the other packages. The most convenient way of reading in database information is using command that can read dot CSV files, comma separated files. You just read in the data, convert to arrays. Now displaying the graph takes some work. The reason is that we wanted to do several things. We wanted to have nice big nodes. We wanted to have the edges with thickness representing the amount of traffic and we wanted to put the traffic against each link and we wanted to label the nodes. So what do you do? You first make a graph. There are some aspects of this that actually are pretty murky because for instance, you have to create the graph and then you have to create the window and things like that, which I don't understand. I know what works, but I don't know why it works. But let's look at what gets me the node size. Node size is got by defining this parameter, node diameter. It's 30 pixels, for instance. Then I want the edge width. Well, the edge width, I have my traffic. So I make a vector based on the traffic, properly normalized to the maximum line thickness and I put that into the graph's line edge width information. So that immediately gives me edges of different kinds of widths. Then I show the graph. As I told you, you have to first show the graph and then set the window index, why I am not sure. Now I would like to name the nodes. Well, naming the nodes is very simple because I know where my cities are because I use that to plot my graph. I just put a name next to it. But putting the information on the link is a little harder. First I locate where the midpoint of the link is. Then I locate the vector that shows me the direction of the link and then I want to go with an orthogonal direction because I don't want to write my link traffic on top of the link itself. I want to put it by the side of it. So I move orthogonally by about twice the thickness of the edge. So I find the orthogonal direction and then I move in that orthogonal direction by a distance that's twice the maximum line thickness and then I write out my information. And that gives me the plot we saw. So you can see that now all the information is nicely away from the link itself and the link edge thicknesses are all proportional to the traffic. And it makes a perfectly decent graph, something that we could actually be quite proud of. The last one, one of the common things that we would like to do is to animate progress of an algorithm. In this case, this was a class assignment I gave, which was to find the minimum of this function using different kinds of 2D minimizers. So one of the standard 2D minimizers is the Povel algorithm. So the students wrote the Povel algorithm in C. They defined the problem in Sylab and they presented the contour in Sylab. And now they had to show how the minimizer progressed towards the final result. Now how you do that is as follows. First of all, you draw your contour. Having drawn the contour, you put it in a do-look. You sleep for about 0.2 seconds and then you plot one point. Then you sleep for 0.2 seconds, plot the next point. Unfortunately, I don't have the code itself, but if you see the, if you run this code, it'll plot three points in a cluster, then it'll jump, plot three points in a cluster, it'll jump 0.3 points in a cluster, etc. You can see it crawling its way all the way around this valley to the minimum. It's a very powerful visualization tool when you do it that way because you can see just what the conjugate gradient technique, which both Povel and the conjugate gradient method use, how it works. That it locates the direction along the valley and moves in that direction and finds the minimum. So to conclude, Sylab is extremely powerful as a visualization and computing tool. I mean, it's not better than Matlab, but it's as good. In my opinion, it's even more powerful, especially for pedagogy when you use it with literate programming. And if you combine it with C code, it allows you to use your C on the main algorithm portion and let Sylab do all the rest, which is the user interface and the graphics. But there are some serious deficiencies in Sylab which you keep running up against. Now, I'd say to my mind, the biggest deficiency is the debugging problem. The, unless it's a function, you cannot really put breakpoints in Sylab. And even when you do, single stepping code is very difficult. I get past it by writing macros in Emacs and running Sylab under Emacs. But that's not, that's like my own solution to a bad problem. It's a problem that I think urgently needs solution. The other problems are, I think, also quite important. For instance, I've done a nice piece of work. I've generated a nice Sylab for a function. I want to now convert it to C and optimize it. That translator, the translator which takes me from Matlab to Sylab exists, but the translator that takes me from Sylab to C is, I think, more important. And that one does not exist. There used to be one which translated to Fortran, but it doesn't seem to work anymore. The other, another problem is that you can integrate C code into Sylab. But when you do that, you have to be very sure that you have done the interfacing correctly or you can crash Sylab itself. So that's why, in fact, I don't recommend for my students that they do it. Better to use a shell, escape and let them, let the shell handle the crash. And finally, one of the most useful things that you would like is for C to be able to call back to Sylab. For instance, one of the problems I had given them, they had to minimize a function that used Bessel functions. And the Bessel functions are well implemented in Sylab. But since I'm in C, I can't use the Sylab Bessel function and I had to link in my own copy of Bessel functions. This should not be required. I should be able to call back to Sylab and use the Sylab built-in routine from C. It's a, it's not a simple problem. It's not easy to do, but it's something that needs, I think, to be tackled. Thank you.