algebra

What is a formula to get a vector perpendicular to another vector?

自作多情 提交于 2019-11-30 13:45:05
What is a formula to get a three dimensional vector B lying on the plane perpendicular to a vector A? That is, given a vector A, what is a formula f(angle,modulus) which gives a vector that is perpendicular to A, with said modulus and rotated through an angle? If the two vectors are perpendicular then their dot product is zero. So: v1(x1, y1, z1), v2(x2, y2, z2) . => x1 * x2 + y1 * y2 + z1 * z2 = 0 You know (x1, y1, z1) . Put arbitrary x2 and y2 and you will receive the corresponding z2 : z1 * z2 = -x1 * x2 - y1 * y2 => z2 = (-x1 * x2 - y1 * y2) / z1 Be aware if z1 is 0 . Then you are in the

How can I remove a column from a sparse matrix efficiently?

 ̄綄美尐妖づ 提交于 2019-11-30 13:13:00
问题 If I am using the sparse.lil_matrix format, how can I remove a column from the matrix easily and efficiently? 回答1: I've been wanting this myself and in truth there isn't a great built-in way to do it yet. Here's a way to do it. I chose to make a subclass of lil_matrix and add the remove_col function. If you want, you can instead add the removecol function to the lil_matrix class in your lib/site-packages/scipy/sparse/lil.py file. Here's the code: from scipy import sparse from bisect import

Scientific Programming with Ruby

南楼画角 提交于 2019-11-30 07:19:16
I was doing the mathematical calculations with python or octave because of availability of really nice functions and libraries at hand. But recently I gained interest in ruby and I wonder if there is an equivalent in Ruby to the numpy, scipy in Python for scientific programming. Specifically, I'm looking something that I can draw plots as in matplotlib and do mathematical, algebraic calculations quickly as in numpy and scipy. Linear algebra is at the heart of most large-scale scientific computing. LAPACK is the gold standard for linear algebra libraries, first written in FORTRAN. There's a

Java/Scala library for algebra, mathematics [closed]

蹲街弑〆低调 提交于 2019-11-29 20:42:44
Can you advise me some flexible and powerful, yet fast library which could cover SciPy (both in performance and functionality). I found SciPy very expressive - but I want to try something in Scala. I read a little about Scala - but is not as featured as SciPy. Any alternatives? Maybe Java library? The functionality in Scipy is rather Matlab-like. So the question is whether you just want the core linear algebra / vector-matrix mathematics operations, or all sorts of things like clustering. If you are not aware of both Scalala (now called Breeze ) and ScalaLab , you should check them out--maybe

What is a formula to get a vector perpendicular to another vector?

好久不见. 提交于 2019-11-29 19:05:16
问题 What is a formula to get a three dimensional vector B lying on the plane perpendicular to a vector A? That is, given a vector A, what is a formula f(angle,modulus) which gives a vector that is perpendicular to A, with said modulus and rotated through an angle? 回答1: If the two vectors are perpendicular then their dot product is zero. So: v1(x1, y1, z1), v2(x2, y2, z2) . => x1 * x2 + y1 * y2 + z1 * z2 = 0 You know (x1, y1, z1) . Put arbitrary x2 and y2 and you will receive the corresponding z2

I'm curious if Logic Programs can do algebra

↘锁芯ラ 提交于 2019-11-29 18:12:08
问题 I read a brief article about Prolog and Logic Programming. I'm curious if Logic Programs can do algebra. Like would you be able to ask what the Variable of X is in the equation 5+X = 7 and get an answer of -2? 回答1: All serious Prolog systems provide constraint logic programming over finite domains, called CLP(FD) for short, with which you can solve many such equations easily. For example, with SICStus Prolog, SWI and Yap: ?- use_module(library(clpfd)). true. ?- 5+X #= 7. X = 2. Apparently,

Scientific Programming with Ruby

喜你入骨 提交于 2019-11-29 09:27:28
问题 I was doing the mathematical calculations with python or octave because of availability of really nice functions and libraries at hand. But recently I gained interest in ruby and I wonder if there is an equivalent in Ruby to the numpy, scipy in Python for scientific programming. Specifically, I'm looking something that I can draw plots as in matplotlib and do mathematical, algebraic calculations quickly as in numpy and scipy. 回答1: Linear algebra is at the heart of most large-scale scientific

Is there an expression using modulo to do backwards wrap-around (“reverse overflow”)?

流过昼夜 提交于 2019-11-28 18:49:24
For any whole number input W restricted by the range R = [ x , y ], the "overflow," for lack of a better term, of W over R is W % (y-x+1) + x . This causes it wrap back around if W exceeds y . As an example of this principle, suppose we iterate over a calendar's months: int this_month = 5; int next_month = (this_month + 1) % 12; where both integers will be between 0 and 11, inclusive. Thus, the expression above "clamps" the integer to the range R = [0,11]. This approach of using an expression is simple, elegant, and advantageous as it omits branching . Now, what if we want to do the same thing

Sign of a symbolic algebraic expression

久未见 提交于 2019-11-28 11:36:04
Is there any algorithm that can find the sign of an arbitrary symbolic algebraic expression given in a "Tree - Form"? I know that a general algorithm doesn't exist because the zero recognizion problem is undecidable for an arbitrary expression, but how should I approach the problem of finding the sign of an expression? (how is this done in computer algebra?) For example: sign(sqrt(2)-1) = ? Evaluate the function value You need function evaluator engine for that (it is not that hard to code) there is no way to evaluate sign only if you want to support +,- operations !!! All my function

What's the opposite of JavaScript's Math.pow?

你离开我真会死。 提交于 2019-11-28 08:12:34
I'm having a mental block here, and algebra not really being my thing, can you tell me how to re-write the JavaScript code below to derive the variable, c , in terms of a and b ?: a = Math.pow(b, c); c = ? Thanks! c = Math.log(a)/Math.log(b) Logarithms. You want the logarithm of a. B is the base, c is the exponent, so log b a = c 来源: https://stackoverflow.com/questions/4016213/whats-the-opposite-of-javascripts-math-pow