math

SymPy: Factorization of polynomials over symbolic roots with combined square roots

自作多情 提交于 2020-06-28 03:55:03
问题 SymPy factor function can factorize over symbolic roots, e.g. : In [1]: from sympy import * In [2]: init_printing(use_latex=False) In [3]: z, a, b = symbols('z a b') In [4]: poly = expand((z - sqrt(a))*(z - sqrt(b)), z) In [5]: poly Out[5]: 2 √a⋅√b - √a⋅z - √b⋅z + z In [6]: factor(poly, z) Out[6]: (-√a + z)⋅(-√b + z) but the factorization fails if b = a : In [10]: b = a In [11]: poly = expand((z - sqrt(a))*(z - sqrt(b)), z) In [12]: poly Out[12]: 2 -2⋅√a⋅z + a + z In [13]: factor(poly, z) Out

How to generate a random sample of points from a 3-D ellipsoid using Python?

梦想与她 提交于 2020-06-27 22:58:45
问题 I am trying to sample around 1000 points from a 3-D ellipsoid, uniformly. Is there some way to code it such that we can get points starting from the equation of the ellipsoid? I want points on the surface of the ellipsoid. 回答1: Here is a generic function to pick a random point on a surface of a sphere, spheroid or any triaxial ellipsoid with a, b and c parameters. Note that generating angles directly will not provide uniform distribution and will cause excessive population of points along z

Multivariate Linear Regression in c++ [closed]

谁说胖子不能爱 提交于 2020-06-27 04:49:14
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . Improve this question I have a vector A[a1, a2, a3] and B[b1, b2, b3]. I want to find a "correlation" matrix X (3x3) that can predict from new incoming data of A' to to produce output predictions of B'. Basically in the end: A'*X to get B'. I have lots of recorded data of A and B

How do i make my answer print correctly in java

北战南征 提交于 2020-06-27 04:17:31
问题 I am having an issue where when my program prints (base)^0= , it doesn't print the answer (1) (I shorend down the out put examples as I'm only having an issue with the first line of the output) expected output: 2^0=1 2^1=2 2^2=2*2=4 2^3=2*2*2=8 2^4=2*2*2*2=16 actual output: > 2^0= > 2^1=2=2 > 2^2=2*2=4 > 2^3=2*2*2=8 > 2^4=2*2*2*2=16 code: else if(option == 2){ base = Input.nextInt(); for(int i = 0; i<10; i+=1){ System.out.print(base+"^"+i+"="); for(int j = 0; j < i; j+=1){ if(j != i -1){

Draw small symmetrical arc line path between two markers on world map in Highmaps

主宰稳场 提交于 2020-06-26 12:27:10
问题 I'm using Highmaps to create a flight path chart, using their demo Simple flight routes (jsfiddle) as a starting point. When I update the code to use a world map the line paths between locations/markers become distorted with an exaggerated curve. See my jsfiddle where I have only modified from the demo to the following: HTML <!-- line 5 --> <script src="https://code.highcharts.com/mapdata/custom/world.js"></script> JavaScript // line 39 mapData: Highcharts.maps['custom/world'], // line 47

Split square into small squares

安稳与你 提交于 2020-06-25 21:53:27
问题 I have big square. And I would like to split this square into small squares. I need all possible combinations. I know that there are infinity count of combinations but I have one limitation. I have fixed size for smallest square. I can implement it using brute force. But it is too long. Is any preferable algorithm for this task? Thanks! 回答1: Well this problem only have solution if we made 2 assumptions (otherwise there is infine combinations) 1) the smalest square has a fixed size 2) the way

How to brute force arithmetic puzzle?

这一生的挚爱 提交于 2020-06-24 08:58:32
问题 A friend shared this puzzle: How to make 21 from the numbers 1, 5, 6, 7? You can use the operations of addition, subtraction, multiplication and division, as well as brackets. You must use each number once. I eventually solved it on paper—two days later. No doubt a computer could brute force all solutions in a second. How though? I tried generating all strings a.b.c.d inserting the numbers for letters and operations for dots, but it missed my solution. Bonus puzzles: How to make 11 from 1,5,6

How to find the rotation matrix between two coordinate systems?

爷,独闯天下 提交于 2020-06-24 01:56:10
问题 There are two coordinate systems. We know the 3D coordinates of the origin and the 3D vectors of the axes of the second coordinate system with respect to the first coordinates system. Then how can we find the rotation matrix that transforms the first coordinate system into the second coordinate system? 回答1: The problem described can be solved as follows. Let M = m_11 m_12 m_13 m_21 m_22 m_23 m_31 m_32 m_33 denote the desired rotation matrix. We require 1 0 0 * M + t = x_x x_y x_z 0 1 0 y_x y

Conversion of CIELab to CIELCh(ab) not yielding correct result

懵懂的女人 提交于 2020-06-23 14:46:06
问题 I am having a hard time manually converting CIELab to CIELCh with my calculator. According to http://www.easyrgb.com/en/math.php, the following is a neutral language programming code to get from CIELab to CIELCh by going from radians to degrees: var_H = arc_tangent( CIE-b*, CIE-a* ) //Quadrant by signs if ( var_H > 0 ) var_H = ( var_H / PI ) * 180 else var_H = 360 - ( abs( var_H ) / PI ) * 180 CIE-L* = CIE-L* CIE-C* = sqrt( CIE-a* ^ 2 + CIE-b* ^ 2 ) CIE-H° = var_H And on this website, it

Sin and Cos function incorrect in python [duplicate]

﹥>﹥吖頭↗ 提交于 2020-06-17 15:42:09
问题 This question already has answers here : Unusual Math with incorrect results? [duplicate] (3 answers) Closed 5 years ago . I am trying to make a top down shooter in pygame. I when I added the code to make the player move in the direction they are facing. The player would move in weird directions. This is the code I am using: if pygame.key.get_pressed()[K_UP]: playerX = playerX - math.cos(playerFacing) playerY = playerY - math.sin(playerFacing) if pygame.key.get_pressed()[K_DOWN]: playerX =