540 questions
-3
votes
3
answers
273
views
Taylor Series in Java using float [closed]
I am implementing a method berechneCosinus(float x, int ordnung) in Java that should approximate the cosine of x using the Taylor series up to the specified order.
My questions:
Can I optimize the ...
4
votes
1
answer
135
views
floating-point implementation of a function with removable singularity
Consider the following function:
ƒ(x) = sin(sqrt(x)) / sqrt(x) if x > 0
ƒ(x) = 1 if x = 0
ƒ(x) = sinh(sqrt(-x)) / sqrt(-x) if x < 0
This is an entire function with a Taylor series at 0 of: 1/1!...
8
votes
2
answers
759
views
Sine approximation, did i beat Remez?
First, it is most compact sine approximation ever. It seems i can do better than Remez in terms of precision/performance. Here [0,pi/2] approximation range.
double p[] =
-0.0020836519336891552,
-0....
0
votes
2
answers
156
views
how to approximate 2^x and log2(x) where x is an FP number [closed]
I have 2 approximations for both functions, however the log2(x) takes in an FP number, and outputs a fixed point number; and the 2^x takes in an integer, and outputs a floating point number.
the ...
2
votes
1
answer
163
views
Maximum the sum of lengths of two nondecreasing subsequence of given array
It is a famous question which asked about finding longest nondecreasing subsequence from a given array. The question is well studied and have O(n log n) time complexity solutions.
I have encountered a ...
2
votes
1
answer
97
views
How can I approximate 255/sqrt(x) using Newton's method?
I am trying to approximate 255 / sqrt(x) using Newton's method to avoid using division or the sqrt() operation on an architecture where those operations are expensive.
My derivation is:
y = 255 / sqrt(...
2
votes
2
answers
189
views
Approximating logarithm using harmonic mean
Here is a function to approximate log10(x+1) for (x+1) < ~1.2:
a = 1.097
b = 0.085
c = 2.31
ans = 1 / (a - b*x + c/x)
It should look like that:
It works by adjusting harmonic mean to match log10,...
1
vote
2
answers
186
views
Problem with least squares rational approximation to `asin(x)+ sqrt(1-x^2)` in [3,1] form
I'm trying to generate a decent [3,1] rational least squares polynomial approximation to asin(x)+sqrt(1-x^2) on [0,1] and failing dismally :(
The problem is that it has a pole for this particular ...
1
vote
0
answers
109
views
The efficient approximation algorithm of mandelbrot set?
While implementing the mandelbrot set using java, I found that the rendering time of the program is ridiculously slower than other programs.
public class FractalFormula {
private Complex[] ...
0
votes
0
answers
70
views
Interpolation with function of 3 variables in maple
The value depends on three variables. I have a data set of type [x,y,z,w]. Here x,y,z are the input variables and w is the output result. Can I use maple to find a function that approximates a given ...
1
vote
0
answers
39
views
How can I write the code for optimization problem with adding new constraints that use all optimal solutions in each iteration?
I currently deals with optimization problems with a convex constraint function by cvx.
I consider approximating the function by point-wise maximum function composed of the tangent lines that can be ...
1
vote
0
answers
32
views
Approximating the diameter of a point set
given a set of n points P and a nxn matrix M such that for every two point u,v where M[u,v] is the distance between u and v , and the distance is pseudo metric, is there a property testing algorithem ...
2
votes
2
answers
668
views
Fixing boundary values on a spline?
I have data x and y which are noisy evaluations of a function f:[0,alpha] -> [0,1]. I know very little about my function except that f(0) = 0 and f(alpha) = 1.
Is there any way to enforce these ...
0
votes
0
answers
285
views
Explicit & implicit Euler and trapezoid method of ODE solving in Python
I have a question regarding my code. I have to solve an ODE: [y′(t)=(0.5−t)(y(t) + 1), y(0) = 1], numerically (and approximate), using the explicit and implicit Euler as well as the trapezoid method ...
0
votes
1
answer
51
views
PyTorch: calculating model accuracy for approximation problems
There are some SO posts on calculating accuracy of a classification model in PyTorch, but I how do I calculate accuracy of an approximation model?
For example, for classifications, I can usually count,...
-1
votes
1
answer
70
views
How do i construct a polynomial
How do i construct a polynomial x1*x2*Ai(x1-x2)^n in python, n=6. I need it for approximation. Also I need to extract Ai. x1 and x2 are a set of experimental data.
I don't really know how to do it. I ...
0
votes
0
answers
57
views
Why does the genfit function in mathcad work strangely?
I have a tabular function of two vectors x and y
x y
-5.00000000000000e+000 9.08419036515801e+000
-4.86884290294375e+000 9.18474413956781e+000
-4.86842653120706e+000 9.28030145313736e+000
-4....
1
vote
1
answer
90
views
How to find an Approximate Polynomial using Perceptron
I want to approximate cos(x) from 0 to pi/4 using a quadratic polynomial.
I believe I could train a perceptron using (say 1000) points in my range, with training inputs (x^2, x, 1) and with training ...
1
vote
0
answers
102
views
Computing a piecewise-linear approximation of a function of three variables
Imagine that you have a bunch of points in R3, each with a value (say, temperature). You want to construct a regular grid in R3 and compute a value at each grid point, such that if you then use ...
1
vote
0
answers
92
views
approx function in R is it random?
I'm using approx function on 2 identical list :
unlist(fp_st_4_main[[1]],fp_st_4_main_extr[[1]]) 0.02438017
0.03842975 0.04504132 0.07231405 0.08884298 0.09917355 0.11363636 0.12644628 0.13966942 0....
2
votes
3
answers
376
views
I'm trying to make a while loop that approximates the value of cos(x) so that its to within - or + 1-e10
We must use a while loop to solve this problem (approximating the value of cos to within - or + 1-e10 ) and I believe I have all the right setup but I keep getting the error "missing value where ...
2
votes
4
answers
394
views
Approximating mathematical constant e in Python
I'm attempting to approximate the constant e using 100,000 iterations and display the results where i is in multiples of 10,000 ranging from 10,000 to 100,000.
The code I have is this:
import math
e =...
2
votes
3
answers
152
views
How Fast Can We Approximate Set Jaccard Scores?
I'm trying to compute about 1 trillion different pairwise jaccard scores on a laptop. I'm also not very patient.
Each set tends to contain about 200-800 unique, pseudorandom 32-bit hashes. I've ...
0
votes
1
answer
621
views
Sine curve to fit data cloud using C++
Consider:
Curve fit using Python SciPy
I'm trying to find an algorithm to fit a sine curve into a data set. This is quite simple using Python SciPy, but now I have to bring the whole algorithm to an ...
0
votes
0
answers
70
views
Calculating the length of a cord line based on forces
In 3D, I need to find the cord length based on forces that describe the cord.
I tried to do this, based on the following code with the following inputs:
H the constant horizontal force
q_verti the ...
1
vote
1
answer
198
views
3d triangle approximation with rectangular prisms
I am trying to approximate 3d triangles with rectangular prisms but I cant figure out the math
Im using lua
Ive tried flattening the triangle to a 2d plane and approximating the triangles with normal ...
3
votes
3
answers
202
views
Why does my binary search algorithm miss the optimal solution, and how can it be improved?
I am looking primarily for a theoretical answer, ideally one addressing my misunderstanding (below) about binary search algorithms. Practical examples are welcome as well.
I have a complex function ...
1
vote
1
answer
643
views
Solving a system of matrix equations in Mathematica
I am trying to find a matrix that satisfies six matrix equations.
The equations are as follows:
(Conjugate[ConjugateTranspose[B1]].X.ConjugateTranspose[B1]) == TotalPrB1,
(Conjugate[ConjugateTranspose[...
0
votes
1
answer
252
views
Why my approximation in scipy curve_fit is so bad?
Before approximating the data of my calculations, I decided to test the code on data from Q. Zhang, N. Sabelli, V. Buch; Potential energy surface of H⋅⋅⋅H2O. J. Chem. Phys. 15 July 1991; 95 (2): 1080–...
0
votes
0
answers
188
views
How to perform a linear combination between 2 numpy arrays that approximates a 3rd array?
On paper it seems quite simple so forgive me if I'm missing something obvious.
I've got 2 input arrays X1 and X2 of the same shape, and a target array Y also of the same shape. I'd like to combine X1 ...
0
votes
1
answer
541
views
Nearest Fibonacci sphere points
I have n points on a unit sphere (n up to 10^9). I need to find nearest approximations of these points by n_samples Fibonacci sphere points (n_samples in my case is 65536).
I.e. for each input point, ...
23
votes
3
answers
14k
views
Why does the integer representation of a floating point number offer a piecewise linear approximation to the logarithm?
If you were reading news about developments in graphics in the 1990s, you might have followed Jim Blinn's column in IEEE Computer Graphics & Applications, "Jim Blinn's corner." In the ...
0
votes
0
answers
87
views
Reducing the Number of Passes
Consider the following clustering algorithm in a semi-streaming setting.
Suppose edges of a graph are coming in a stream and the clustering is done in the following way. Here N(u) denotes the ...
0
votes
1
answer
310
views
(Cephes) Approximation of log1p
The Cephes implementation of log1p is described in the documentation as
Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
where P(x) and Q(x) are two polynomials (with Q(x) a monic polynomial.
...
0
votes
1
answer
58
views
Speeding Up Numerical Computation of Double Integral
I am trying to speed up the following code that computes:
where I only need to compute this function for x > y from 0 to 1 (but need very high discretization like dt = 0.001). I have vectorized my ...
1
vote
1
answer
88
views
Comparing the exact and an approximation of the CDF function with R command ecdf
I want to compute the exact and an approximation of the Cumulative Distribution Function for the following density :
f(x)= U(x;-1,2)/2 + U(x;0,1)/2
where U(.;a,b) is the uniform density function on ...
2
votes
0
answers
94
views
A Different version of facility location problem
I posted this question before but since Mathjax is not supported here, I took a picture of the compiled latex file and I am posting a picture of that.
0
votes
1
answer
68
views
how to express Chebyshev sequence constants for function approximations in an interval other than [-1,1]?
To approximate the function with Cheboshev polynomials, it is necessary to operate on the interval [-1,1]. How can these constants be recalculated if I want to approximate on another interval?
...
1
vote
0
answers
69
views
Approximate Counting Algorithm with limited updates / writes
Problem
I want to count the number of page hits that my site gets, without relying on an external service, e.g. countapi.xyz, and without invading user privacy by using Google Analytics.
Idea
...
2
votes
0
answers
111
views
How to make poisson noise from uniform random numbers using central limit theorem? [closed]
Using the fact that Gaussian(λ=σ) is an approximation of Poisson(λ), I want to compute an approximation of Poisson noise using only uniform random numbers without using factorials.
There are two ...
0
votes
1
answer
2k
views
Why is this variable returning 32766?
I wrote a very basic evolution algorithm. The way it's supposed to work is that the user types in the desired value, and the amount of generations to try to reach it. Then, the program will run ...
0
votes
3
answers
554
views
In C language how to calculate the term number of infinite series where we get pi=3.14, pi=3.141,pi=3.1415 and finally pi=3.14159?
The question is: Calculate the value of π from the infinite series. Print a table that
shows the value of π approximated by one term of this series, by two terms, by three terms,
and so on. How many ...
1
vote
2
answers
314
views
Polynomial approximation does not represent accurate approximation of line passing through data points in python
I am working on the task where I have to Augment the data. For data augmentation, I have to do polynomial approximation of the data (Non linear data). But if I do the polynomial approximation, I am ...
0
votes
1
answer
244
views
Using the Eigen library, can I get the kernel of a matrix which only has one "approximately"?
I need to find the kernel (a.k.a. null space) of a 3*3 matrix
which is of full rank 3, but very close to being singular and thus
of rank 2. This means it has no null space unless you look for it
with ...
0
votes
1
answer
57
views
Successive approximation of unkown value
I have a url with a page system.
For instance https://myURL?p=50
But I want a script to find the last page available, for instance, let's say p=187
I have a function checkEmpty() that tells me whether ...
1
vote
0
answers
434
views
How does smoothing in scipy RBFInterpolator work?
I want to approximate scattered 2D data onto a regular grid with slightly bigger dimensions than the surrounding box of scattered data in Python.
My reference is the behavior of the R package mba.
I ...
1
vote
1
answer
179
views
progressive iteration approximation(PIA) method for bspline not working?
I am new to this, and tried to implement this algorithm by using uniform B-Spline. And I don't know where I did it wrong, the result just doesn't come out the way it supposed to be.
I don't know if ...
1
vote
0
answers
176
views
Estimating vertical asymptotes via numerical integration
I am integrating a differential equation with Runge-Kutta 2 method in order to obtain an approximate solution y_n(t), where n is a varying initial parameter. Then, for a sample of n's in a chosen ...
0
votes
1
answer
127
views
Interpolation for finding roots of a numerically integrated function
I am integrating an ODE of the first order of the form $\frac{d}{dr}P(r) = f(r)$ with a Runge-Kutta method of the second order (RK2) and the C programming language. I would like to estimate the first ...
3
votes
1
answer
109
views
what does n^O(1/ε) means?
I often find n^O(1/ε) in approximation algorithms. for example, in euclidean tsp, the number of portals(with its possible state) is equal to n^O(1/ε).
here is the link to the source
http://algo2.iti....