Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - 3rik

Pages: [1]
1
TI-Nspire / Matrix Library
« on: June 22, 2012, 06:28:21 pm »
As the title implies, I'm planning on making a matrix library for Lua. I want it to be usable in computer Lua, too, so I don't want to use math.eval or other calculator dependent functions in this library. The math related aspect of this project can be found here.

Spoiler For fixed (I think):
My first roadblock is with being able to make the matrix itself.

I want the matrix to be unable to be edited without using the matrix functions. This can be accomplished using up-values, __index, and __newindex but I cant seem to figure out a good way to do this. I also want all the matrix functions to be available from the matrix.

Basically, I want it to be tamper-proof. I imagine it functioning like like this: (don't worry about the functions them selves)

Code: [Select]
matrix1 = matrix.new({{2, 3, 4}, {3, 4, 5}})
matrix2 = matrix.new({{1, 0, 5}, {2, 5, 9}})

matrix1:add(matrix2) == matrix.add(matrix1, matrix2) --true

matrix1[1] = {2} --error

matrix1[1][1] = 2 --no error

matrix1[1][1] = "2" --converts to number

matrix1[1][1] = true --error

table.maxn(matrix1) == 0 --true matrix1 doesn't actually contain any values, it forwards them to a local table in the matrix.new function

matrix1[1][300] = 2 --error wrong dimensions

If anyone has any suggestions, it would be very helpful.

Edit: I've attached a copy to the first post so people don't have to search through the topic for a copy.



Lua Matrix Library
Last Update: July 16, 2012, 03:03:56 pm
Version: 0.9.2
New Features: added lu, trace, det, ref, rref, and rank


2
Math and Science / Matrices/Complex Numbers
« on: June 14, 2012, 02:22:52 pm »
I'm beginning to plan for a library that adds complex numbers and matrices to Lua (both calculator and computer). (There would also be copies that add one or the other because this will probably be a big library that could take a while to load.) I feel like I'm always making simplified versions of these, so I want to just make a complete library and be done with it.

I haven't taken linear algebra yet, but I don't want to have to edit my library later to add new functions, so I need to gather all the operations/features of matrices and complex numbers that would be useful in a multipurpose library. I don't plan on doing much symbolic stuff.

I haven't started coding yet, so suggestions are welcome, but I'll probably add a topic in the Lua section when I get to that point. I'd appreciate help adding to the following list if there's something you think would be useful. I'll get the basic ones out of the way here. If you notice anything that's inaccurate or incomplete, please correct it. :)

Spoiler For One Matrix and One Scalar Operations:
One Matrix and One Scalar Operations:

Spoiler For Addition:
Addition:

Adds the scalar to each element in the matrix

Limitations: none

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D%2B5
Spoiler For Subtraction:
Subtraction:

Add the quantity on the left with the quantity on the right multiplied by -1. (see above and below)

Limitations: none

Example: http://www.wolframalpha.com/input/?i=simplify+5-%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Multiplication:
Multiplication:

Multiply each element on the matrix by the scalar.

Limitations: none

Example: http://www.wolframalpha.com/input/?i=simplify+5*%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Division:
Division:

If the scalar is on the left, take the multiplicative inverse of each element in the matrix and multiply
If the matrix is on the left, divide each element in the matrix by the scalar

Limitations: If the matrix is on the right, it may not contain a 0. If the scalar is on the right, it may not be zero.

Example: http://www.wolframalpha.com/input/?i=simplify+5%2F%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Exponentiation:
Exponentiation:

If the scalar is the exponent, repeat matrix multiplication the number of times specified.
If the matrix is the exponent, raise the scalar to the power of each element.

Limitations: If the scalar is the exponent, it must be a nonnegative integer (raising it to the 0th power produces an identity matrix) and the matrix must be a square matrix. If the matrix is the exponent, the base must be nonnegative, and if the base is 0, the matrix may not contain nonpositive numbers.

Examples: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D%5E5
http://www.wolframalpha.com/input/?i=simplify+5%5E%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Two Matrix, Element-by-Element Operations:
Two Matrix, Element-by-Element Operations:

Spoiler For Equality:
Equality:

If each corresponding element in each matrix are equal, the matrices are equivalent.

Limitations: Matrices must be the same dimensions

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D%3D%3D%7B%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%7D%2F2
Spoiler For Addition:
Addition:

Adds the corresponding elements of the two matrices.

Limitations: Matrices must be the same dimensions

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+%2B+%7B%7B2%2C+3%2C+4%7D%2C+%7B2%2C+3%2C+4%7D%7D
Spoiler For Subtraction:
Subtraction:

