algebra

Function that check if two algebraic expressions are equal in javascript

社会主义新天地 提交于 2021-02-17 06:06:28
问题 var Answer = '2a + 5b' // downloaded from database var input = '5*b+ 2*a' // user input after calculating some algebraic expression. if (Answer == input){ // tell student he solved the math problem correctly. } I want a function so that the above if-statement return true. My problem is that my answer and user input is a string, and when compared they are not equal. The user however have solved the initial problem correct. 回答1: Even though certain forms of algebraic expressions -such as low

Function that check if two algebraic expressions are equal in javascript

╄→гoц情女王★ 提交于 2021-02-17 06:05:03
问题 var Answer = '2a + 5b' // downloaded from database var input = '5*b+ 2*a' // user input after calculating some algebraic expression. if (Answer == input){ // tell student he solved the math problem correctly. } I want a function so that the above if-statement return true. My problem is that my answer and user input is a string, and when compared they are not equal. The user however have solved the initial problem correct. 回答1: Even though certain forms of algebraic expressions -such as low

Finding the intersection of two lines

孤人 提交于 2021-02-08 11:20:34
问题 I have two lines: y = -1/3x + 4 y = 3x + 85 The intersection is at [24.3, 12.1] . I have a set of coordinates prepared: points = [[1, 3], [4, 8], [25, 10], ... ] #y = -1/3x + b m_regr = -1/3 b_regr = 4 m_perp = 3 #(1 / m_regr * -1) distances = [] points.each do |pair| x1 = pair.first y2 = pair.last x2 = ((b_perp - b_regr / (m_regr - m_perp)) y2 = ((m_regr * b_perp) / (m_perp * b_regr))/(m_regr - m_perp) distance = Math.hypot((y2 - y1), (x2 - x1)) distances << distance end Is there a gem or

How to calculate a rotation matrix in n dimensions given the point to rotate, an angle of rotation and an axis of rotation (n-2 subspace)

泄露秘密 提交于 2021-02-07 07:17:35
问题 I would like to calculate an (nxn) rotation matrix in the n-dimensional space given the following: The point to rotate. An angle of rotation. An axis of rotation (an (n-2) subspace that passes through the origin given by (n-2) unit vectors that span the subspace). the final rotated point. I think that number 4 (the final rotated point) is redundant and it is possible to calculate the rotation matrix without it. But I have them all. Is there a matlab function that already implements it? I know

Finding Intersection of an ellipse with another ellipse when both are rotated

我是研究僧i 提交于 2021-01-29 18:00:13
问题 Equation of first ellipse=> (((x*cos(A)+y*sin(A)-H1)^2)/(a1^2))+(((x*sin(A)-y*cos(A)-K1)^2)/(b1^2))=1 Equation of the second ellipse=> (((x*cos(B)+y*sin(B)-H2)^2)/(a2^2))+(((x*sin(B)-y*cos(B)-K2)^2)/(b2^2))=1 I know that the ellipse will intersect at One Point Two Point Three Point Four Point No intersection at all Is there a general set of equation to solve the same. 回答1: You can transform these equations to general form of conic section: A*x^2+2*B*x*y+C*y^2+D*x+E*y+F=0 and solve system of

Finding the intersect between a quadratic and line

*爱你&永不变心* 提交于 2021-01-29 10:30:55
问题 I am trying to find the intersect between a straight line and a quadratic curve, however the result I am getting appears to be imaginary although I don't see how this can be the case as I can see them intersect on real axes: Import numpy #quadratic coefficients a,b,c = (-3.09363812e-04, 1.52138019e+03, -1.87044961e+09) # y = ax^2 + bx + c #line coefficients m,d = (1.06446434e-03, -2.61660911e+03) #y = mx + d intersect = (-(b-m)+((b-m)**2 - 4*a*(c-d))**0.5)/(2*a) print(intersect) The output of

SAGE: Automorphism group of finite abelian group?

痞子三分冷 提交于 2021-01-28 17:28:37
问题 For a finite abelian group G, say, G = AbelianGroup((4,4,5)) , I want Sage to return the automorphism group of G. Is this implemented? 回答1: You can get it partway easily. G = AbelianGroup((4,4,5)) gap(G).AutomorphismGroup() Group( [ Pcgs([ f1, f2, f3, f4, f5 ]) -> [ f1*f3*f4, f2*f4, f3*f4, f4, f5 ], Pcgs([ f1, f2, f3, f4, f5 ]) -> [ f1*f3*f4, f2*f4, f3*f4, f4, f5 ], Pcgs([ f1, f2, f3, f4, f5 ]) -> [ f1, f2, f1*f2*f3, f2*f4, f5 ], Pcgs([ f1, f2, f3, f4, f5 ]) -> [ f1, f2, f2*f3*f4, f4, f5 ],

Adjacent Neighbor Summation [closed]

柔情痞子 提交于 2021-01-27 14:56:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . Improve this question If I am given the numbers [1,2,1] and I want to find the sum of each number with it's adjacent neighbors (in a ring) repeated a number of times. I can use the following formula: base case: [x=1, y=2, z=1] repeat 7 times. staring with index 0 or (variable x): round 1 index 0: [(x+y+z), y, z]

Does R have a function for the logarithm that deals with negative numeric values?

给你一囗甜甜゛ 提交于 2020-12-15 06:41:41
问题 In mathematics, the exponential and logarithm functions can be generalised from the real numbers to the complex numbers. The exponential function is generalised using Euler's formula and the logarithm is generalised to the complex logarithm. The latter allows inputs that are complex numbers or negative real numbers. Thankfully, the exponential and logarithmic function in R accommodate complex inputs. Both functions can take complex inputs and produce the appropriate exponential or logarithm

Is it possible to solve an algebraic equation in R?

谁说我不能喝 提交于 2020-12-01 10:54:46
问题 I want to find the solution of: -x^3+6*x^2+51*x+44=0 but with R. Is it possible? I found the package Ryacas, but nobody seems to be able to make it work. May sound trivial, but I'm not able to find an easy way to do this... Do you have an alternative? Thanks guys! 回答1: You can use polynom package: library(polynom) p <- polynomial(c(44,51,6,-1)) # 44 + 51*x + 6*x^2 - x^3 solve(p) # [1] -4 -1 11 But you simply can use the function polyroot from base package: polyroot(c(44,51,6,-1)) # [1] -1+0i