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.

952 questions
2
votes
1 answer

Conversion from Maxima (Mathematica) to python

Did you know the script (program) that converts the code of Maxima (mathematical formula processing software) to Python? Does Maxima have the ability to convert to Fortran? Since the formula processing software is easy input for fractions, I…
user15181
1
vote
0 answers

Modeling a Daily Target Count Progression with Decreasing Increment Rate

Summary: I'm trying to model a progression for a daily target count that starts at 5,000 on Day 1 and ends at 7,200 on Day 31. The progression should initially have a higher rate of increase, which decreases around the midpoint of the month, and…
L23P
  • 111
1
vote
0 answers

Error in Python code for Schelling Segregation problem

I understand this is more a programming problem but if anyone familiar with the Schellings Segregation problem could help me out with this, I would highly appreciate it. I have a problem where I am supposed to model the Schelling Segregation problem…
Sl30202
  • 11
  • 1
1
vote
1 answer

How to plot $y(x)=4e^{\frac{-118300}{x}}$ in $[3000,25000]$ in python

I am new at python. I found this code for plotting $e^x$ in $[-2,2]$: import matplotlib.pyplot as plt import numpy as np # 100 linearly spaced numbers x = np.linspace(-2,2,100) # the function, which is y = e^x here y = np.exp(x) # setting the…
M.Ramana
  • 2,753
1
vote
1 answer

How to express a Python loop and a condition mathematically?

I have the following Python code that I want to express mathematically. W = 0 for i in range(5): if (A > i_1) and ( (A < i_2) or (A < i_3) ): W = W + 1 This is a generic problem that I am trying to achieve; looping over some values and…
1
vote
3 answers

Probability that rolling dice that two dice sum to X

New here. I'm trying to figure out how to come up with a roll system for a game, where i want the probability of rolling N dice or rolling one dice N times and then taking the two largest outcomes, adding them together and equaling them to some…
0
votes
1 answer

Octal conversion to decimal

How to convert octal to decimal? My code works for integers, such as 25 and 60. But if I let the octal number to be non-integer, the return value truncates the digits after the decimal point. How could I edit this one? import math def…
user1158304
0
votes
0 answers

Is there something unique you can get out of a set of numbers?

I am currently trying to solve a problem with constraint programming. My problem is that for example you need a set of numbers and you can only have a maximum number of 9 with a required length of 6 so you can get something like [1, 3, 4, 5, 6, 8]…
0
votes
1 answer

Adjoint (or transpose) of the Radon transform in scikit-image

I'm trying to implement an optimization algorithm in Python for solving a computerized tomography problem with TV regularization. I know I can use the function "radon" from scikit-image, but the point it that I also need the transpose (or adjoint…
Nabuco
  • 1
0
votes
0 answers

Making an array of part of a vector in numpy

Is there a way to make a Python array in numpy of part of a vector? For example, say I have a vector v of length n, could I make an array of the elements v[2] to v[n-2]? I tried: numpy.array(v[2]:v[n-2]) but this didn't work...
0
votes
0 answers

Define 1D Python list as 1d Vector in Math formulation

In Python I believe a list is considered as a 1 dimensional vector. how do I define a list A = [1, 2, 100, 300] for example whose elements is of set B provided that the element is more than zero: B ={-1, -2, 1, 2, -300, 100, -100, 300} would this…
0
votes
0 answers

Generate random functions following certain constrains (Using python).

How to produce random functions $g:N\times N\rightarrow N$ where $N=\{ 0,1,\ldots ,n \}$ and $$g\Big( g(a,b)\; ,c\Big)=g\Big(a,\; g(b,c)\Big)\quad \forall a,b,c\in N \qquad \text{[Constraint of associativity.]}$$
0
votes
1 answer

Gain function based on Bézier curves

I'm looking for a gain function, for range 0-1, where the output goes from 0-1 but at different pace. Sure there are plenty of Log, Squares, sigmoids, tanhs but I was looking for something more flexible, and the I thought of the Bézier curves, for…
vswers
  • 1
0
votes
1 answer

confusion about differential eq question

i was using sympy to solve Differential eqs this was the code enter image description here what does that C mean in the output and also is the answer right?Im new to solving D.E and im actually clueless where to start with
0
votes
2 answers

Problem related to output in python programming (not gives expected result)

I'm very beginner at python. Given code gives error with output. Want to correct it. The mathematics behind the code is : Let denote $S_m(n)=1^m+2^m+...+n^m$ and denote $D_x(y)$ is sum of digits of $y$ in base $x$. Example $S_2(3)=14$ and…
Pruthviraj
  • 2,707
1
2 3