Subtracts each element from the matrix on the right from the corresponding element in the matrix on the left.

Limitations: Matrices must be the same dimensions

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+-+%7B%7B2%2C+3%2C+4%7D%2C+%7B2%2C+3%2C+4%7D%7D
Spoiler For Multiplication:
Multiplication:

Multiplies the corresponding elements of the two matrices.

Limitations: Matrices must be the same dimensions

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+*+%28%2B%7B%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%7D%29
Spoiler For Division:
Division:

Divides each element from the matrix on the left by the corresponding element in the matrix on the right.

Limitations: Matrices must be the same dimensions and the matrix on the right must not contain a 0.

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+%2F+%28%2B%7B%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%7D%29
Spoiler For Exponentiation:
Exponentiation:

Raises each element from the matrix on the left to the power of the corresponding element in the matrix on the right.

Limitations: Matrices must be the same dimensions. If the matrix on the left contains any negative numbers, the corresponding element in the matrix on the left must be an integer power (since this is all Lua can handle). If it contains a zero, the corresponding element must be positive.

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+5%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+**+%28%7B%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%2C+%7B2%2C+4%2C+6%7D%7D%29
Spoiler For Special Two Matrix Operations:
Special Two Matrix Operations:

Spoiler For Multiplication:
Multiplication:

The elements of the rows in the matrix on the left are multiplied with corresponding columns in the matrix on the right. Then they are added up and that is the element of the new matrix. This element is in the same numbered row as the row used from the matrix on the left and the same numbered column as the column used from the matrix on the right. It can be thought of as the dot product of the row vector and the column vector.

Limitations: The number of columns in the matrix on the left must be equal to the number of rows in the matrix on the right.

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D+*+%7B%7B2%2C+2%2C+2%7D%2C+%7B3%2C+3%2C+3%7D%2C+%7B4%2C+4%2C+4%7D%7D
Spoiler For One Matrix Operations and Properties:
One Matrix Operations and Properties:

Spoiler For Transpose:
Transverse:

For each element in a matrix, switch its row number with its column number. Switch the dimensions, also.

Limitations: none

Example: http://www.wolframalpha.com/input/?i=simplify+%7B%7B1%2C+2%2C+5%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D%5ET
Spoiler For Conjugate Transpose:
Conjugate Transpose:

The same as the transpose except it switches the sign on any imaginary values in the matrix. (6+4i becomes 6-4i). If all the elements in the matrix are real, then the conjugate transpose is the same as the transpose.

Limitations: none

Example: http://www.wolframalpha.com/input/?i=simplify+conjugate+transpose+%7B%7B1%2C+2%2B4i%2C+5i%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2-i%2C+3%7D%7D
Spoiler For Pseudoinverse:
Pseudoinverse:

Does this stuff http://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse. It's a general inverse for all matrices regardless of their dimensions. The result of the product of the original and the pseudoinverse isn't necessarily the identity matrix, but if multiplied by the original matrix again, it will produce the original matrix. It always exists and is always unique. If the matrix is a non-singular square matrix, the pseudoinverse will be equal to the inverse (there is still a pseudoinverse for singular square matrices).

Limitations: none

Example: http://www.wolframalpha.com/input/?i=pseudoinverse+%7B%7B1%2C+2%2C+5%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Determinant:
Determinant:

The determinate has various geometric properties. The determinate of an inverse matrix is the the multiplicative inverse of the determinate of the original matrix. If the original determinate is zero, the matrix is singular.

Limitations: The matrix must be a square matrix

Example: http://www.wolframalpha.com/input/?i=simplify+determinant+%7B%7B1%2C+2%2C+5%7D%2C+%7B1%2C+2%2C+3%7D%2C+%7B1%2C+2%2C+3%7D%7D
Spoiler For Generatable Matrices:
Generatable(?) Matrices:

Spoiler For Identity Matrix:
Identity Matrix:

Generates a square matrix that has all 0s except for along the diagonal where it has 1s.

