Why is my conical/angle gradient image distorted?

I’m currently trying to create a conical gradient, and it kind of works. However, it doesn’t look quite right and I can’t wrap my hand around to why: The line that goes up from the center is slightly …

Unsupported operand types ‘NoneType’

I am very new to Python, and I’m trying to create a software that calculates a series of equations and I keep running into an error. This is the code: import math x_i = 1 dt = 0.01 k = 11.5 r_out = 0….

Unexpected result in the numerical calculation – (invalid value encountered in double_scalar )

from numpy import log as ln z = 3 k = 2 x = 1 – ln(1 + z) / ln(1 + k) y = 1/5 print(“The x=”, x) Q = x**y print(Q) The result is The x= -0.26185950714291484 c:Users-Desktop… …

math module not working in a string for eval

Suppose I have this code: import math import traceback def getValue(s,p,val): d={} for k in range(len(p)): d[p[k]]=val[k] y = eval(s,d) return str(round(y,3)) values = [5,3] …

Adding functions y(x) together in python – impossible?

I’m currently trying to solve an engineering problem where I need to solve relatively long differential equations, for which I’m using the method odeint from scipy. I changed my problem to more easy …

Faster matrix calculation in numpy

Is there some faster variant of computing the following matrix (from this paper), given a nxn matrix M and a n-vector X: ? I currently compute it as follows: #M, X are given as numpy arrays G = np….

Python while loop not working as intended

I don’t know how to get over this problem with while loop. So basically I want to return the number of zeros at the end of a number’s factorial. import math def zeros(n): total_zero = 0 n = …

Smoothing Categorical Output

I have a list of outputs obtained from a cow behavior detection model. Even in a video when a cow is laying, often time it identifies as standing and vice versa. In each video frame, a classification …

Algorithm for integer solutions of a circle?

I am trying to search for integer solutions to the equation: If I search this in wolfram alpha, they are all found almost immediately even for very large n. When I implemented a brute force approach it was very slow: So I assume there is a much faster way to get all of the integer solutions to the equation above. How can I do this in python so that it will have much lower runtime? Note: I have seen this question however it is about finding lattice points within a circle not the integer solutions to the equation of the

How to extract digits from a number from left to right?

I know that I can extract digits from a number from right to left by implementing something like: while (number => 10) digit = number modulo 10 number = number / 10 But is there a way to do …