Math Introduction to computer algebra systems?

Does anybody know of any resources (books, classes, lecture notes, or anything) about the general theory of computer algebra systems (e.g. mathematica, sympy)? "Introductory" materials are preferred, but I realize that with such a specialized subject anything is bound to be fairly advanced.

Math Calculate distance between two x/y coordinates?

I would like to calculate the distance between two x/y coordinates on the surface of a torus. So, this is a normal grid that has the property that its corners and sides are 'connected'. For example, on a grid of 500x500, the point at (499, 499) is adjacent to (0, 0) and the distance between e.g. (0,0) and (0,495) should then be 5. Is there any good mathematical way of calculating this?

Math How to remove colinear points from a list of points?

Given a point list (A1, A2, A3, ...., AN), each point Ai has Ai_x, Ai_y, and Ai_z indicates the x, y, z coordinate respectively. Assume that given three point AONE, ATWO, ATHREE, a function named as checkColinear exist, i.e. checkColinear(AONE, ATWO, ATHREE) returns TRUE if points AONE, ATWO and ATHREE are colinear. I am looking for a quick method to remove points that are colinars with some key points on the list. Thank you

Math Find the closest tile along a path

I have a tile based game and I need to find the closest tile within a 32px radius. So say a user is at 400, 200 and the user clicks at 500, 400. I need to create a path or line from the player to the mouse position on click and the closest tile that is underneath the path within 32px (or 2 tiles) must be chosen. The map is tiled at 16px. A function call to see if a tile is at a given tile position is available Map.at(x,y). I just don't know the maths to use to work this out. The block block

Looking for good substitute for calculating percentage employing integer math

I am a hobbyist programming for an embedded application. The application requires speed. I would like to determine whether or not a certain variable (call it "X") has passed a certain percentage (call it "Y") of another variable (call it "Z"). X, Y, and Z can all change at runtime. Since I need speed I would like to do this using integer math as opposed to float, which incurs a speed penalty. Are there any tricks for doing this? I am a self trained programmer so please excuse me if this is

Math OpenGL: glRotate: determining the 'angle' component

I need some help with math and OpenGL. I want to make some object follow another one, that is, turn its face to another object every time the former moves. So I learned about glRotate. I thought I would obtain the (x, y, z) of the former everytime it moves and then send its coordinates to another function which should update the 'facing to' property of the latter. But, how do I find the 'angle' parameter to glRotate based on both new and old direction of the follower object? Any help is highl

Math Do not want scientific notation on plot axis

I regularly do all kinds of scatter plots in R using the plot command. Sometimes both, sometimes only one of the plot axes is labelled in scientific notation. I do not understand when R makes the decision to switch to scientific notation. Surprisingly, it often prints numbers which no sane human would write in scientific notation when labelling a plot, for example it labels 5 as 5e+00. Let's say you have a log-axis going up to 1000, scientific notation is unjustified with such "small" numbers.

Math Algorithm for finding an equidistributed solution to a linear congruence system

I face the following problem in a cryptographical application: I have given a set of linear congruences a[1]*x[1]+a[2]*x[2]+a[3]*x[3] == d[1] (mod p) b[1]*x[1]+b[2]*x[2]+b[3]*x[3] == d[2] (mod p) c[1]*x[1]+c[2]*x[2]+c[3]*x[3] == d[3] (mod p) Here, x is unknown an a,b,c,d are given The system is most likely underdetermined, so I have a large solution space. I need an algorithm that finds an equidistributed solution (that means equidistributed in the solution space) to that problem using a pse

Math Generate subdivided triangle-strip cube?

I want to generate a cube where each face is divided into bits, like the following image: http://img59.imageshack.us/img59/2504/gridcube165c3.jpg Now, I can do this pretty simply if I'm just rendering quads, by just spacing vertices along each face plane at regular intervals, but my problem comes in when I want to turn the whole thing into a triangle strip. I've just got no idea how to unwrap it programmatically- is there some pattern to unwrapping that I'd follow? I'm thinking of starting wi

Naive Bayes Classifier Mathematics - Lack of Precision in Computing

I was talking with someone about the Naive Bayes classifier from a mathematics point of view. We were talking about how if you multiply a lot of probabilities together, eventually primitive types like a float or a double would not be able to store the resulting value and it would just get turned into a zero. P(x1)* P(x2) * ... = a number too small for a computer = 0 The person I spoke with said that a "workaround" would be to take the log of the probabilities and just add them together like so

Mathjax loading issues

I've a web page that renders latex equations using mathjax. In order to load the equations faster, i'm trying to avoid the preprocessing step, by replacing the math delimiters by <span class="MathJax_Preview">[loading...]</span><script type="math/tex;"> latex equation here </script> But the problem is; while rendering, the html entities that comes within the equation are shown as such and hence the equations are not rendered properly.For eg, '&' is used for alignm

