sympy

Sympy - altering the range of the y axis for a plot

孤人 提交于 2020-06-12 05:11:39
问题 Using Sympy how does one set the range for the y axis ? plot((x**2 + 2)) I wanted to have this so that the y axis would be from 0 to 7 回答1: When you plot you can use the kwargs xlim and ylim to set the axis limits. For example: >>> plot((x**2 + 2), xlim=[-3,3], ylim=[0,7]) 来源: https://stackoverflow.com/questions/33881624/sympy-altering-the-range-of-the-y-axis-for-a-plot

Sympy - altering the range of the y axis for a plot

寵の児 提交于 2020-06-12 05:11:31
问题 Using Sympy how does one set the range for the y axis ? plot((x**2 + 2)) I wanted to have this so that the y axis would be from 0 to 7 回答1: When you plot you can use the kwargs xlim and ylim to set the axis limits. For example: >>> plot((x**2 + 2), xlim=[-3,3], ylim=[0,7]) 来源: https://stackoverflow.com/questions/33881624/sympy-altering-the-range-of-the-y-axis-for-a-plot

How to get the minimum value of a cost function, having two variable integration expression, in short time using python?

独自空忆成欢 提交于 2020-06-10 07:23:48
问题 I want to find the minimum value of the cost function T . The cost function T has an expression in two variables ( Q and r ). I also need to find values of Q and r at which the cost function T reaches the global minimum. (if multiple global minimum values - then all) The bounds of Q and r are : 0 < Q < 15000 ; 0 < r < 5000 Here are the equations I am using Sympy library to generate the equations. and using the minimize function of scipy.optimize.minimize to find the minimum value. The code

How to get the minimum value of a cost function, having two variable integration expression, in short time using python?

走远了吗. 提交于 2020-06-10 07:23:05
问题 I want to find the minimum value of the cost function T . The cost function T has an expression in two variables ( Q and r ). I also need to find values of Q and r at which the cost function T reaches the global minimum. (if multiple global minimum values - then all) The bounds of Q and r are : 0 < Q < 15000 ; 0 < r < 5000 Here are the equations I am using Sympy library to generate the equations. and using the minimize function of scipy.optimize.minimize to find the minimum value. The code

Solving system of linear equation with Sympy

给你一囗甜甜゛ 提交于 2020-06-01 06:53:30
问题 To evaluate a certain property of elasticity I would like to use sympy to visualize the set of equation. I use the following code : import numpy as np import sympy as sym b1=sym.Array([[Rational(-1/2),sqrt(3)/2,0],[-sqrt(3)/2,Rational(-1/2),0],[0,0,1]]) Sigma=[] for i in range(0,3): for j in range(0,3): for k in range(0,3): for l in range(0,3): x= symbols(('\sigma_{%d%d}')%(k+1,l+1),commutative=False) M=sym.Array([x]) Sigmatotal_tmp=tensorproduct(b1[i][k],b1[j][l],M) Sigma.append(Sigma11) I

How do I replace floats with rationals in a sympy expression?

眉间皱痕 提交于 2020-05-14 18:07:55
问题 I have an expression from a sympy calculation: sqrt(pi)*(0.333333333333333*a + 0.333333333333333*b - 2.66666666666667*c**2) where a,b,c are symbols, and would like to parse it so that the floats are replaced with rationals like in sqrt(pi)*(1/3*a + 1/3*b - 8/3*c**2) I know how to do one by hand, In[24] Rational(str(0.333333333333333)).limit_denominator(1000) Out[24]: 1/3 but do not quite know how to go about parsing the atoms and picking only the ones that are floats, and substituting back

How do I replace floats with rationals in a sympy expression?

梦想的初衷 提交于 2020-05-14 18:07:14
问题 I have an expression from a sympy calculation: sqrt(pi)*(0.333333333333333*a + 0.333333333333333*b - 2.66666666666667*c**2) where a,b,c are symbols, and would like to parse it so that the floats are replaced with rationals like in sqrt(pi)*(1/3*a + 1/3*b - 8/3*c**2) I know how to do one by hand, In[24] Rational(str(0.333333333333333)).limit_denominator(1000) Out[24]: 1/3 but do not quite know how to go about parsing the atoms and picking only the ones that are floats, and substituting back

How do I replace floats with rationals in a sympy expression?

不问归期 提交于 2020-05-14 18:06:08
问题 I have an expression from a sympy calculation: sqrt(pi)*(0.333333333333333*a + 0.333333333333333*b - 2.66666666666667*c**2) where a,b,c are symbols, and would like to parse it so that the floats are replaced with rationals like in sqrt(pi)*(1/3*a + 1/3*b - 8/3*c**2) I know how to do one by hand, In[24] Rational(str(0.333333333333333)).limit_denominator(1000) Out[24]: 1/3 but do not quite know how to go about parsing the atoms and picking only the ones that are floats, and substituting back