algebra

Displaying (nicely) an algebraic expression in PyQt [duplicate]

瘦欲@ 提交于 2019-12-10 09:27:27
问题 This question already has an answer here : matplotlib - write TeX on Qt form (1 answer) Closed 4 months ago . In my python program is a hierarchy of mathematical objects I've created, that represent mathematical formulae. For example, there's Collection , which is a series of Equations , which is a container of two Sums , Products , Quotients , Exponants or Logarithms , which are all establishments upon Figures , which can be numerical or variables. I need to display to the user, a step of

Determine if num is a power of two in java? [duplicate]

风格不统一 提交于 2019-12-09 23:20:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to check if a number is a power of 2 How could I write a method that would return true if passed in the value 2, 4, 8, 32, 64, and so on? 回答1: This is probably the best way: ((value & -value) == value) 回答2: Might want to look at this if you need a fast algorithm: http://en.wikipedia.org/wiki/Power_of_two#Fast_algorithm_to_check_if_a_positive_number_is_a_power_of_two 来源: https://stackoverflow.com/questions

Equation Solvers for linear mathematical equations

淺唱寂寞╮ 提交于 2019-12-09 19:06:36
问题 I need to solve a few mathematical equations in my application. Here's a typical example of such an equation: a + b * c - d / e = a Additional rules: b % 10 = 0 b >= 0 b <= 100 Each number must be integer ... I would like to get the possible solution sets for a, b, c, d and e. Are there any libraries out there , either open source or commercial, which I can use to solve such an equation ? If yes, what kind of result do they provide? 回答1: Solving linear systems can generally be solved using

How could I implement logical implication with bitwise or other efficient code in C?

久未见 提交于 2019-12-09 15:48:41
问题 I want to implement a logical operation that works as efficient as possible. I need this truth table: p q p → q T T T T F F F T T F F T This, according to wikipedia is called "logical implication" I've been long trying to figure out how to make this with bitwise operations in C without using conditionals. Maybe someone has got some thoughts about it. Thanks 回答1: FYI, with gcc-4.3.3: int foo(int a, int b) { return !a || b; } int bar(int a, int b) { return ~a | b; } Gives (from objdump -d):

How to determinate round by element in tree (Tournament brackets)?

安稳与你 提交于 2019-12-09 13:48:24
问题 Assume we have following tree: 1 9 2 13 3 10 4 15 5 11 6 14 7 12 8 Where elements(matches): 1-8 is round 1 9-12 is round 2 13-14 is round 3 15 is round 4 How I can determinate round of element "n" in shuch tree? My current formulas are: total_rounds = floor(log(totalTeams,2)); matches_per_round = (totalTeams / pow(2, current_round)) next_match_id = (totalTeams/2) + ceil(match_id/2) total_matches = total_teams - 1 回答1: Imagine the tree was numbered in reverse. 15 7 14 3 13 6 12 1 11 5 10 2 9 4

Simplify Regular Expression in Mathematica

你。 提交于 2019-12-09 04:12:55
问题 I recently found out about Kleene algebra for manipulating and simplifying regular expressions. I'm wondering if this has been build into any computational software programs like Mathematica? It would be great to have a computational tool for doing unions and concatenations of large expressions and have the computer simplify them. If you are not aware of any programs with this algebra built in, do you know any programs that allow extending their engines with new algebras? 回答1: On http://www

Fast multiplication modulo 2^16 + 1

自古美人都是妖i 提交于 2019-12-08 21:01:19
问题 The IDEA cipher uses multiplication modulo 2^16 + 1 . Is there an algorithm to perform this operation without general modulo operator (only modulo 2^16 (truncation))? In the context of IDEA, zero is interpreted as 2^16 (it means zero isn't an argument of our multiplication and it cannot be the result, so we can save one bit and store value 2^16 as bit pattern 0000000000000000 ). I am wondering how to implement it efficiently (or whether it is possible at all) without using the standard modulo

Solving an overdetermined constraint system

荒凉一梦 提交于 2019-12-08 19:12:02
问题 I have n real number variables (don't know, don't really care), let's call them X[n] . I also have m >> n relationships between them let's call them R[m] , of the form: X[i] = alpha*X[j] , alpha is a nonzero positive real number, i and j are distinct but the (i, j) pair is not necessarily unique (i.e. there can be two relationships between the same variables with a different alpha factor) What I'm trying to do is find a set of alpha parameters that solve the overdetermined system in some

minimize euclidean distance from sets of points in n-dimensions

浪尽此生 提交于 2019-12-06 07:50:18
Let's look at m points in n-d space- (A solution for 4 points in 3-d space is here: minimize distance from sets of points ) a= (x1, y1, z1, ..) b= (x2, y2 ,z2, ..) c= (x3, y3, z3, ..) . . p= (x , y , z, ..) Find point q = c1* a + c2* b + c3* c + .. where c1 + c2 + c3 + .. = 1 and c1, c2, c3, .. >= 0 s.t. euclidean distance pq is minimized. What algorithms can be used ? Idea or pseudocode is enough. (Optimizing performance is a big issue here. Monte Carlo method with all vertices and changing coefficients would also give a solution.) We can assume p = 0 by subtracting p from all the other

Books & resources to teach myself Linear Algebra [closed]

纵饮孤独 提交于 2019-12-05 20:50:17
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I'm looking for books and resource to teach myself linear algebra to be used in 3D graphics programming. I prefer practical approaches