calculus

Sympy summation with indexed variable

六眼飞鱼酱① 提交于 2019-12-01 20:54:04
问题 I try to create a sympy expression with a Sum with an indexed variable as previous explain here However, I can not do lambdify of this expression and give an array to get the sum calculated. Is this impossible? 回答1: Perhaps like this? >>> s=Sum(Indexed('x',i),(i,1,3)) >>> f = lambda x: Subs(s.doit(), [s.function.subs(s.variables[0], j) ... for j in range(s.limits[0][1], s.limits[0][2] + 1)], x).doit() >>> f((30,10,2)) 42 回答2: You can use lambdify. Just make sure the limits of the sum match

LibGDX Path (CatmullRomSpline) Constant Speed

只谈情不闲聊 提交于 2019-12-01 20:40:15
问题 I’m trying to achieve constant speed on a path using the LibGDX CatmullRomSpline and I’m having problems getting it to work. I’ve tried researching on this topic a lot including reading the LibGDX wiki, but their explanation for achieving constant speed doesn’t really make sense and I wasn’t able to get their method to work. https://github.com/libgdx/libgdx/wiki/Path-interface-&-Splines In my case, the derivative values are very large (in the hundreds) so when dividing a number between 0-1 by

javascript slider weighted values

喜欢而已 提交于 2019-12-01 17:58:42
问题 I have a JavaScript slider that outputs a value between 0 and 1 depending on its position. I want to convert that value to a value on another scale between say 100 and 1000, but based on the distribution of a set of data points between 100 and 1000. The use case here is that I want the slider to be less sensitive to changes when there is a very close set of numbers. Eg... let's say the values in the scale are: 100, 200, 300, 500, 1000 The values 100-500 might take up, say, the first 80% of

Ploting solid of revolution in Python 3 (matplotlib maybe)

独自空忆成欢 提交于 2019-11-30 22:53:16
Greetings the problem: R is a region in the xy plane bounded by the parabola y=x^2+1 and line y=x+3. A solid of revolution is formed by rotating R around the x axis. I need to plot parabola and line in 2D and solid revolution 3D, How do it? I have installed anaconda. You could use plot_surface : import numpy as np import matplotlib.pyplot as plt import mpl_toolkits.mplot3d.axes3d as axes3d fig = plt.figure() ax = fig.add_subplot(1, 1, 1, projection='3d') u = np.linspace(-1, 2, 60) v = np.linspace(0, 2*np.pi, 60) U, V = np.meshgrid(u, v) X = U Y1 = (U**2 + 1)*np.cos(V) Z1 = (U**2 + 1)*np.sin(V)

Minimizing NExpectation for a custom distribution in Mathematica

百般思念 提交于 2019-11-29 23:24:37
This relates to an earlier question from back in June: Calculating expectation for a custom distribution in Mathematica I have a custom mixed distribution defined using a second custom distribution following along the lines discussed by @Sasha in a number of answers over the past year. Code defining the distributions follows: nDist /: CharacteristicFunction[nDist[a_, b_, m_, s_], t_] := (a b E^(I m t - (s^2 t^2)/2))/((I a + t) (-I b + t)); nDist /: PDF[nDist[a_, b_, m_, s_], x_] := (1/(2*(a + b)))*a* b*(E^(a*(m + (a*s^2)/2 - x))* Erfc[(m + a*s^2 - x)/(Sqrt[2]*s)] + E^(b*(-m + (b*s^2)/2 + x))*

How to sort colors in two dimensions?

允我心安 提交于 2019-11-29 11:03:19
I am currently working on a hobby project to automatically solve a puzzle from the popular mobile game I Love Hue . The game is available here . Basically, the whole premise of the game is that you're given a bunch of colored rectangular blocks organized in a grid. You can swap most of the blocks except for a few fixed blocks, which are marked by black dots. The object of the game is to swap the blocks around so you get a two-dimensional spectrum of color. The colors are sorted such that the color of each block is approximately the average of the colors around it. (Sorry, I don't know any

Minimizing NExpectation for a custom distribution in Mathematica

风格不统一 提交于 2019-11-28 20:41:37
问题 This relates to an earlier question from back in June: Calculating expectation for a custom distribution in Mathematica I have a custom mixed distribution defined using a second custom distribution following along the lines discussed by @Sasha in a number of answers over the past year. Code defining the distributions follows: nDist /: CharacteristicFunction[nDist[a_, b_, m_, s_], t_] := (a b E^(I m t - (s^2 t^2)/2))/((I a + t) (-I b + t)); nDist /: PDF[nDist[a_, b_, m_, s_], x_] := (1/(2*(a +

How to sort colors in two dimensions?

回眸只為那壹抹淺笑 提交于 2019-11-28 04:16:42
问题 I am currently working on a hobby project to automatically solve a puzzle from the popular mobile game I Love Hue . The game is available here. Basically, the whole premise of the game is that you're given a bunch of colored rectangular blocks organized in a grid. You can swap most of the blocks except for a few fixed blocks, which are marked by black dots. The object of the game is to swap the blocks around so you get a two-dimensional spectrum of color. The colors are sorted such that the