Math Control sum in network connection

i'm making network application which doesn't send good data every time (most of time they are broken) so i tought to make control sum. At the end of data i will add control sum to check if they are valid. So i'm not sure is that a good idea to multiply every data (they are from 1 to 100) by 100, 100^2, 100^3..., and sum them. Do you have any suggestion what to do, without making really big number(there are many data in the every packet). Example: Data: 1,4,2,77,12,32,5,52,23 My solution:1,4,2,7

Math Floating point error in successive coordinate rotations

I have code (Python) that must perform some operations regarding distances between reflected segments of a curve. In order to make the thinking and the code clearer, I apply two rotations (using matrix multiplication) before performing the actual calculation. I suppose it would be possible to perform the calculation without any rotation at all, but the code and the thinking would be much more awkward. What I have to ask is: are the three rotations too much of a penalty in terms of lost precisi

Math Determining if two IP adresses are on same subnet - is it leading or trailing 0s get dropped from IP address?

I understand if two IP addresses are AND'd with a subnet mask if the result is the same then they are on the same network. If the result is different then they are on different networks. My question is, when given an IP address omitting some 0s where do the extra 0s get placed? For example if the subnet mask is 255 . 128 . 0 . 0 , and you have IP 126 . 1 . 0 . 10 and IP 126 . 127 . 0 . 1 if you just blindly AND the IPs with the subnet mask you get different results even though they are on the s

Math Calculate percentage fill of progress bar

I am having trouble setting the worrect width of my progress bar image on a userform in Excel VBA. I have a userform, and on that form is a label, and an image. The maximum width of the image is 330. In my loop from 1 to intNumberOfGetRows (in this case 64) I want to update the width property of the image to show progress as each 1000 record chunk of a large recordset is put in an array and written to a csv file. Here is my code: For intRecord = 1 To intNumberOfGetRows + 1 ' outer loop

Math log-sum-exp trick why not recursive

I have been researching the log-sum-exp problem. I have a list of numbers stored as logarithms which I would like to sum and store in a logarithm. the naive algorithm is def naive(listOfLogs): return math.log10(sum(10**x for x in listOfLogs)) many websites including: logsumexp implementation in C? and http://machineintelligence.tumblr.com/post/4998477107/ recommend using def recommend(listOfLogs): maxLog = max(listOfLogs) return maxLog + math.log10(sum(10**(x-maxLog) for x in li

Math Oscillate value based on input

