Questions tagged [numerical]

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

It includes questions about algorithms, precision and accuracy of underlying numbers, advantages and disadvantages of several methods, error propagation, problems with the underlying numbers and data structures.

508 questions
0
votes
1 answer

Numerical Integration: Trapezium Rule in C

I am trying to integrate the function 1/((1+x)(x^0.5)) between 0 and infinity in C using the trapezium rule. I understand that this is an improper integral and that the trapezium method isnt ideal but its what Ive been told to use. Rather than try…
Charlie
  • 95
  • 1
  • 2
  • 7
0
votes
2 answers

Numbering Array items numerically

Alright, so I tried implementing the bubble sort algorithm into my code, but now my output for the second array (in my code) is giving me a ton of zeros. Can anybody tell me what is wrong with my code and how I can fix it so the zeros are removed…
Jeremy
  • 51
  • 7
0
votes
2 answers

Arrays in numerical order (without importing array.sort() option)

I would like to sort my two arrays in numerical order. So if I input something like: 96 2 1 42 49 5, it'll give me an output of: 1 2 42 49 96. How would you do this using a for-loop? I'm trying to implement a basic for-loop to get my numbers to…
Jeremy
  • 51
  • 7
0
votes
0 answers

Matlab FindPeaks is oversensitive

I'm using Matlab's findpeaks function for finding local maxima's in a 1d array. My aim is to count the number of maximas, and that's where I encounter problems. findpeaks() is just too sensitive. For instance, try this v=[3.6107,3.6109,…
Amir Sagiv
  • 376
  • 5
  • 23
0
votes
1 answer

How to define floating point constants within template. Avoid casts at run-time

Say I have a simple function that does something like this: template T get_half(T a){ return 0.5*a; } this function will typically be evaluated with T being double or float. The standard specifies that 0.5 will be a double (0.5f…
Alejandro
  • 1,064
  • 1
  • 8
  • 22
0
votes
2 answers

Numerical integration in R for indicator functions on the unit square

I am trying to write a simple routine for obtaining the measure of certain regions in the unit square (two dimensions) I know I could use one of the standard num. integration functions but I wanted to try and optimize my code since the class of…
Moritzplatz
  • 123
  • 4
0
votes
2 answers

Create an increasing integer alternating sequence in MATLAB / Octave

I'm trying to find a way to create a number pattern like the one below 0,1,-2,3,-4,5.... Please note: it needs to go to 200000, but I will be splitting them up into groups of 2000. I found a formula that looks like it would work on…
Rick T
  • 3,349
  • 10
  • 54
  • 119
0
votes
1 answer

C++ numeric code (using Eigen) surprisingly slow

I'm a physicist used to writing code in MATLAB / Python / Julia, considering using C++ for some performance sensitive code. I've written one of the most performance sensitive functions currently of interest to me - the computation of the…
user13492
  • 87
  • 4
0
votes
1 answer

Need help solving numerical ODE [Python]

I have a physics problem and have never used odeint or any numerical solving for ODE on python and am a little confused. I tried looking at other examples but could not understand and am hoping for a little help. My ODE is: Where α is a given angle…
GlassSeaHorse
  • 429
  • 2
  • 7
  • 14
0
votes
3 answers

How do I calculate radius of curvature from discrete samples?

I've got a series of (x,y) samples from a plane curve, taken from real measurements, so presumably a bit noisy and not evenly spaced in time. x = -2.51509 -2.38485 -1.88485 -1.38485 -0.88485 -0.38485 0.11515 0.61515 1.11515 1.61515 ... y…
John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110
0
votes
0 answers

Parallel ellisoid projection onto a plane, numerical method

I am having the following problem. I need to find the contour points of a ellipsoidal rotated body on the xy-plane (see image for more detail). Now, I have found the analytic solution to this problem (using this method). However, due to the use of…
Diederik
  • 83
  • 1
  • 1
  • 9
0
votes
1 answer

How to use a wrapper function that i generated using swig in python?

Okay, I am new to swig. I have finally successfully wrapped the most expensive part of my python program using swig and also numpy.i . The program is a finite difference scheme for the 2D wave PDE . My question is how do I use it now ? I can see it…
bluerubez
  • 300
  • 2
  • 14
0
votes
1 answer

Numerically compute a function that is almost 1

So my fellow numerical computational peeps it may be that I am suffering from sleep deprivation but I'm struggling to numerically compute a function x-> u(x) defined implicitly as follows: x^h(x) + x^-h(x) = a x To be clear, that's just saying x…
Quant
  • 4,253
  • 3
  • 17
  • 15
0
votes
1 answer

Efficient computation of an implicitly defined function

I have a scalar function f(u) defined implicitly as follows: pow( u, -f(u) ) + pow( u, f(u) ) = u The function is approximately 1, but evidently not quite so. I am scratching my head for an efficient means of numerically computing values of this…
Golf Monkey
  • 175
  • 2
  • 7
0
votes
0 answers

Matlab system of ODE numerical answer also weird graphs

I have 2 problems. I need the final values of the ODEs, and I don't know why my graphs look so square. I've tried changing the xaxis scaling. Any help would be great. Most info I've found online seems to be dealing with a single ODE, and I'm not…