将Numpy数组附加到另​​一个Numpy数组

问题描述

我有一个NumPy数组,其中的符号用常数 a b 进行符号求解。这是我的数组“ bounds_symbolic”中索引为(2,0)的单元格的示例:

-a*sqrt(1/(a**6*b**2+1))

我还有一个名为“ a_values”的数组,我想将其替换为“ bounds_symbolic”数组。我还将 b 值设置为1,我也想替换为该值。保持数组的第一行完好无缺。

换句话说,对于在“ bounds_symbolic”中索引为(2,0)的单元格,我想将所有 a b 值替换为方程,同时扩展列以包含替换的方程。然后,我想对整个“ bounds_symbolic”数组进行此操作。

这是我到目前为止的代码:

import sympy
import numpy as np

a,b,x,y = sympy.symbols("a b x y")

# Equation of the ellipse solved for y
ellipse = sympy.sqrt((b ** 2) * (1 - ((x ** 2) / (a ** 2))))

# Functions to be tested
test_functions = np.array(
    [(a * b * x),(((a * b) ** 2) * x),(((a * b) ** 3) * x),(((a * b) ** 4) * x),(((a * b) ** 5) * x)])

# Equating ellipse and test_functions so their intersection can be symbolically solved for
equate = np.array(
    [sympy.Eq(ellipse,test_functions[0]),sympy.Eq(ellipse,test_functions[1]),test_functions[2]),test_functions[3]),test_functions[4])])

# Calculating the intersection points of the ellipse and the testing functions

# Array that holds the bounds of the integral solved symbolically
bounds_symbolic = np.array([])
for i in range(0,5):
    bounds_symbolic = np.append(bounds_symbolic,sympy.solve(equate[i],x))

# Array of a-values to plug into the bounds of the integral
a_values = np.array(np.linspace(-10,10,201))

# Setting b equal to a constant of 1
b = 1

integrand = np.array([])
for j in range(0,5):
    integrand = np.append(integrand,(ellipse - test_functions[j]))

# New array with a-values substituted into the bounds
bounds_a = bounds_symbolic
# for j in range(0,5):
#    bounds_a = np.append[:,]

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)