Questions tagged [python]

For mathematical questions about Python; questions purely about the language, syntax, or runtime errors are off-topic here and would likely be better received on Stack Overflow.

Filter by
Sorted by
Tagged with
0 votes
0 answers
27 views

How to numerically solve a second order ODE with only a zeroth order initial condition? [closed]

I am not sure whether wordings in my title are making sense or not. But let me give more details here. Currently, I am trying to numerically solve a second order ode which is $y''=-y+y^3+x$, where $y=...
SCLin's user avatar
  • 1
0 votes
0 answers
40 views

Influence of elements order in Vandermonde matrix on the result of polynomial regression [closed]

Using the definition of polynomial regression coefficients in matrix form, I have a following function: ...
B_Junior's user avatar
-5 votes
0 answers
26 views

Calculate the odds [closed]

Calculate the odds the histogram of the previous exercise was created from a NumPy array ends, that contains $500$ integers. Each integer represents the end point of a random walk. To calculate the ...
Peter Ochola's user avatar
0 votes
1 answer
14 views

Expand product of sums in sympy by introducing new dummy indices

I want to use sympy to simplify some expressions which contain products of sums, this will require expanding out the products and cancelling equal terms. ...
cyfirx's user avatar
  • 35
-1 votes
0 answers
24 views

Find intersection point between line and ellipse [closed]

I am trying to find the point which intersects with the line and the ellipse. I can find the point manually as seen in the code but how can I find it automatically. Also when the red point is inside ...
Blind0ne's user avatar
  • 107
0 votes
0 answers
58 views

Software packages to compute finite type invariants of Polygonal Knots

Assume I have a polygonal knot, $K$, represented as its set of vertices $\{\mathbb{v}_i| \mathbb{v}_i\in\mathbb{R}^3\}_{i=1,...,n+1}$, where $n$ is significant, let's say $100<n<500$. Which ...
guest's user avatar
  • 51
1 vote
1 answer
87 views

Is it possible to extract the translation of an affine transformation matrix independent of rotation center and angle?

I have $2$ images rotated by $60^\circ$ to each other with different center of rotation. The here presented matrices are affine transformation matrices derived from OpenCV: https://docs.opencv.org/4.x/...
TMul's user avatar
  • 13
0 votes
0 answers
19 views

I'm not able to create propper essential matrices and I don't know why

I'm currently trying to generate an essential matrix from two cameras with known parameters. According to Wikipedia this can easily be done by calculating the transformation ($R$, $\vec{t}$) from one ...
RobinW's user avatar
  • 77
0 votes
0 answers
20 views

Bayesian network: how to speed up inference(s)?

I'm experimenting with open-source python libraries that can handle Bayesian networks easily. However the inference is slower compared to the commercial solution (SMILE). One slower inference would ...
bartfer's user avatar
  • 11
0 votes
0 answers
47 views

Black Box Curve Fitting Problem with Extra Layer Between Input and Output Vectors

MAJOR EDIT: I attempted to better describe my problem here. My original post (more or less) is below, if for whatever reason that is needed. $\underline x$ is a linearly spaced vector of arbitrary ...
kriegersan's user avatar
0 votes
3 answers
47 views

Understanding Computer Code to Test for an Injective Function

I'm learning about types of function in discrete maths. I like to learn by exploring concepts through computer code. I came across the following code purporting to determine whether a function is ...
Robin Andrews's user avatar
0 votes
1 answer
65 views

Python code for Second Order ODE Initial Value problem using Finite Difference methods

I am trying to solve the following ODE $$\begin{aligned} & y^{\prime \prime}+2 y^{\prime}+y=0 \\ & y(0)=2 \quad y^{\prime}(0)=-1 \\ & 0 \leqslant x \leqslant 1 \end{aligned}$$ Using ...
Yoshiro's user avatar
0 votes
1 answer
62 views

Simulation of a pendulum on a spinning Disk