Math is not my strong suit; hope to find some help for this pretty basic question. I have a function taking an input value based on a modulus operation. So the input goes from 0-60, then repeats. I want the function to return an value that oscillates within a range. For example, it would return values in the range 0-60, then return values in the range 60-0, then repeat. Can anyone point me in the right direction? Edit Here is what my function to look like: int convert(int input) { // inpu

Math How to check if point is in line shadow

I can't really figure out how exactly to phrase this question, so I made a crude graphic explaining what I'm trying to ask: Given a line comprised of two points, how would I go about checking if a given point was within the area relative to the line as displayed in the image? Sorry if there is a term for this that I didn't know.

Math Get new position x distance away from another position using a slope

Excuse me if I phrased the title wrong, I am not great with math and don't know the right term, but I figure someone will edit it correctly. I am creating a script in Lua and I have a target location and my location. I found the slope for it so at the moment I have X1, X2, Y1, Y2, and M(slope). I do not know the math to add a new point with x distance away. Sort of like this badly done MS paint example where the 2 black dots are target on the far right, and my location on the left, and then th

Math Convert Linear scale to Logarithmic

I have a linear scale that ranges form 0.1 to 10 with increments of change at 0.1: |----------[]----------| 0.15.010 However, the output really needs to be: |----------[]----------| 0.11.010 (logarithmic scale) I'm trying to figure out the formula needed to convert the 5 (for example) to 1.0. Consequently, if the dial was shifted halfway between 1.0 and 10 (real value on linear scale being 7.5), what would the resulting logarithmic value be? Been thinking about this for hours, but I have not w

Math Positive vs negative nans

I have some numerical code that was developed on AMD64 Linux (using LLVM 3.2). I have recently ported it to OSX 10.9 with XCode. It runs fine, but it fails a lot of the unit tests: it seems that some calculations which on Linux return NaN (or -NaN) now return, on OSX, -NaN (or NaN). Can I safely assume that positive and negative NaNs are equivalent and adjust my unit tests to accept either as a success, or is this a sign of something more serious going wrong?

Math dropping random item based on chance

so Im making this game and I want to drop random items, this is what I used to do if(Math.random() > 0.5) //%50 percent chance {//code here } the problem with this method is I will keep adding more and more items to the game, so I want to create more dynamic way, because each time I add an Item I will need to re-type the whole function... not only adding one more if-else statement, but I need to change all the chances in all if statements(the total sum should be 100 in all) any ideas?

Math Is there a way to calculate the number of tries X, who's binomial probability falls on given number CPR? (example inside)

Let's assume we have an event with: number of tries => N = 20 probability of success => p = 0.3 number of successes => X = 0 Probability that the event succeeds X number of times => PR = 0.0007979 (check Binomial Distribution for how the calculation works) So for X=0-20 we will have different probabilities where PR(X=0) + PR(X=1) + ... + PR(X=20) = 1 Now what I would like to do is generate a random number with regards to the binomial distributions Xn, but without calculating all the specif

Math Number Power , multiple of 3

We have a Number N and Cost C,(range N<10^18 ,C<100) Now we have to spend maximum of C rupees to convert the number into another. The rules of conversion of a number to another are as follows: 1)A number can be converted into other number with same number of digits and no leading zeros. 2)The cost of converting a number into other is the sum of absolute difference of corresponding digits. For example, Cost to convert 235 to 331 is 5 (since the absolute difference in corresponding digits

Math Multiple objects triangulation in 3D, intersecting the right vectors (rays)

I am working on a project in which I should be able to triangulate the position of multiple objects when they are seen by (at least) two cameras. Single object Currently I am able to triangulate a single object. This is done in some steps: For every camera, it is calculated the vector pointing to the pixel where object's center lies. This is done by properly rotating the vector pointing at the center of the image (0,0,1) on Y and X axis. Then every direction vector is converted from camera's ow

Math Graph - Dijkstra's algorithm - Tile-based map - Is there "blocking" term in graph?

Let's suppose there is tile-based map. Each tile(vertex) has edges to 8 neighbour tiles. On one of these tiles, there is a wall(which is completly blocking). From mathematical point of view, does it mean that vertex(on which there is a wall): Does not exists? There are no edges to this vertex? Vertex is just blocking - is there this term in graph teory?

Math Program asked in a online hiring challenge

Given N integers in the form of Ai where 1≤i≤N, the goal is to find the M that minimizes the sum of |M-Ai| and then report that sum. For example, Sample Input: 1 2 4 5 Sample Output: 6 Explanation: One of the best M′s you could choose in this case is 3. So the answer = |1−3|+|2−3|+|4−3|+|5−3| = 6. The approach I used is sort the given input and take the middle number as M. But I was not able to solve all the test cases. I am unable to find any other approach for this question. Where did I g

How is a rule in CLIPS mathematically defined?

I am trying to understand the mathematical concepts behind CLIPS programming language and I am not sure how is a rule in CLIPS mathematically defined ? Is it a set ? Does the order of the set matters? Is there any place where I can read more about theoretical concepts of CLIPS language ?

Simple assembly math calculation

Hello I'm trying to calculate simple math function (2c-a)/(c+ax). But for some reason all my answers are 0. Given: a - b, b - w, c - w, x - w, y - b MOV ax, 2 MUL c ; dx:ax=2c JC kl1 ; sandauga netilpo i ax XCHG ax, dx MOV al, a XOR ah, ah ADD dx, ax ; c^2-a JC kl1 MOV al, a MUL x[si] ; a*x JC kl1 ; sandauga netilpo i ax ADD bx, ax ; ax+c JC kl1 CMP al, 0 JE kl2 ; dalyba is 0 MOV ax, dx XOR dx, dx DIV bx ; ax=rez re: Thanks for any ideas.

Math Maxima diff: variable must not be a number; found: 1

sorry for my english,it isn´t my mother tongue.I´m trying to build Newton-Raphson algorithm to numerical resolution of equations and non-linear systems. I have windows 10 and maxima 14.12.1.This is my algorithm: NR(f,a,tol,n):=block( define(k(x),diff(f(x),x)), for i:1 thru n do( b : a - f(a)/k(a), if abs(b-a)<tol then return (float(b)) else a:b ),return (float(a)) ); When i try to evaluate this on this function: g(x) :=x^3 -(3*x^2)*2^(-x)+3*x*4^(-x)-8^(-x)

Math How can I make sure message m ∈ Zp

I am implementing ORUTA and using JPBC library for it. In one of the algorithms, for hashing a message, it is specified that for message m: m ∈ Zp, for some large prime number p.(may be this is equal to m < p) I have a message text, so how can I make sure that the above equation holds true? This question is different from https://crypto.stackexchange.com/questions/44340/how-can-i-make-sure-message-m-%e2%88%88-zp. I want algorithm whose steps I can follow to write the program in java.

Math Split chained integer pairs

I have an array of integer pairs [a, b], e.g [3, 7], [6, 7], [8, 5], [2, 6], [4, 2], [0, 5], [3, 4], [8, 1], [0, 1] These pairs always form chains (closed loops), in this case, there are two of them. The problem is to split given array into n arrays for further graph generation for every chain. [[3, 7], [6, 7], [2, 6], [4, 2], [3, 4]] [[8, 5], [0, 5], [8, 1], [0, 1]]

Math Align IMU orientations and then get relative rotations

I am using two IMUs of the same type (BHI160, i.e. orientation is relative to the north and on alignment with north, the IMU's local y-axis points into the north direction) on two objects, let's say pens, with the added difficulty that if I place the two objects in parallel, both IMUs' z-axes point upwards, but one IMU is rotated 180° around the z-axis relative to the other. Now, if I understand the math here correctly, the quaternion data I receive from an IMU is the half-angle-rotation relati

Math AppleScript to determine if a shape has been warped or scaled

I'm making a script to determine if a shape has been warped or scaled. It starts by making a list of all the lengths of a line in one shape, like so. set noofsides to text returned of (display dialog "Enter number of sides:" default answer "") set sidevalues to {} set repeatnumber to 0 repeat noofsides times set repeatnumber to repeatnumber + 1 set currentsidevalue to text returned of (display dialog "Enter length of line " & repeatnumber & ":" default answer "") set the en

Math Animating a circle of lights

I am trying to create some basic animations for a set of RGB LEDs. Normal linear animations are simple enough using loops and counters to vary the light colour. What I have is a ring of 24 LEDs and want to be able to apply animations to them so that the effect, say a simple colour wipe, occurs from top to bottom, or side to side (basically any given direction). I have not made any progress worth sharing, other than storing an array of each "row" of LEDs: 0 => 0 1 => 1, 23 2 => 2, 22

Math Basic arithmetic giving strange value

I am trying to compute a value which takes the functional form x+10(y+10(z+10(w+10(u+1000v))))). Let's say x = y = z = w = 1, u = 3 and v = 2. Then this should come out to 20031111. I'd like this as a floating point number, not an integer. When I use the code output = x+10(y+10(z+10(w+10(u+1000v))))) I get 20031111 as expected. However, when I use output = 1.0(x+10(y+10(z+10(w+10(u+1000v)))))) I get 20031112.000, which is wrong. What is going on here? By the way, if I pre-multiply by 1.D0

