Regular expression to match digits and basic math operators

I need a regular expression that will match 0-9, (,),+,-,* and /.

Why doesn't Python have a sign function?

I can't understand why Python doesn't have a sign function. It has an abs builtin (which I consider sign's sister), but no sign. In python 2.6 there is even a copysign function (in math), but no...

Drawing Collision on Screen

And here we are for another question. After the previous one, i finally completed the kDop system and everything related. (Hierarchycal tree of kDop, etc..) Everything works fine. Now i want to...

3D Trilateration using given distances of unknown fixed points

I am new to this forum and not a native english speaker, so please be nice! :) Here is the challenge I face at the moment: I want to calculate the (approximate) relative coordinates of yet unknown...

Extracting Yaw from a Quaternion

I have a rotation quaternion and want to extract the angle of rotation about the Up axis (the yaw). I am using XNA and as far as I can tell there is no inbuilt function for this. What is the best...

What are the mathematical/computational principles behind this game?

My kids have this fun game called Spot It! The game constraints (as best I can describe) are: It is a deck of 55 cards On each card are 8 unique pictures (i.e. a card can't have 2 of the same...

Alternative to if(x >= 200 && x <= 299)?

In PHP (or any similar language), is there a better alternative to: if(x >= 200 && x <= 299){ return 'ok'; } My goal is to validate if a number is in the range of the 2xx code (for HTTP...

How do I get the decimal places of a floating point number in Javascript?

What I would like to have is the almost opposite of Number.prototype.toPrecision(), meaning that when i have number, how many decimals does it have? E.g. (12.3456).getDecimals() // 4

How do I calculate square root in Python?

Why does Python give the "wrong" answer? x = 16 sqrt = x**(.5) #returns 4 sqrt = x**(1/2) #returns 1 Yes, I know import math and use sqrt. But I'm looking for an answer to the above.

Using a Naive Bayes Classifier to classify tweets: some problems

Using, amongst other sources, various posts here on Stackoverflow, I'm trying to implement my own PHP classier to classify tweets into a positive, neutral and negative class. Before coding, I need...

Python cos(90) and cos(270) not 0

What is going on?? Testing out sin and cos functions to find out why I get so beautiful positioning on the wrong places when outputting my coordinates into a SVG file. So I made this test code,...

calculating the point of intersection of two lines

I have dynamically generated lines that animate and I want to detect when a lines hits another. I'm trying to implement some basic linear algebra to obtain the equation of the lines and then...

Finding out nth fibonacci number for very large 'n'

I was wondering about how can one find the nth term of fibonacci sequence for a very large value of n say, 1000000. Using the grade-school recurrence equation fib(n)=fib(n-1)+fib(n-2), it takes...

How to find the number of values in a given range divisible by a given value?

I have three numbers x, y , z. For a range between numbers x and y. How can i find the total numbers whose % with z is 0 i.e. how many numbers between x and y are divisible by z ?

Points of intersection of vector with cone

I have a Vector A defined as : (Ao+t∗Ad) I also have a Cone with vertex (cone tip) V, axis direction D, base radius R and height H. How can I find the points of intersection between the vector...

How to name value with range of 0.0 to 1.0?

Quite often I use values between 0.0 and 1.0 to hold progress, or transparancy, or other things that can go from none to full. A percentage if you will. I don't want to call it a percentage...

PIL "ValueError: image has wrong mode" when resizing an image

I am working in Blender and so I wanted to use a bump map I found on the internet. The image is here. However, when I tried to use it, Blender crashed. I am assuming that happened because of the...

Pagerank probability converging to zero?

I'm attempting to code the pagerank algorithm from scratch, so far I have constructed the stochastic matrix G and now I am trying to find the limiting probability. The limiting probability is...

Shear (Skew) transformation along arbitrary direction in 2d

I need to skew a 2d polygon shape in arbitrary direction (2d). Doing it in X axis looks like this: float skewAngle; glm::mat4 skewMatrix; skewMatrix[1][0] = ...

why I am getting "SCRIPT5021: Invalid range in character set" and blank screen in IE11?

I am using Angular 9, All code is working fine in chrome but not in IE11 , I am no where using any Regex and mostly I am using back tics. Below error is coming in Polyfills-es5.js as on page...

Is there a way to import compare_ssim for python IDLE?

I tried running the python code in IDLE to import compare_ssim with this command line, from skimage.measure import compare_ssim: code for importing compare_ssim from keras.layers import Input,...

How to calculate Mean Absolute Error (MAE) and Mean Signed Error (MSE) using pandas/numpy/python math libray?

I have a dataset like below. In this dataset, there are different colored thermometers, and given a 'True' or reference temperature, how different they measure according to some measurement...

Is it possible to make a native in pure Java using python?

Using JNI, or Java Native Interface, it is possible to use c++/c types and functions in Java. I want to do something similar with Python. There are many libraries for executing Python code from...

Verify/Publish Smart Contract on Etherscan Rinkeby

I am attempting to Verify and Publish a smart contract that I have deployed to the rinkeby network using hardhat and hardhat-etherscan. When I am running the verify script I am getting an error. I...

How do I set the precision of a float variable in c++

It will print 88.89 to the console because, 88.888 with a hundredths place rounding precision equals 88.89. How do I make "b" equal to the value of "a" rounded to the hundredths place. (e.g....

Function to make a list as unsorted as possible

I am looking for a function to make the list as unsorted as possible. Preferably in Python. Backstory: I want to check URLs statuses and see if URLs give a 404 or not. I just use asyncio and...

Convert GPS Coordinates to Match Custom 2d outdoor layout Image

I don't know if this is possible, but I am trying to take the image of a custom outdoor football field layout and have the players' GPS coordinates correspond to the image xand y position. This...

screenPointToWorld in processing

I would like to draw where something where the mouse is, after a set of transformations. It is not about the drawing itself, it's getting the point in xyz when a certain transformation is applied....

How to get sufficient entropy for shuffling cards in Java?

I'm working on a statistics project involving cards and shuffling, and I've run across an issue with random number generation. From a simple bit of math there are 52! possible deck permutations,...

Why my natural log function is so imprecise?

Firstly, I'm using this approximation of a natural log. Or look here (4.1.27) for a better representation of formula. Here's my implementation: constexpr double eps = 1e-12; constexpr double...