Questions tagged [numerical-algorithms]
Questions related to algorithms that use numerical approximations for the problems of mathematical analysis.
153 questions
3
votes
1
answer
404
views
Finding the solution to an equation closest to an arbitrary state
There are a number of numerical methods for finding a solution to an equation that is usually close to the initial guess, but not always the closest. Is there an algorithm that will always find the ...
7
votes
2
answers
3k
views
Numerical methods: why doesn't this python code return 1.0?
I typed the following into the python console:
...
3
votes
0
answers
49
views
Is this approach to generating points for the graph of a function that attempts to avoid discontinuities appropriate?
I'm not sure where to ask this question, I'd appreciate being redirected accordingly if need be.
Context
Let's say I have a program that might plot the graph of functions supplied by a user, for ...
0
votes
3
answers
621
views
Details of sqrt.c library source code
Have seen library code for finding square-root, using the Newton Raphson method.
It uses a table of 256 entries, whose significance is unclear, as the initial guess should be dependent on the quantity ...
0
votes
1
answer
60
views
Hill climbing method searching special polynomial equations
I have system of two polynomial two variables, second order; monomials are {${1,x,y,x^2,xy,y^2}$}
I want find special systems of polynomials: two or more roots in specified range, two root close to ...
2
votes
0
answers
62
views
Alternative parameterizations of the circle
When solving numerical problems with circles, one often has to sample these at numerous points, not necessarily in a uniform way. Evaluating the $(\cos\theta,\sin\theta)$ values can represent a ...
0
votes
0
answers
64
views
What is the quickest algorithm to numerically integrate this function?
Motivation & Question
So I can theoretically build a "computer" to calculate the exact anti-derivative of a particular function.
Using classical calculations and the Robin boundary ...
3
votes
4
answers
378
views
Factor a number in the longest possible product of distinct numbers
I got stuck with quite a simple problem:
Given a positive number $X$ find the largest number $k$, for which exists the positive distinct integers $Y_1,…,Y_k$ such that $(Y_1+1)(Y_2+1)⋯(Y_k+1)=X$
Any ...
4
votes
1
answer
146
views
Bisecting Intervals of floating point numbers containing 0 and infinity fairly
It is seldom considered that floating points are not evenly distributed in the real number line. I've been working with interval arithmetic and noticed when bisecting $[a,b]$ on the real number line ...
3
votes
0
answers
82
views
Computing a series of matrix power - matrix products
Assuming we have two dense matrices $A \in \mathbb{R}^{m\times m}, B \in \mathbb{R}^{m\times n}$, is there a smart way to compute all entries of the series $A^1 B, A^2 B, A^3 B, \dots, A^k B$ up to ...
1
vote
0
answers
34
views
Given constants $c_i$ and $K$, find $b$ numerically such that $b^{c_1} + b^{c_2} + ... + b^{c_n} = K$
Given constants $c_i > 0$ and $K > 0$, find $b > 0$ numerically such that $b^{c_1} + b^{c_2} + \dots + b^{c_n} = K$. I'd like to solve this with a non-iterative method if possible.
My attempt ...
4
votes
2
answers
397
views
Precise algorithm for finding higher order derivatives
I'm trying to make an algorithm that finds the first 10 or so terms of a function's Taylor series, which requires finding the nth derivative of the function for the nth term. It's easy to implement ...
1
vote
1
answer
178
views
How to use Runge–Kutta methods in a second order ODE
Consider a second order equation $F=ma=m\ddot{x}$.
In the language of Euler's method
$\ddot{x}(t+dt)=F(t,x(t),\dot x(t))$
$\dot{x}(t+dt)=\dot x(t)+\ddot x(t)dt$
$x(t+dt)=x(t)+\dot x(t)dt$
Basically, ...
1
vote
1
answer
583
views
fastest way to identify "singular row" of a matrix
Suppose I have a matrix that I know to be singular. This means that there is at least one row in the matrix which is a linear combination of the other rows. What is the fastest way to identify which ...
1
vote
5
answers
5k
views
What algorithm do computers use to compute the square root of a number?
What algorithm do computers use to compute the square root of a number ?
EDIT
It seems there is a similar question here:
Finding square root without division and initial guess
But I like the answers ...
1
vote
1
answer
214
views
Adaptive step size constrained to a limited number of iterations
I'm solving a differential equation on the form $\ddot x = f( \dot x, x)$ on a microchip within a limited (real world) time frame, hence I want to use an adaptive step size to get as good of a result ...
1
vote
1
answer
190
views
Cancellation in C++
I am trying to figure out what the problem with the following expression in C++ is:
y=std::log(std::cosh(x));
My first intention was that there might occure a ...
0
votes
2
answers
120
views
convergence rate of newton's method
So, I'm currently studying Newton method used for finding the 0's of a function, however my professor has only announced that the speed of this algorithm can be more than quadratic, however I'm ...
1
vote
1
answer
74
views
foresightful acceleration and decelerations
I am programming a CNC machine (using matlab). In order to generate a surface with a "high" shape accuracy (order of $1\mu m$) and "small" micro roughness (order of few nm) I need ...
2
votes
1
answer
115
views
O(m+n) Algorithm for Linear Interpolation
Problem
Given data consisting of $n$ coordinates $\left((x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n)\right)$ sorted by their $x$-values, and $m$ sorted query points $(q_1, q_2, \ldots, q_m)$, find the ...
5
votes
5
answers
744
views
fast and stable x * tanh(log1pexp(x)) computation
$$f(x) = x \tanh(\log(1 + e^x))$$
The function (mish activation) can be easily implemented using a stable log1pexp without any significant loss of precision. Unfortunately, this is computationally ...
1
vote
1
answer
459
views
Algorithm to calculate Polylogarithm
In my code i want to solve the Fermi-Dirac-Integral numerically. This can be achieved with a Polylogarithm.
Actually I'm coding in C#, so my function to calculate ...
3
votes
1
answer
1k
views
Robust two lines/segments intersection point in 2D
Given two line segments the problem is to find an intersection point of corresponding lines (assuming that they are not parallel or coincide).
There is a Wikipedia article which gives us exact ...
0
votes
0
answers
23
views
Efficiently populate a look-up table for a function over a range of arguments
I am minimizing a scalar function $f$ which takes a $n$-dimensional vector input and outputs a scalar value. I have code that given an input $x$ will compute the output of $f(x)$ (a scalar), its ...
0
votes
1
answer
109
views
Computing an Expression
I am writing code to evaluate the following expression:
$$ \frac{(a+b+c)!}{a! b! c!} $$
where $a$, $b$ and $c$ are on the range of $10$ to $500$. The result is going
to be a floating point number. ...