Math Number of pairs of a and b given w

Given two statements 1) w + a = b 2) a & b = 0 (bitwise and) Find the number of pairs of a and b given w. Can someone please help me how should i solve this problem.

Math How to compute the derivative of a function through the Fourier domain?

I am currently working on a project where I have to reconstruct an Image from its gradient by solving a Poisson equation, which we solve in the Fourier domain. The solution involves the product of the image's FT and that of the discrete derivation filter. In the Fourier domain, this is defined as the coordinate-wise product of the two. I understand how the FT of an image is computed, however I have trouble understanding how I should compute that of a filter, as [0 -1 1] for horizontal differen

Math Constraining numbers to a range based on a MASK and a COMPARE register

Recently, I stumbled over the following problem in an embedded software project. I cannot yet figure out, under which conditions there is a unique solution and how it can be found. Let us assume that we have a 16-bit MASK and a 16-bit COMPARE value and we want to set them, such that for a defined range of consecutive IDs {a, ..., b} (e.g. {0x78, 0x79, ..., 0x97}) those IDs satisfy bitwise ID & MASK == COMPARE while IDs outside that range do not satisfy the above equation. As an example:

Math How to raise a power to a power?

I was taught xab = xa*b. why is x21023 * x21023 = x21024 correct? Is x21023 * x21023= x2 *1023 * x2 *1023 = x2046 * x2046 = x2046 + 2046 = x4092 wrong? This is from a RSA cryptosystem lecture on YouTube. Time stamp at 1:08:04 if more context is needed. https://youtu.be/QSlWzKNbKrU?t=4084

Math Division in Projection Matrices

Disclaimer: This question is not the same question as other projection matrix questions. So Projection Matrices are 4x4 Matrices that are multiplied with 4D vectors to flatten them onto a 2D plane. Like this one: 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 But in the explanation, it says that the x and y coordinates of the vector are divided by Z. But I don't understand how this works because each part of the matrix that is multiplied by Z is 0. A comment in another question on this subject said

  1    2   3   4   5   6  ... 下一页 最后一页 共 34 页