# Tag: sympy

## How do I apply Sympy.Solve to solve a two-sided function on each row in a database?

I am attempting to apply the sympy.solve function to each row in a DataFrame using each column a different variable. I have managed to solve for the undefined variable I need to calculate — λ — using the following code: However, I need to apply this function to every row in a DataFrame and output the result as its own

## solving single variable two sided equation in sympy

Can anyone advise on why the below code using Sympy would error with ‘Add’ object is not callable? I am trying to solve a simple single variable linear expression. It can be solved by hand and Wolfram Alpha gives a solution for ‘y’. Not sure how else to input it into Sympy. I might be less well versed in math

## Is there a function in sympy or scipy that corresponds to massMatrixForm in matlab?

I am learning rigid body kinematics from: https://rotations.berkeley.edu/the-poisson-top-with-friction/ . The link to the matlab source code is at the bottom of the page. Derive the Poisson top’s equations of motion: http://rotations.berkeley.edu/wp-content/uploads/2017/10/derive_poisson_top_ODEs.txt Solve the Poisson top’s equations of motion: http://rotations.berkeley.edu/wp-content/uploads/2017/10/solve_poisson_top_ODEs.txt I rewrote most of the code for the derivation process in python, though may not be elegant code. In fact, it

## Graphing Inequalities in python

I’m looking to create a program that will randomly generate lines (that are inequalities) and that will show the area that satisfies the constraints. I don’t mind which libraries are used so feel free to use sympy, numpy etc I will show my current code but this just fills the area between 2 lines and doesn’t use inequalities at all.

## How might I find an approximate solution to this equation?

The following code is meant to find for how much Bitcoin one is meant to buy in order to break even given the expected inflation, the holding period, and the amount of savings in dollars: When the program is fed with years=3, times=4, cpi=8, and a=1000 it does not find a solution. Because of it I introduced a loop that

## Trying to simplify a stubborn expression in SymPy – complex exponential / trigonometric space vector equation

I am trying to simplify which I know reduces down to 1.5e^(I*phi) I cannot get SymPy to recognize this. I have tried simplify, trigsimp, expand, etc. But nothing seems to work. Any suggestions? Here is my code: None of these produce the expected result. I can confirm my result manually, by substituting values in for phi like this: Answer It’s

## SymPy returns wrong solution of a nonlinear ODE?

I am trying to solve the ODE of the frictional free fall: I think the solution might be wrong. I believe it should be the reciprocal of the returned expression. Therefore, if I try to find the value of the constant for an initial condition of rest (v(0) = 0), I get no real solutions: As a consequence, if I

## SymPy lambdify gives wrong result, while *.subs gives the accruate one

Sorry for bothering you with this. I have a serious issue and now im on clock to solve it, so here is my question. I have an issue where I lambdify a quantity, but the result of the quantity differs from the “.subs” result, and sometimes it’s way off, or it’s a NaN, where in reality there is a real

## What is the difference between (matplotlib) and (SymPy Plotting Module)?

https://scicomp.stackexchange.com/questions/1144/how-can-i-plot-piece-wise-defined-function-in-some-easily-accessed-open-source-t ①Why is it that the above source code can be used to create a plot, but the following source code cannot? ②Can you point me to a web site that has a table comparing (matplotlib) and (SymPy Plotting Module)? ③(matplotlib) to (SymPy Plotting Module) converter and a (SymPy Plotting Module) to (matplotlib)　converter would be helpful. Answer ①Why is it

## sympy matplolib piecewise TypeError?

matplotlib TypeError? Please tell me the difference. i want to use plt.plot OK Error.why? raise TypeError(“can’t convert expression to float”) TypeError: can’t convert expression to float (ref) Sympy issues with plotting a piecewise function sympy piecewise:How can I plot a piecewise function using matplotlib? (20220315) Answer Matplotlib expects arrays of points rather than symbolic expressions. SymPy’s plot function is designed