I don't know if this is the right place to ask this Question, but I have previously asked a similar question where i asked how to write a simulation on this phenomenon. I got a great answer with a ...
Mo711's user avatar
  • 119
2 votes
0 answers
24 views

Representing a Groebner basis decomposition in sympy

In Sympy package there is Groebner() function, which allows to find a Groebner basis={$g_1, g_2,..., g_k$} for an ideal I, generated by polynomials $\{f_1, f_2,..., f_n\}$. I wonder if there is ...
Dmitri Scheglov's user avatar
0 votes
1 answer
47 views

How to efficiently compute the determinant of a matrix with unknown diagonal entries?

I would like to ask Python to compute the determinant of a large symmetric matrix where all off diagonal entries are known. The diagonal entries could vary. Since I need to compute the determinant ...
dangqingdouna's user avatar
1 vote
0 answers
11 views

Help - How to separate 4th order transfer function (Butterworth Approximation) into 2nd order using Python Control Library?

Previously I had the following coefficients in the program. In this program I want to create a transfer function of butterworth approximation (Figital Filter Fesign - Digital Signal Processing). ...
SKevinAR18's user avatar
0 votes
0 answers
25 views

How to plot two seperate sequences in one plot such that there difference is clear?

Suppose I have two sequences $a_n$ and $b_n$. They both start from a very high number say $25000$ and converges to zero. If I plot them in one plot, as they start from a very large number, the plot ...
Newrion's user avatar
  • 361
0 votes
0 answers
17 views

How do I find linearly dependent groups among vectors?

I have learnt that QR decomposition and RREF can be used to find linearly independent vectors, but now I am confronted with a question that is one step further: How do I find linearly dependent GROUPS ...
张亦弛's user avatar
0 votes
0 answers
25 views

Python sympy: Expressions with an undefined function whose value at zero is known

I'm trying to evaluate an expression in sympy using a function $f(x)$. The function is unknown, but its value at $0$ is known $f(0)=0$. If it's any help, specifically I want to evaluate the Taylor ...
Amir Ban's user avatar
1 vote
0 answers
48 views

Solving a non-linear program using Python

New to optimization, trying to understand the characteristics of a problem I am in the process of modelling, and looking to solve in Python. Given is a decision variable k,the sum of N other decision ...
joachimkristensen's user avatar
0 votes
2 answers
38 views

Turn two ODEs first degree into a Hamiltonian with code

This is more like a coding question, but I thought I'll post it here because of its mathematical foundation. Two ODEs first degree can describe a Hamiltonian System. The connection between the ODEs ...
Mo711's user avatar
  • 119
0 votes
0 answers
31 views

Applying a Vector Field Defined in Cylindrical Coordinates $(r, \phi, z)$ to Points in Cartesian Coordinates $(x, y, z)$

I have written a Python script that defines a meshgrid. The meshgrid represents a 3D grid in Cartesian (x, y, z) coordinates, and for each point, I want to apply a function. After applying the ...
David's user avatar
  • 161
1 vote
0 answers
41 views

pythonic way to sample a point from a hyperplane of an euclidean space.

Consider the 8-dimensional euclidean space $\mathbb R^8$. I denote a point in $\mathbb R^8$ by $$(a_1,a_2,a_3,a_4,b_1,b_2,b_3,b_4)$$ I want to sample a point from a convex subset $S$ of $\mathbb R^8$, ...
govindah's user avatar
  • 107
0 votes
1 answer
46 views

Numerical Inverse Z-Transform - Abate and Whitt

I'm trying to implement an inverse Z-Transform using the Fourier series based technique by Abate and Whitt: The Fourier-series method for inverting transforms of probability distributions. Numerical ...
Tazorraxx's user avatar
2 votes
1 answer
83 views

Confusion about atan vs atan2

I have the following function: $$f(\omega) = \arctan\left(\frac{-\omega\cdot R / L}{-w^2 + 1/(C\cdot L)}\right)$$ When I try to plot it (atan(f(w))), I get the ...
Martel's user avatar
  • 131
