FAQ Database Discussion Community


Implementing Euler's Method in python to solve ODE

python,python-2.7,numerical-methods,numerical,differential-equations
I am working on a little science project to simulate a mechanical system with ODE (Ordinary Differential Equation). I would like to use Euler's Method to do so, however I believe that I am doing something work, because the plot that I create of the output data isn't what it...

Numerical integration in R for indicator functions on the unit square

r,integration,numerical
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 functions I am interested...

Numerically listing Arrays

java,arrays,order,numerical
So my code is having a problem. Here's what I want to do: have one array have the original set of numbers (up to 10 numbers) and then copy and paste those numbers onto the second array. And then afterwards, the second area lists those numbers from the first array...

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

java,arrays,numerical
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...

Best way to check if double equals negative infinity in C++

c++,c++11,numerical,numerical-computing
I found this: http://en.cppreference.com/w/cpp/numeric/math/isinf but it appears to check for either positive or negative infinity. I just want to check if a value is equal to exactly negative infinity, or in otherwords is log(0) Thanks for answer! Based on response below, here is some code that shows what works. #include...

Developing a Secant Method Program for root finding

matlab,root,numerical,scientific-computing
So I have been trying to develop a secant method program that can be used for finding the root of f(x) = tanh(x) - (x / 3) However the answer output is nowhere close. Every solution I have found seems a more complex way to solve it. x = 2;...

Excel VBA Run-time error '13' Type mismatch when value isnt numerical

excel,vba,numerical,mismatch
I have the below code that's returning a mismatch error when the value isn't numerical. What would I change? If Sheet3.Cells(4, 8).Value <= 182 Then Call ThreeSpells End If Thanks in advance :)...

Why am I receiving the error that I am multiplying by non-int type 'float'?

python,integer,numerical,runge-kutta
I am having problems with my code which is a Runge Kutta algorithm to numerically solve for a harmonic oscillator. Unfortunately, I am receiving an error that says I can't multiply sequence by non-int of type float. Considering this code is nearly verbatim from an educational text, I cannot see...

How to find the length of a numerical variable using PROC SQL

sql,sas,numerical,string-length,proc-sql
I have a dataset with a column of phone numbers. I want to filter this dataset using PROC SQL WHERE the length of the numbers is at least 7 digits. In normal SQL I can just apply a length function around a number and it works, however in SAS it...

Accuracy issues with multiplication of matrices in Matlab R2012b

matlab,optimization,matrix-multiplication,floating-accuracy,numerical
I have implemented a script that does constrained optimization for solving the optimal parameters of Support Vector Machines model. I noticed that my script for some reason gives inaccurate results (although very close to the real value). For example the typical situation is that the result of a calculation should...

Looking for a particular algorithm for numerical integration

algorithm,numerical-methods,numerical,numerical-integration
Consider the following differential equation f(x) = g'(x) I have a build a code that spits out values of the function f(x) for the variable x, where x goes from 0 to very large. Now, I'm looking for a scheme that will analyse these values of f(x) in order to...

Create an increasing integer alternating sequence in MATLAB / Octave

matlab,octave,numerical-methods,numerical
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 http://oeis.org/A181983, but when I...

How to numerically integrate with infinite limit in MATLAB?

matlab,integration,infinite,numerical
I want to numerically integrate an integral with infinite limit. Does anyone have any idea how should I do that? int(x* exp (v*x + (1-exp(v*x))/v),x, o , inf) does not work. Note that I will have values for v. %n=10; kappa=.5; delta0=.5; Vmax=500; Vdep=2.2; l=2.2; kbT=4.1; %xb=.4; fb=10; k=1; V0=5;...

Numbering Array items numerically

java,arrays,numerical
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...