You have several issues that you need to fix to make your program run: You have forgotten to copy array1 into array2: The output that you think is coming from sorting array2 is actually from the process of sorting. int[] array2 = new int[i]; for (int j = 0; j...

matlab,integration,infinite,numerical

Assuming the question is about this full code: syms x; v = 1; % For example int(x*exp(v*x + (1-exp(v*x))/v),x, 0, Inf) and the issue is that it returns itself (i.e., int doesn't find an analytic solution), one can set the 'IgnoreAnalyticConstraints' option to true (more details) to get a solution:...

If you have an unknown number of lines of varying format before the info you want, probably the easiest way is along these lines 1) Use fgetl to fetch lines one at a time (obviously if you know you can safely skip the first 3000 lines or whatever, do so)...

math,numerical-methods,raytracing,numerical,embree

I think a lot of the problem is using single precision float rather than double precision. Define two functions double dsqr(double x) { return x*x; } double ddot(const Vec3fa &a,Vec3fa &b) { double x1 = a.x, y1 = a.y, z1 = a.z; double x2 = b.x, y2 = b.y, z2...

c++,performance,numeric,eigen,numerical

First of all, make sure you benchmarked with compiler optimizations ON, aka Release mode in visual studio. Second, what's the purpose of the outer_product_3d function, why not doing rvec*rvec.transpose()? Finally, you can significantly reduce the operation count as follows: rpy.block<3,3>(3 * (i + 1) - 3, 3 * (j +...

Something like this Dim MyVar, MyCheck MyVar = Sheet3.Cells(4, 8).Value MyCheck = IsNumeric(MyVar) 'Returns True If MyCheck = True Then If Sheet3.Cells(4, 8).Value <= 182 Then Call ThreeSpells End If Else 'msgbox or what you want End If ...

What about this? $ sort -rn -k1 -k2 file 12364 257363 12364 246291 12364 243701 12364 243699 12364 2895 12363 222222 12363 111111 12363 3456 Note that -k1 -k2 is not the same as -k1,2....

GSL seems to have it: https://www.gnu.org/software/gsl/manual/html_node/Dilogarithm.html gsl_sf_dilog.h double gsl_sf_dilog (double x) int gsl_sf_dilog_e (double x, gsl_sf_result * result) int gsl_sf_complex_dilog_e (double r, double theta, gsl_sf_result * result_re, gsl_sf_result * result_im) ...

Using Bubble Sort. You will be required to use 2 for loops. Complexity of bubble sort is O(n2) package com.*; import java.util.Scanner; public class Sort { public static void main(String[] args) { int n, c, d, swap; Scanner in = new Scanner(System.in); System.out.println("Input number of integers to sort"); n =...

Roger Stafford gave some MATLAB code here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/152405 Which I verbosed a bit to make this function: # given a load of points, with x,y coordinates, we can estimate the radius # of curvature by fitting a circle to them using least squares. function [r,a,b]=radiusofcurv(x,y) # translate the points to...

matlab,octave,numerical-methods,numerical

Method #1 - Using (-1)^x Just use a linear increment operator to go from 0 to 200000 and multiply the sequence by (-1)^(x+1) to allow the sign of the sequence to alternate: x = 0:200000; y = ((-1).^(x+1)) .* x; The addition of the +1 is important so that the...

Copy your array1 to an array2 of the correct length before sorting, something like for (i = 0; i < 10; i++) { System.out.println("Input a number for " + (i + 1) + ": "); int input = scan.nextInt(); if (input == -9000) { break; } array1[i] = input; }...

matlab,optimization,matrix-multiplication,floating-accuracy,numerical

Do you use format function inside your script? It looks like you used somewhere format rat. You can always use matlab eps function, that returns precision that is used inside matlab. The absolute value of -1/18014398509481984 is smaller that this, according to my Matlab R2014B: format long a = abs(-1/18014398509481984)...

c++,c++11,numerical,numerical-computing

x == -1.0 / 0.0 This expression evaluates to true iff x is negative infinity. If you are willing to include cmath, then x == - INFINITY is more readable. Assuming that floating-point types are mapped to IEEE 754 formats, then each of them has its own infinity. 1.0 /...

android,keyboard,show,numerical

You may use TYPE_CLASS_PHONE, it adds some symbols (#+.), spaces and backspaces. More infos here: http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_PHONE...

Try this... set.seed(42) df0 <- data.frame( X = rnorm(100,10,10), Y = rnorm(100), Z = rnorm(100)) df0$seq <- as.integer(df0$X) library(data.table) dt = data.table(df0) dt[,lapply(.SD, sum), by=seq ] seq X Y Z 1: 23 164.8144774 1.293768670 -3.74807730 2: 4 8.9247301 1.909529066 -0.06277254 3: 13 40.2090180 -2.036599633 0.88836392 4: 16 147.8571697 -2.571487358 -1.35542918...

matlab,root,numerical,scientific-computing

You suppose to add up terms so replace minus in this line: x = x - (tanh(x)-(x/3))*((x-(prevx))/((tanh(x)-(x/3))-(tanh(prevx))-((prevx/3)))); To a plus: x = x + (tanh(x)-(x/3))*((x-(prevx))/((tanh(x)-(x/3))-(tanh(prevx))-((prevx/3)))); To get a desired result of 2.987 for x. Also remove x before the end of the loop. ...

jquery,variables,parameters,numerical,gridster

The problem is that your height variable is not visible inside the scope of your handler2 function because it was declared inside handler1, you could pass it as a parameter to handler2 as follows: //Resize widget on handler click function handler1() { var height = $(this).parent().parent().attr( "data-sizey" ); // console.log(height,...

From the little testing I've done, you may well be best off using the adaptIntegrate function in the cubature package, as that is written in C. Otherwise, if you can change your function from returning vector values to separate inputs for x and y, you may be best off using...

One way is to add 0.5 and then floor. If you use floor, don't forget to add -lm to your compile line. uint8_t b = floor(a + 0.5); As Jerry Jeremiah mentioned, direct assignment with a cast should also work. uint8_t b = (uint8_t) (a + 0.5); ...

algorithm,numerical-methods,numerical,numerical-integration

numerical integration always return just a number if you do not want the number but function instead then you can not use numerical integration for this task directly Polynomial approach you can use any approximation/interpolation technique to obtain a polynomial representing f(x) then integrate as standard polynomial (just change...

python,integer,numerical,runge-kutta

I'm willing to bet the problem is that you're mixing up NumPy arrays and normal Python lists. You're using NumPy arrays all over your code. These know how to do all kinds of cool things, like element-wise operations. For example: >>> a = np.array([1, 2, 3, 4]) >>> a *...

plot,integration,numerical,maple

I don't know what you mean by "avoid the singularity". Your function is singular at t=0, and there's no way to change that. Just don't try to evaluate it at 0. Your other problem is caused by trying to differentiate with respect to a number. What you need to do...

python,python-2.7,numerical-methods,numerical,differential-equations

Using Euler for mechanical systems is in general a bad idea. The easiest test case to explore this statement is the simple oscillator x''+x=0 where you will find that the energy of the system grows rapidly. For a general mechanical system you have an equation of motion m*x'' = F(t,x,x')....

sql,sas,numerical,string-length,proc-sql

Since you have not posted the sample dataset , so I have created one for myself Creating the sample dataset. Taking phonenum as numeric same as in your case. data test; infile datalines; input phonenum : 8.; datalines; 123 1234 12345 123456 1234567 12345678 123456789 12345678910 ; run; You are...