Limitations: It must be a square matrix (implying that it's dimensions will be positive integers).

Example: http://www.wolframalpha.com/input/?i=simplify+identity+matrix+5

Spoiler For Random Matrix:
Random Matrix:

Generates a matrix with specified dimensions and random elements between 0 and 1. (Other operations can be done if you want a different range or complex numbers)

Limitations: Its dimensions must be positive integers.

Example: http://www.wolframalpha.com/input/?i=random+6x2+matrix

Other functions:
ref()
rref()

There is also all the other various math functions. They all take one matrix as an argument and effect each element-by-element.

As far as complex numbers go, are there any useful functions that apply to complex numbers (cis and arccis for example). I would update the math library to include complex numbers too. I don't know what to do about the periodicity created by some operations, yet.  :-\

 :D  The End          (It's only the beginning) x.x

3
Math and Science / Calculating Trajectories
« on: January 15, 2012, 09:51:23 pm »
I'm working on a problem that involves accurately predicting the trajectory of a ball.

To simplify things a bit let's say I have a cannon that is capable of putting backspin on the cannonball. This cannon is capable of moving anywhere on the ground. It can adjust the angle it is firing at and how fast it shoots the cannonball. How do I determine what position, angle, and speed I need to hit a target in 3D space?

While looking on the internet I found a bunch of things that involved differential equations, the Magnus Effect, and integrals.

I haven't taken high school physics yet and I am only learning beginning to learn about definite integrals in calc 1.

If there's anyone that can explain a method for finding this that doesn't involve too much advanced calculus, they would be really helpful. It may eventually be included in a program so the less symbolic stuff the better.

Thanks in advance.

4
Miscellaneous / Bookmarklets
« on: October 10, 2011, 09:14:00 pm »
Quote from: Wikipedia - Bookmarklet
A bookmarklet is Unobtrusive JavaScript stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. The term is a portmanteau of the terms bookmark and applet, however, an applet is not to be confused with a bookmarklet just as JavaScript is not to be confused with Java. Whether bookmarklet utilities are stored as bookmarks or hyperlinks, they are designed to add one-click functionality to a browser or web page. When clicked, a bookmarklet performs some function, one of a wide variety such as a search query or data extraction. Usually the applet is a JavaScript program.

This is a fun one I created. Just Copy and Paste the following code into a bookmark then click to enjoy.


javascript: var hi = function() { var audio = document.createElement("embed"); audio.setAttribute("src", "http://radio.omnimaga.org/songs/Rick Astley - Never Gonna Give You Up (DJ Omnimaga Happy Hardcore Remix).mp3"); audio.setAttribute("autostart", "true"); audio.setAttribute("loop", "true"); audio.setAttribute("hidden", "true"); audio.setAttribute("volume", "100"); document.body.appendChild(audio); }; alert("TURN ON YOUR SPEAKERS AND GET READY FOR AWESOMENESS!!!"); hi();

  :D

Other bookmarklets that have been mentioned include:

http://ourl.ca/7315

Spoiler For Cheat Code for the bookmarklet above:
Spoiler For One must not overly abuse this awesome power:
javascript: window.ASTEROIDS.enemiesKilled=13370000000000000; Doesn't work anymore.  :(

 ;)
:devil: :devil: :devil: :devil: :devil:

http://ourl.ca/9461

http://www.quickonlinetips.com/archives/2008/07/edit-any-web-page/

Note: Some browsers don't allow "javascript:" to be pasted directly into the address bar so be sure to either retype it at the beginning or just put it in a bookmark.


If anyone else finds cool new ones or makes their own, post them here. (As long as they aren't harmful.  D:)

5
Math and Science / Understanding Shading
« on: August 26, 2011, 04:52:03 pm »
I am working on a Lua function that creates a TI Image of a 3D object made of triangles but I don't know how to determine what shade the pixel should be.
I have looked at some websites but they either didn't get into detail or they used notation or syntax I'm not familiar with.

This is the relevant information I have:
camera position
light source position
the points that make up the triangle
the equation of the plane the triangle lies in
point where the camera view intersects the plane
the original color of the triangle

If anyone understands how Phong shading (or something similar) works, explaining it at a precalculus level would be much appreciated.

Something like this is what I am thinking of but I don't know how it works.


I know about vectors but I don't understand what R is.

Thank you

6
Introduce Yourself! / Hello.My name is 3rik.
« on: August 08, 2011, 10:35:32 pm »
Hello World!
My name is 3rik. I’m a student from the United States. This is the first forum I have ever been a part of so it may take a while to get accustomed to using it.

I became a member of Omnimaga because I want to learn more about calculator programming, I think that I would enjoy programming as hobby, and everyone here seems really friendly.

As for calculators, I own a TI-84+ Silver Edition and a TI-Nspire CX. I know BASIC on the TI-84 somewhat well. I am also in the middle of learning Lua for the Nspire and I am going to eventually learn assembly for the TI-84.

I am excited to learn more about calculators and hopefully get to the point where I can start developing games. I probably won’t post as frequently as other members since I'm shy and I don’t understand everything I read here yet.

My Website: http://www.programs-of-3rik.co.cc

Pages: [1]