cubic

Why am I receiving a “no ordering relation defined for complex numbers” error?

梦想与她 提交于 2019-12-31 00:45:09
问题 See this question for some background. My main problem on that question was solved, and it was suggested that I ask another one for a second problem I'm having: print cubic(1, 2, 3, 4) # Correct solution: about -1.65 ... if x > 0: TypeError: no ordering relation is defined for complex numbers print cubic(1, -3, -3, -1) # Correct solution: about 3.8473 if x > 0: TypeError: no ordering relation is defined for complex numbers Cubic equations with one real root and two complex roots are receiving

How to solve cubic equation analytically (exact solution) in R?

ぐ巨炮叔叔 提交于 2019-12-25 05:18:19
问题 I'm trying to get solution of cubic equations analytically in R, not numerically. I looked up on the internet and get the formula for cubic roots and wrote the following code: The link is: http://www.math.vanderbilt.edu/~schectex/courses/cubic/ cub <- function(a,b,c,d) { p <- -b/3/a q <- p^3 + (b*c-3*a*(d))/(6*a^2) r <- c/3/a x <- (q+(q^2+(r-p^2)^3)^0.5)^(1/3)+(q-(q^2+(r-p^2)^3)^0.5)^(1/3)+p x } However this function doesn't work in most cases and I guess it's because of the power of negative

Extract TCP round trip time (RTT) estimations on linux

白昼怎懂夜的黑 提交于 2019-12-19 17:12:05
问题 I have apache server running on Ubuntu. Client connects and downloads an image. I need to extract RTT estimations for the underlying TCP connection. Is there a way to do this? Maybe something like running my tcp stack in debug mode to have it log this info somewhere? Note that I don't want to run tcpdump and extract RTTs from the recorded trace! I need the TCP stack's RTT estimations (apparently this is part of the info you can get with TCP_INFO socket option). Basically need something like

CUDA: 1-dimensional cubic spline interpolation in CUDA

戏子无情 提交于 2019-12-14 03:42:29
问题 I'm making a medical imaging equipment. I want to use CUDA for making faster equipment I receive 1024 size 1d data from CCD 512 times. before I perform IFFT I have to apply high performance interpolation algorithm (like cubic spline interpolation) to the 1024 size data each (then 1d interpolation 512 times). Is there any CUDA library to perform cubic spline interpolation? (I found that there is one library, but it is for 2 or 3 dimensional image. Since I need to perform other complicated

convert bezier curve with N point to many cubic bezier curve

痴心易碎 提交于 2019-12-13 02:55:27
问题 I have bezier curve with about 48 ctrl points and I want to transform it to many cubic bezier curves... Any algorthim , math theory or just a link may help :) ?? 回答1: Math theory: you cannot do this. An nth order Bezier curve cannot be represented as any number of (n-1)th order Bezier curves, because the curvatures cannot be faithfully represented. You can approximate it, but you won't get an identical result. Practice: you can cut up your 48th order curve into sections of simple curve, where

How to implement a piecewise function and then plot it on certain intervals in MATLAB

≯℡__Kan透↙ 提交于 2019-12-11 04:08:21
问题 I am actually attempting to write code for the cubic spline interpolation. Cubic spline boils down to a series of n-1 segments where n is the number of original coordinates given initially and the segments are each represented by some cubic function. I have figured out how to get all the coefficients and values for each segment, stored in vectors a,b,c,d , but I don't know how to plot the function as a piecewise function on different intervals. Here is my code so far. The very last for loop

Finding Y given X on a Cubic Bezier Curve?

给你一囗甜甜゛ 提交于 2019-12-09 14:48:48
问题 I need a method that allows me to find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate. I've come across lots of places telling me to treat it as a cubic function then attempt to find the roots, which I understand. HOWEVER the equation for a Cubic Bezier curve is (for x-coords): X(t) = (1-t)^3 * X0 + 3*(1-t)^2 * t * X1 + 3*(1-t) * t^2 * X2 + t^3 * X3 What confuses me is the addition of the (1-t) values. For instance, if I fill in the X values with some random numbers: 400 = (1

Matplotlib: Data cubic interpolation (or FIT) for Contour plot

谁都会走 提交于 2019-12-06 12:49:11
问题 I have a series of data from device. How can i make cubic interpolation or FIT for this plot? import matplotlib.pyplot as plt a = [[1,1,1],[2,2,2],[3,3,3]] b = [[1,2,3],[1,2,3],[1,2,3]] c = [[3,2,1],[1,4,2],[4,5,1]] fig1 = plt.figure() ax1 = fig1.add_subplot(111) fig1.set_size_inches(3.54,3.54) #Create Contour plot contour=ax1.contour(a,b,c) plt.show() 回答1: You can adapt @Joe Kington's suggestion and use scipy.ndimage.zoom which for your case of a cubic interpolation fits perfectly: import

Solving a cubic to find nearest point on a curve to a point

这一生的挚爱 提交于 2019-12-06 06:33:29
问题 Ok, I have a projectile that has its position defined such that: a.x = initialX + initialDX * time; a.y = initialY + initialDY * time + 0.5 * gravtiy * time^2; I want to be able to predict which obstacles in my environment this projectile will collide with. I plan on checking the distance from A the closest point on the curve to the point P . I figure that at the point A the tangent to the curve will be perpendicular to the vector AP , and that the tangent to the curve at A will simply be the

Matplotlib: Data cubic interpolation (or FIT) for Contour plot

浪子不回头ぞ 提交于 2019-12-04 19:45:33
I have a series of data from device. How can i make cubic interpolation or FIT for this plot? import matplotlib.pyplot as plt a = [[1,1,1],[2,2,2],[3,3,3]] b = [[1,2,3],[1,2,3],[1,2,3]] c = [[3,2,1],[1,4,2],[4,5,1]] fig1 = plt.figure() ax1 = fig1.add_subplot(111) fig1.set_size_inches(3.54,3.54) #Create Contour plot contour=ax1.contour(a,b,c) plt.show() Saullo G. P. Castro You can adapt @Joe Kington's suggestion and use scipy.ndimage.zoom which for your case of a cubic interpolation fits perfectly: import matplotlib.pyplot as plt import numpy as np from scipy.ndimage import zoom from mpl