0 votes
0 answers
21 views

Normal Distribution parameters with only 30% of the values

For a statistics project, I am seeking a method to determine the most precise parameters for a normal distribution based on a dataset for which I have the following information: The total number of ...
Ruben Sailly's user avatar
-4 votes
1 answer
69 views

Cannot understand the approach of this code [closed]

I wanted to find the properties of a circle from 3 points that are on its circumference, I understand how the problem should be solved, but the provided code after the explanation, does not match the ...
Ahmad Mansoori's user avatar
0 votes
0 answers
17 views

Inconsistencies in time calculations for a Brachistochrone curve with friction

I am trying to find the time taken by a bead to slide down the Brachistochrone curve (between 0,0 and 1,-1) under kinetic friction, but I'm getting inconsistent answers with analytical and numerical ...
Saransh's user avatar
4 votes
3 answers
177 views

Proof for Particular Fair Shuffle Algorithm

I ran multiple simulations of the following function, and it seems to be fair shuffling, given that all permutations were roughly equal, but I don't understand why it works. It's just inserting at ...
Mashiron's user avatar
0 votes
0 answers
78 views

Standard way to do Runge-Kutta (4th order) for coupled ODE's in Python?

I am somewhat familiar with using RK4 for coupled ODE's, I found a very elegant way (in my opinion) to utilize it in Python, like so: ...
Vox Winters's user avatar
0 votes
0 answers
60 views

Help! My System of Linear Equations is on a Rampage - It Won't Follow the Rules! How Do I Tame These Rebel Equations?

Help! My System of Linear Equations is on a Rampage - It Won't Follow the Rules! How Do I Tame These Rebel Equations? Hello, I'm grappling with an intriguing puzzle involving a system of two equations ...
Tobias Schneider's user avatar
0 votes
1 answer
32 views

Imaginary components in Discrete Fourier Transform of Gaussian?

I am trying to understand Discrete Fourier Transform (DFT), after only having experience with the continuous transformation. The natural idea was to try to understand DFT on the simplest function, ...
Szgoger's user avatar
  • 153
0 votes
0 answers
29 views

Need help in comparing two 3D point clouds

I am supposed to take 2 input point clouds and compare them to figure out if there are any differences in them in terms of lets say the location of the components, etc. I thought of doing the feature ...
Ayush Singh's user avatar
-1 votes
1 answer
56 views

How do I solve the following system of 2D pde [closed]

I dont have a background in maths and this is my first time dealing with pdes, trying to solve $$ \begin{matrix} \frac{\partial n_c}{dt} \\ \frac{\partial n_p}{dt} \\ \end{matrix} =\begin{pmatrix} ...
Cal Ng's user avatar
  • 1
0 votes
1 answer
47 views

How do I make the diagonal elements of R in a RQ decomposition positive?

I am using scipy.linalg.rq()to RQ decompose: $$ M = \begin{bmatrix}353.553 & 339.645 & 277.744\\-103.528 & 23.3212 & 459.607\\0.707107 & -0....
Andy's user avatar
  • 845
0 votes
0 answers
37 views

Python Native Implementation of Mixed Integer Linear Programming

Is it possible to have pure Python implementation of Mixed Integer Linear Programming, something similar to mip, pulp, cvxpy, etc. - but such simple as https://github.com/ispaneli/lippy - it is ...
Kamil Islamov's user avatar
0 votes
1 answer
26 views

Calculation of Shortest Paths in a Directed Graph takes much longer than calculating Betweenness Centrality

First of all, I am trying to calculate the Betweenness Centrality of a fully connected directional graph with edge weights with N=3015 nodes. Matlab can do this in about 30 seconds and Python igraph ...
Dom's user avatar
  • 256
0 votes
0 answers
17 views

How to use cumulative distribution functions within an interactive simulator

