Courses/CS 491ab/Winter 2008/Oksana Maeva
From CSWiki
[edit] Week 1 - January 4, 2008
This was the class introduction. We did a short introduction about why we are computer science majors and possible thoughts on our 'project' for this class.
At the moment I am leaning towards doing the To Do List. It seems like a good opportunity to work with web programming which interests me more than any other subject in CS. Also, it is something i might want to do in the future as a career option. I am looking forward to exploring other interests, and learning new things having to do with web programming.
[edit] Week 2 - January 11, 2008
This week I spend quite a bit of time looking through the list of Platforms provided for us. The open source mathematical stuff caught my eye. http://msu.edu/~olsonluk/openSource/OSSMath.htm
After browsing the site, I settled on doing a little more research on Ox. I downloaded the editor and played around with the language a little bit. After doing so, I think I am leaning toward something more mathematical for my project. Possibly involving some web programming and math. I am currently taking a linear programming course, so it might be interesting to develop something along those lines.
This week I also went to the 'remember the milk' website to see if a to do list was something I was interested in and played around with that.
[edit] Week 3 - January 18, 2008
So far this week i have finalized my plans for the project. I will be creating a web application and tutorial for solving linear programming problems. I looked into current tutorials available and there are no tutorials that offer hands on experience. I also plan on integrating Ox to do some of the background math work in the tutorial, if not I will just use a java library and build on that.
Also i signed up for the Listserv for Ox users. --
After asking several questions on the Ox listserv I found out that there exists a package called OxJapi that allows Ox programs to run through the JRE.
Then I looked at possible java packages for linear programming. Nothing specific for linear programming but I found a lot of different packages for just linear algebra and matrices but they are not complete and still use the two dimensional array approach, although functions for multiplying matrices are in place. If Ox stuff doesn't work out it will be useful to just use the java packages and build on that.
i also downloaded and installed tomcat on my computer and maybe in the next week i'll put some code together to make a skeleton design for the tutorial website, and think about all the things i would like to include.
[edit] Week 4 - January 25, 2008
Better part of this week I spent talking to people and doing research on how I could connect Java and Ox. The only feasible solution seems to be to write Java code that will generate Ox code. I decided that it was not something I wanted to do. Also, through my discussion with some people that actually use Ox on a regular basis, it seems as though no one really uses Java in those environments. These people primarily work with C and Visual C++.
So the other half the week I spent digging into Matrix packages that have been developed specifically for Java. Although I briefly mentioned some of them during my presentation last time, I didn't go into them throroughly.
I have found three basic packages that seem to fit what I will be doing. Two of them are not complete.
1. Jampack (Java Matrix Package)
2. JAMA
3. MTJ Matrix Toolkits of Java
Although I am still learning about Linear Programming. I Think one of the most important things I want to focus on for my project is developing way to help people visualize and understand the Simplex Method and how it runs. Although there is three basic steps, sometimes the pivatol rows and columns are a little confusing to understand. I think an explicite example would be great. A java matrix solver might come in handy here because regular matrix row operations are easier to use while doing the simplex method, rather than subsituting and rewriting each row.
I also looked at a few Java Applet implementations of visualizing the feasible set of solutions on a 2D plane. Since many of these are open source, i might try to use one and fix it to my own specifications, or even build on one of i decide that something else needs to be added.
[edit] Week 5 - February 1, 2008
My previous project ideas have been falling apart, to remedy that I went to meet with Dr. Gray in the Math department to do some work for the National Curve Bank.
After meeting with her and discussing some project ideas, we settled on doing some Mathematica code for the Osculating Tacnode Curve.
I will be creating an animation in Mathematica then saving it as a .gif image to be used on the website. The code will also be given to Dr. Gray. Then I will be developing the information page about the curve etc.
I've been doing some research on Mathematica and coding in Mathematica. I have been reading a lot of help sites and the documentation provided by Wolfram. Also I am slowly learning how to program in the Mathematica language.
This project is a little more exciting than my previous ideas. Since it's a little more math oriented i feel more confident about the choice. Also learning some new software/language is also interesting, especially since it's quite different than any other language i've encountered so far.
[edit] Week 6 - February 8, 2008
I have spent a lot of time this week reading documentation and various other Mathematica Notebooks sorting through the many types of animated images that can be created in Mathematica.
First, you can animate an image by using a Plot and having that plot move by varying one, two, or more variables in the equation.
Animate[Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5}]
There the Sin function is first plotted by x, then the plot range is given to display the graph, and finally the animation is shown by constantly varying the a variable from {a,0,5}, so in the animation the sine wave moves as a continuous wave.
When I tried to apply this type of animation to my plot of the Tacnode Curve, it tried to animate the whole 'wave' per say, and hence the abrupt and ugly looking thing that I showed in class last week. These type of wave animations can be done with Animate in 3D as well, which look really neat.
I know how I need to be able to 'draw' my curve and save it in animated form. Then after more research I found a tutorial, so that in order to 'draw' images in Mathematica I need to apply a "do" looping function. So I need to Generate a bunch of Images and use the do function to put the images together.
One of the biggest problems i've been running into though, lots of code examples I find online I can't run on my version of mathematica because they were done with older versions, and since there are compatibility issues, makes it a little more difficult. after reading some documentation though about the changes that have been implemented in Mathematica 6, i definitely think it's an upgrade from what you had to do before. It seems that the new version is more self contained and easier to use, but on the other hand, all the available notebooks won't work, especially with graphics since it was one of the biggest things that got changed.
[edit] Week 7 - February 15, 2008
This week I have been continuing figuring things out in Mathematica. I am getting frustrated with the examples on the Mathematica website since they are all so trivial. On the other hand MathWorld also done by the same people as Mathematica has whole Mathematica notebooks that I am able to look at which is a plus. But at the same time they are all older versions, I have yet to find anything pertinent to what I am doing that is done in Mathematica 6.
This week I also went through and found some new functions to help me understand how Mathematica executes the function that I am giving it. I took some advice from a student last week to possibly see if Mathematica was confused with the way the function was implemented. Everything came out fine, so the fact that the function when done in ContourPlot does not evaluate at 0 is still a mystery.
I also ran the equation through some functions to see if Mathematica does recognize that when x=0 and y=0 the result is 0, it does. I'm starting to wonder maybe it's just an error with Mathematica 6, or maybe the contour plot is working slightly different. When i went back to the code that was given to me, it was done with implicitplot which no longer exists in the new version. A big thing i noticed is implicit plot is only given input on the x axis. as in -2<=x<=2. while with the new version using contour plot i have to give the function the x and y intervals to where it should be evaluated.
I finally found a blog where some non-trivial code is given and explained, in mathematica 6. i found this out late in the week but i tried to understand this bit of code here
trace, p, q, x, va are all variables here
manipulate creates an expression with added controls so it can be moved around
Manipulate[
Graphics[ draws the specific parts of the graph
{{Thick, Yellow, Disk[{x, 1}, 1]},
{Thick, Orange,
Circle[{x, 1}, 1]},
{Blue, Thickness[.008],
Line[{{x, 1}, {x - q Sin[x], 1 - q Cos[x]}}]}, the line joins a sequence of points together
{PointSize[Large],
Red, Point[{x, 1}]},
{PointSize[Large], Magenta,
Point[{x - q Sin[x], 1 - q Cos[x]}]},
If[trace, {Red, Thick,
Line[Table[{t - q Sin[t], 1 - q Cos[t]}, {t, 0, x, 0.001}]]}]},
The If[condition, t, f] gives t if condition evaluates to True, and f if it evaluates to False.
AspectRatio -> Automatic,
Background -> Black,
ImageSize -> {640, 480},
ImagePadding -> 100,
AxesOrigin -> {0, 0},
If[va, Axes -> True,
Axes -> {True, False}],
AxesStyle -> Directive[Thick, Orange, If[p < 2 Pi, 24, 12]], draw and label axes
PlotRange -> {{-1, 2 p + .5}, {-.5, 2.3}},
If[ticks, Ticks -> {Range[IntegerPart[2 p + .5]], {1, 2}},
Ticks -> {{None}, {None}}]],
{{x, 0}, 0, 2 p, 0.001}, evaluate x at specific points
{{q, 1}, 0.01, 5, 0.001}, same for q
{{p, Pi}, 0.01, 4 Pi, 0.001}, same for p
{trace, {True, False}}, sets values to which part is true and false in trace
{ticks, {True, False}}, same for ticks
{va, {True, False}}]
[edit] Week 8 - February 22, 2008
I haven't done much this week in respect to 'programming' anything in Mathematica. The first thing I focused on was finding out why my Contour Plot is still not evaluating my function at x=0, y=0. After some research I had found that certain functions in Mathematica do not evaluate functions, or certain points of functions, or do so under the special control of that particular function. The function Plot does that. Although I haven't found any specifics on Contour Plot, I am assuming it does the same thing, since the objective of both functions is relatively the same, only ContourPlot allows for multiple variables while plot doesn't.
A solution that was given was to use a function called Evaluate, to Evaluate all the points of a function first and set them into a table. Then have the Plot work with the evaluated values of the table. The Table function I presented a few weeks ago, was the one that allowed me to create a series of images for a function. So then I thought maybe I could evaluate my function and set some values in a table first and then run Evaluate and nesting it in the ContourPlot.
First I ran table on the function and only set the x variable to change the following result was achieved.
Table[2 x^4 - 3 x^2 y + y^2 - 2 y^3 + y^4, {x, -2, 2}]
{32 - 12 y + y^2 - 2 y^3 + y^4, x = -2
2 - 3 y + y^2 - 2 y^3 + y^4, x = -1
y^2 - 2 y^3 + y^4, x = 0
2 - 3 y + y^2 - 2 y^3 + y^4, x = 1
32 - 12 y + y^2 - 2 y^3 + y^4 } x = 2
What I find interesting about this part is the fact that the function seems to evaluate only at integer values.
Now when evaluating all of that with just the y parameters we get
Table[2 x^4 - 3 x^2 y + y^2 - 2 y^3 + y^4, {y, -.2, 2.5}]
{0.0576+ 0.6 x^2 + 2 x^4, y = -.2
0.0256- 2.4 x^2 + 2 x^4, y = 1.2
2.0736- 5.4 x^2 + 2 x^4} y = 2.2
Here we are evaluating every 1 integer step.
Then I figured maybe if i created a table that evaluated everything at x first and when i went to draw the graph in plot that i would iterate through y. although that worked and the graph did get evaluated at 0, it wasn't the osculating curve. Same thing when first evaluated at y then iterated through x, only the curve came out differently.
And then I found this hidden away in Mathematica Documentation and all of a sudden it makes a lot more sense
You should realize that since it uses only a finite number of sample points, it is possible for ContourPlot to miss features of your functions. To check your results, you should try increasing the settings for PlotPoints and MaxRecursion.
So Editing Plot Points and MaxRecursion fixed my problem. MaxRecursion basically makes the image of better quality. Although it's not looking particularly great at the moment, it's a lot closer to the original image. MaxRecursion is hard to run because of the recursive calls, really slows my computer down, so i am going to go on and work on the animation itself, and then run the final with MaxRecursion since i know how to fix the problem now.
[edit] Week 9 - February 29, 2008
This week I went back to the Manipulate Image i worked with in week 7. To fully understand the code, because the overview i did before made me realize that I had very little concept of how it worked. I had a general idea, but wasn't sure how all the parts worked together.
Manipulate[
Graphics[{{Thick, Yellow, Disk[{x, 1}, 1]}, {Thick, Orange,
Circle[{x, 1}, 1]}, {Blue, Thickness[.008],
Line[{{x, 1}, {x - q Sin[x], 1 - q Cos[x]}}]}, {PointSize[Large],
Red, Point[{x, 1}]}, {PointSize[Large], Magenta,
Point[{x - q Sin[x], 1 - q Cos[x]}]},
If[trace, {Red, Thick,
Line[Table[{t - q Sin[t], 1 - q Cos[t]}, {t, 0, x, 0.001}]]}]},
AspectRatio -> Automatic, Background -> Black,
ImageSize -> {640, 480}, ImagePadding -> 100, AxesOrigin -> {0, 0},
If[va, Axes -> True, Axes -> {True, False}],
AxesStyle -> Directive[Thick, Orange, If[p < 2 Pi, 24, 12]],
PlotRange -> {{-1, 2 p + .5}, {-.5, 2.3}},
If[ticks, Ticks -> {Range[IntegerPart[2 p + .5]], {1, 2}},
Ticks -> {{None}, {None}}]], {{x, 0}, 0, 2 p, 0.001}, {{q, 1},
0.01, 5, 0.001}, {{p, Pi}, 0.01, 4 Pi,
0.001}, {trace, {True, False}}, {ticks, {True, False}}, {va, {True,
False}}]
So i did a thorough examination of the code which i will explain in class and i was able to animate this image so it works without having to manually manipulate each of the variables. although the flow of the animated image isn't 100% i am starting to figure out what it takes to animate an image versus just manipulate one.
my next step for the next week is to create a manipulate function for my tacnode curve and then i can possibly animate it.
[edit] Week 10 - March 7, 2008
This week I was able to figure out and replicate a little ball drawing an equation and a 'trace' of the ball following it. Turns out I still didn't quite clearly understand the code that i analyzed previously. It seems like there are so many important little details that entail in making an animated image. From this point i was able to animate the x^2 curve.
Turns out that my max variable in the initial drawing of the curve needs to be evaluated as the current variable of the dot, which makes perfect sense. That way i get the 'trace' effect. Turns out though the 'trace' function used in the sample code does very little for that code. It just creates a little check mark where you can turn the trace on and off. I don't need to be doing this at this point.
Then I tried to implement the same type of idea with multiple variables. to pot the points by evaluating x first and then evaluating the equation with y, was just giving me rather linear representation and wasn't giving me the correct curve.
So i had to take a different approach, Here i started with varying the max variables in the ContourPlot and animating that image. But for some reason the function is still being evaluated wrong, my other concern is that when the image is being drawn it's all choppy and doesn't flow like it should, i think this is because some variables are being evaluated at integer values, while i am trying to add that the other gets evaluated at increments. ContourPlot itself doesn't allow me set the increments of evaluation.
Also I found out when i Animate ContourPlot this way, it seems that the variables get evaluated and the image is drawn from the ground up. Rather than following the right side and then following the left side of the image. even when i just isolate the right side of the image it still draws the side (both lines) from the origin.
Ok just to add that i do have a working animation right now with the fixed 0 point. one of the things i plan to do over break is to possibly see if i can make a better more interesting animation. i would like it to follow the curve from bottom right to bottom left. but we'll see if that's possible. at this point i'm not too sure. also i will be working on attaching some sound.
[edit] Project Description
[edit] Brief project description
My project involves using Mathematica software to create an animated Tacnode Curve
which then will be put up on the National Curve Bank, a section of the Cal State LA Mathematics department website.
The curve is represented by the equation : 2x^4-3x^2y+y^2-2y^3+y^4==0. The curve will be animated using Mathematica code and put into a Mathematica notebook which will be available for download by anyone accessing the site. The notebook will include various graphic images allowing users to explore the curve and it's formation and evaluation, along with a description and explanation of how to achieve similar results with similar curves.
Although off the bat it may seem as though creating an animated image is a rather simple task, things that must be considered in creating it have proved to be challenging, such as the considerations of variable use and the looping mechanism in Mathematica.
[edit] Users (anticipated)
The users of this site will be mostly Mathematics students who look at the National Curve Bank. I will make my code available if anyone wants to run the Mathematica Notebook on their own. This project will be used after the completion of the quarter, since all the information will be up on the Curve Bank website.
[edit] Main conceptual (i.e., user-level) objects
The object that I create in Mathematica will not be able to be manipulated on the website itself, since it needs to be saved to a .*gif file to be displayed. Upon downloading the Mathematica notebook, though, some actual manipulation of the object can be done. For example, the variables that are being varied in the equation can be manipulated by the Animate Function to visually see how the curve is being formed and designed.
As far as the site itself is concerned, it will just a basic user, informational page about the curve, it's origin, and the complete notebook used to design the Curve with explanations and demonstrations.
[edit] Primary conceptual (i.e., user-level) operations
Mathematica will be using several built in functions to create an overall animation of the curve. Some of which are Animate: that allows a user to animate a certain function with several constraints and inputs. Graphics allows users to display different types of images within images, and Tables that help evaluate functions.
With the use of these functions the user of the notebook will be able to see how the functions are evaluated in Mathematica, what possible errors they might encounter when using them, and a see a general description of of how to use these functions in the ContourCurve context.
[edit] Why I am interested in this project
This project interests me because it's not usual programming. Here I have had to learn a completely new language and system that has very little in common with regular Object Oriented languages like Java and C++. Even most of the syntax is different and Mathematica is widely used in education and in the Mathematics community.
Aside from learning to program in a new language, this project is allowing me to develop my skills in Mathematics and applying abstract ideas to something concrete. Also the skills and understanding that i already have about programming languages and general experience with them is also being integrated here because it helps me understand how some 'loops' are evaluated, although they are not written as regular loops.
Overall it's been a big learning and discovery experience. Also like this project because it's cute.
[edit] Status
Currently I have jumped over several barriers I had when I first started working on this project. I am getting a much better feel for Mathematica and how functions are evaluated. I have gotten several images to animate, and do have a working animation of the tacnode curve.
Although, I'm not particularly please with the way the image is animating at the moment. The animation begins at the point (-2,-.2) and because of the way the function is being defined at certain iterations through the varied variables sometimes the x variable has a higher weight than the y and the curve isn't followed the expected way. Rather it is formed from the x axis upwards to the y axis. This is because the function isn't 'balanced' like x^2=y or x^2+y^2=1.
So for next quarter I will be trying to make a better looking animation and hopefully find a way to have a 'trace' on the image rather than building it up. Also I will try to attach the 'kissing' sound.
To finalize my project the final notebook will not only contain code for the animated curve, but also explanations and demonstrations of how most the functions being used work. I will demonstrate the pitfalls that I have, and others, might run into while working with similar curves in this type of environment. Also I will add a manipulate function which will allow the user to not just watch the image move as each point gets evaluated but they can drag controls on the image so that they have a more hands on experience with the curve.

