Found 33676 Articles for Programming

Integrate a Laguerre series over axis 1 in Python

AmitDiwan
Updated on 04-Mar-2022 06:39:27

162 Views

To integrate a Laguerre series, use the laguerre.lagint() method in Python. The method returns the Laguerre series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable. The 1st parameter, c is an array of Laguerre series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.The 2nd parameter, m is an order of integration, must be positive. (Default: ... Read More

C++ program to find length of non empty substring whose sum is even

Arnab Chakraborty
Updated on 04-Mar-2022 06:38:37

135 Views

Suppose we have an array A with n elements. We have to find the length of a non-empty subset of its elements such that their sum is even or return -1 when there is no such subset.So, if the input is like A = [1, 3, 7], then the output will be 2, because sum of [1, 3] is 4.StepsTo solve this, we will follow these steps −n := size of A for initialize i := 0, when i < n, update (increase i by 1), do:    if A[i] mod 2 is same as 0, then:       ... Read More

Integrate a Laguerre series over specific axis in Python

AmitDiwan
Updated on 04-Mar-2022 06:38:05

145 Views

To integrate a Laguerre series, use the laguerre.lagint() method in Python. The method returns the Laguerre series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable.The 1st parameter, c is an array of Laguerre series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index. The 2nd parameter, m is an order of integration, must be positive. (Default: ... Read More

Generate a Vandermonde matrix of the Laguerre polynomial with float array of points in Python

AmitDiwan
Updated on 04-Mar-2022 06:31:19

153 Views

To generate a pseudo Vandermonde matrix of the Laguerre polynomial, use the laguerre.lagvander() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The shape of the returned matrix is x.shape + (deg + 1, ), where The last index is the degree of the corresponding Laguerre polynomial. The dtype will be the same as the converted x.The parameter, x returns an Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array. The parameter, deg is the degree of the ... Read More

Generate a Vandermonde matrix of the Laguerre polynomial in Python

AmitDiwan
Updated on 04-Mar-2022 06:26:57

163 Views

To generate a pseudo Vandermonde matrix of the Laguerre polynomial, use the laguerre.lagvander() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The shape of the returned matrix is x.shape + (deg + 1, ), where The last index is the degree of the corresponding Laguerre polynomial. The dtype will be the same as the converted x.The parameter, x returns an Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array. The parameter, deg is the degree of the ... Read More

C++ program to find string with palindrome substring whose length is at most k

Arnab Chakraborty
Updated on 04-Mar-2022 06:29:01

287 Views

Suppose we have two numbers n and k. Let we are trying to generate a string S with only three types of characters 'a', 'b' and 'c'. The maximum length of a substring of the string S that is a palindrome which does not exceeds k.So, if the input is like n = 3; k = 2, then the output will be "aab", because its length is 3 and the palindrome substring is "aa" with length at least 2. (other answers are also possible).StepsTo solve this, we will follow these steps −S := a blank string j := 0 for ... Read More

Compute the roots of a Laguerre series with given complex roots in Python

AmitDiwan
Updated on 04-Mar-2022 06:25:06

183 Views

To Compute the roots of a Laguerre series, use the laguerre.lagroots() method in Python Numpy. The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex.The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to ... Read More

Compute the roots of a Laguerre series in Python

AmitDiwan
Updated on 04-Mar-2022 06:23:40

352 Views

To Compute the roots of a Laguerre series, use the laguerre.lagroots() method in Python Numpy. The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex.The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to ... Read More

C++ Program to count number of characters to be removed to get good string

Arnab Chakraborty
Updated on 04-Mar-2022 06:23:53

238 Views

Suppose we have a string S. S contains two types of characters in S, the 'x' and 'a'. We have to count what will be the longest string remaining after removal of few characters in S so that it becomes good string. A string is good if it has strictly more than the half of its length filled with character 'a'.So, if the input is like S = "xaxxxxa", then the output will be 3, because if we remove 4 'x's, the string will be "xaa" and this is a good string whose length is 3.StepsTo solve this, we will ... Read More

Generate a Laguerre series with given complex roots in Python

AmitDiwan
Updated on 04-Mar-2022 06:21:51

125 Views

To generate a Laguerre series with given roots, use the laguerre.lagfromroots() method in Python Numpy. The method is a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real. The parameter roots are the sequence containing the roots.StepsAt first, import the required library −from numpy.polynomial import laguerre as LTo generate a Laguerre series with given roots, use the laguerre.lagfromroots() method −j = complex(0, 1) print("Result...", L.lagfromroots((-j, j)))Get the datatype −print("Type...", L.lagfromroots((-j, j)).dtype)Get the shape ... Read More

Advertisements