I am building a simple simulator in python that should simulate an event taking place based on its ...
FTM's user avatar
  • 101
1 vote
0 answers
59 views

Affine transformations. Reflection

I'm trying to develop a programme, which transforms a 2d image. I'm trying to create a simple reflection. Based on a theory affine transformation is determined as follows: Given a transformation ...
Jack Havis's user avatar
2 votes
1 answer
82 views

Defining limit of integral using fractions [closed]

I was trying to derive limit form of integral and I got the below. But I'm not sure what is wrong about it. I learned about it in class today and I'm having all the rectangles under a function summed ...
Coder Gautam YT's user avatar
3 votes
2 answers
774 views

Why does it converges to 1/4 and 3/4 [closed]

I've stumbled upon an "anomaly" in my code (Python). Which one is bigger 2^3 or 3^2. Of course 3^2 beacause it's 9 and the other one is 8. What about 2^4 and 4^2? They're equal. Basically ...
Zoltanocska's user avatar
8 votes
1 answer
298 views

When are $n!+1$ and $(n+2)!+1$ coprime?

For every $n\geq 1$, $n!+1$ and $(n+1)!+1$ are coprime. I suspected the same would happen for $n!+1$ and $(n+2)!+1$, but short Python script yielded 3 counterexamples: $\gcd(7!+1,9!+1)=71$ $\gcd(16!+...
Luca T. Castrillón's user avatar
0 votes
2 answers
64 views

How to numerically approximate solutions to a set of two second order two-variable ODEs using a python script (boundary value problem)?

I have a set of two ODEs like so: $$ \ddot r = \dot \theta^2r \ - \frac{GM}{r^2}$$ $$ \dot r = -\frac {r \ddot \theta} {2 \dot \theta}$$ $\theta$ and $r$ are functions of time, G and M are constants. ...
AtomProgrammer's user avatar
-2 votes
1 answer
73 views

How to parametrize eliptic curve?

def curve(t, radiusX, radiusY): x = sin(t*pi/2) * radiusX y = cos(t*pi/2) * radiusY return (x,y) Following Python pseudo-code will draw a part 1/4 ...
underflow's user avatar
-1 votes
2 answers
96 views

Is it truly random if the outcome of the first coin toss depends on the outcome of the second coin toss? [closed]

I'm trying to understand how randomness in not truly random in the following example: an outcome of a first coin toss (yes/no) is only considered if the second coin toss also comes up 1/0 (1> ...
b0d's user avatar
  • 9
1 vote
1 answer
49 views

The optimal step size in the Lotka-Volterra equations

Given a Lotka-Volterra predator-prey system, $x'(t) = ax - bxy$ and $y'(t) = cxy - dy$, and the initial values (for example, $x(0) = 600$ and $y(0) = 400$), I need to estimate the optimal step size ...
Dhdj Dydys's user avatar
2 votes
2 answers
73 views

can you decompose a polynomial using an approximated zero?

There's this exercise of numerical analysis in which I need to make a function that calculates the zeroes of a second grade polynomial and a function that applies newton's method, afterwards I need to ...
MASSIMILIANO MESSINA's user avatar
0 votes
0 answers
51 views

Nelder-Mead implementation in Python

I am working on a non-linear optimization problem, containing bounds and constraints for the variables. Very complex problem involving networks and logical functions. I have been switching a tool from ...
SebDL's user avatar
  • 131
2 votes
0 answers
80 views

How do I calculate the prediction interval for a data set in python?

I have a data set taken from real measurements that I have modeled with a simple univariate linear regression in python using scipy.stats.linregress, so the model ...
Boone's user avatar
  • 29
0 votes
0 answers
55 views

Problem with data optimization after sum of squared errors in Python

I have a script that allows you to optimize some data (goals from all matches of a football team), after plotting the sum of the squared errors. The aim is to find a final parameter that is more ...
Zollikofen4's user avatar

1
2 3 4 5
20