Category "math"

Find which two angles an angle is between in Python

I have a list of angles (in radians) in the range [-pi, pi]. The angles can be assumed to ordered as follows: every increasing index in the list will be counter

How to Solve Recurrence Relations When Master Theorem is not Applicable

How to mathematically solve the recurrence relations of the following form : T(n)=(2^n)T(n/2) + n^n T(n)=4T(n/2) + n^(2)/logn Is there a generic method to solve

How to Solve Recurrence Relations When Master Theorem is not Applicable

How to mathematically solve the recurrence relations of the following form : T(n)=(2^n)T(n/2) + n^n T(n)=4T(n/2) + n^(2)/logn Is there a generic method to solve

How to calculate a mouse position like 0 will return -8 and 1000 will return 8 number?

As I'm trying to get into animation using a mousemove event I encountered a problem on how to get the specific number with a limit in both left and right direct

How to make MathJax faster?

I was working on a website that contains a lot of mathematical expressions. I use MathJax with React (using 'react-mathjax-preview') but I noticed that renderin

How to get a better approximation of a thick bezier curve?

Let's say I already have a bezier curve approximated by many straight lines (the bezier array in the code), and I would like to draw it with a series of rectang

In C++ printing even, odd and prime number by using for loop and typeinfo method [closed]

I am trying to print even, odd and prime numbers in one program b/w 1 to 1Lac. I have already printed even and odd numbers but don't how to pr

Haskell - Incorrect distance returning from Haversine

I have the code below for calculating the Haversine distance between a list of airports, however it is consistently returning the incorrect value. For example,

How to get numbers to cycle around specific range in JavaScript?

I have this which isn't working, for cycling like 1 2 3 4 5 6 7 8 9 1 2 3 4 ..., cycling between 1 and 9. const cycle = integers => { let i = 0 let x

Simplification code to avoid if else division problem

I would like to make an optimisation by avoiding to use theIf else i used this element because when E = 0in the logic of my probelm B = [0 0 0 0 0]. By consequ

JavaScript exponents

How do you do exponents in JavaScript? Like how would you do 12^2?

The best algorithms to detect continuing decrease pattern on conversion data

I'm tring to use an algorithm for finding and ranking continuing decreases in my data. The base condition: The breakpoint location (blue arrow) is unknown but b

Rotate a Multiple Lines in OpenCV/Python

I have many lines in my opencv, I want to rotate them but Opencv does not have shape rotation functionality. It has image rotation function. I made a rectangle

Rotating an end point while having the direction

I have a point and a direction and I would like to know what that point would be if it was rotated by 45 degrees. For example, if I have Point A being (0, 0, 0)

Find the nth character of an increasing sequence

Recently i saw a competitive coding question, the bruteforce approach doesn't meet the time complexity, Is there any other solution for this, Question: An expan

Trying to use math function: sgn... error : sgn is not declared

hmm... I imported:System.math... test as integer=sgn(100) I get the error: sgn is not declared. Other math functions work. So Why? Might Visual Studio not be

Is floating point math broken?

Consider the following code: 0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 Why do these inaccuracies happen?

How to create TradingView indicators that look like this?

I've been trying to create similar indicator to this This is the reference I have the code for RSI, Stochastic RSI, MACD and 50/100/200 MA (with crosses), but I

How to create TradingView indicators that look like this?

I've been trying to create similar indicator to this This is the reference I have the code for RSI, Stochastic RSI, MACD and 50/100/200 MA (with crosses), but I

E-olymp: Profit. 90% gives, one test wrong answer

Description of my code: For example, take n = 3, and let p [i] be 1 2 3. For beginnings, max = 0. I take in this order the sequences: 1, 1 + 2, 1 + 2 + 3, 2, 2