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
2 answers

'Less than' comparison with tolerance

I am trying to write some code that computes whether a is less than b with n-bit tolerance, where a and b are double precision variables. For example, 4.000000001 < 4.00000001 would be TRUE, but 4.0000000001 < 4.000000001 would be FALSE. 3.99999999…
0
votes
1 answer

Code in java that will get the numerical value in a textbox?

Is there a way that I can get the numerical value from the textbox? The value in the textbox is in currency form. I want to multiply the value from this but I get an error because there is letters "Php". Can anyone help me with this? Thank you in…
user2059513
0
votes
1 answer

Numerical Recipes v3.0 and pthread library in C++11

If I compile the following code with the command g++ -std=c++11 Threads.cpp -lpthread -I../Libs/nr30, where nr30 is the library provided by http://www.nr.com/, I obtain no errors: #include #include int main(void) { /* ...…
jackb
  • 695
  • 8
  • 26
0
votes
2 answers

MATLAB ODE solver giving 0's everywhere

My code is giving me zeros everywhere for my solution vectors but I don't know why. I've decomposed a coupled second order ODE into 4 1st order ODE's. I have my function defined as xp.m function zprime = f(t,z) a = 1; b = 1; c = 1.5; zprime =…
alvarezcl
  • 579
  • 6
  • 22
0
votes
1 answer

How to handle with sim data by differential equations

I've studied dynamic simulations like planetary or molecular motion. Output data are huge, and saved as text data. Exp. FILE* f = fopen("xyzFile.txt", "w"); for (int i=0;i
akiniwa
  • 617
  • 8
  • 18
0
votes
2 answers

Avoiding rounding errors in a matrix calculation

I have the following very simple code that is supposed to iteratively change the values of a matrix (finalvals)until the row sums and column sums approach certain values (given by b1 and c) - double[] rowsums = new double[3]; double[] colsums…
Rohit Pandey
  • 2,443
  • 7
  • 31
  • 54
0
votes
3 answers

Beginner Python: If-else statements, formatting errors

I am a beginner programmer in python and I need assistance with some code. Attached is the code I have been working on. The purpose is to take a dollar amount like 305.67 and convert the number to a text phrase like "Three Hundred Five Dollars and…
Jr.
  • 111
  • 5
  • 12
0
votes
1 answer

Possible Javascript numerical bug

This code snippet: Math.pow(10,20)+20000 == Math.pow(10,20) + 10000 evaluates to true. Is this a JS bug?
user997712
  • 161
  • 9
0
votes
0 answers

Debugging no-error hang in MATLAB's ode solver

I have a system of ODE's. The ODE takes a couple of seconds to run in a particular parameter range. For another parameter range, however, MATLAB suddenly takes an infinite amount of time to run (well, ok, only tested to half a day). This is a…
0
votes
2 answers

Speeding up Matlab optimizations by CUDA

I was wondering if I can improve the speed of my simulations with CUDA in Matlab by simply breaking up the loop into GPU-threads. So far I have done the loops with mclapply in R, but I was wondering, if I could speed it up in Matlab with CUDA?…
Anim Mina
  • 13
  • 4
0
votes
1 answer

Evaluating Strings with numerical expressions in Perl

Is there a way in Perl to evaluate expressions in string variables ? I am using Perl 5.8 While parsing files, I came across a string like this : var_xx = ((216<<23)|34); I am trying to make a hash table for each variable along with its value. But…
Utkarsh Kumar
  • 567
  • 1
  • 5
  • 17
0
votes
2 answers

Regex in JavaScript to validate both decimal and numerical values

I am working with EXT-JS and am using a VType to specify the regex for a particular field in a form. I need this field to accept values like: 1, 11, 11561.464, 1.0, 56.0, etc and reject values like: .1, 1., 56.(I need my values to start and end with…
ss7389
  • 85
  • 2
  • 12
0
votes
2 answers

Numerical Integration in MatLab

I am trying to compute an integral using Matlab's dblquad. To do it I first wrote a script function. My code is function z = IntRect(x, y) %The variables z0=20; x0=15; y0=20; rl=sqrt(x.^2+y.^2+(z0/2)^2); theta=acos(z0./(2*rl)); phi=atan(y./x); %The…
Thanos
  • 594
  • 2
  • 7
  • 28
0
votes
2 answers

Trapezoidal Numerical Integration in MATLAB without using a FOR loop?

I'm following a Numerical Methods course and I made a small MATLAB script to compute integrals using the trapezoidal method. However my script uses a FOR loop and my friend told me I'm doing something wrong if I use a FOR loop in Matlab. Is there a…
lauziepi
  • 1
  • 1
  • 1
  • 1
0
votes
1 answer

MATLAB; Lagrange Polynomial, an Interesting Error

In my school homework I was given a problem, that required me to calculate Lagrange polynomial. The data set (x,y) involved x = 0,1,2....20, while y = x - 0.3*rand() + 1; Then we were asked to observed Runge's Phenomenon. After that, we were asked…
ponir
  • 447
  • 7
  • 20