# \#sympy

**URL:** https://discourse.julialang.org/tag/sympy/662.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Metaprogramming | String to Symbolics Num; eval(Meta.parse(. . .))](https://discourse.julialang.org/t/metaprogramming-string-to-symbolics-num-eval-meta-parse/132078)

<div class="topic-metadata">

**Author:** [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)\
**Replies:** 3\
**Last updated:** [September 4, 2025, 7:32pm UTC](https://discourse.julialang.org/t/metaprogramming-string-to-symbolics-num-eval-meta-parse/132078 "2025-09-04T19:32:36Z")

</div>

Hello, Context. I am using SymPy.solveset(. . .) within a function to solve an equation. I first convert the Symbolics Num equation to a string, pass it to the function, and within the function use SymPy.sympy.parse\_ex…

---

## [How to plot a impulse unit function using Plots.jl and SymPy.jl?](https://discourse.julialang.org/t/how-to-plot-a-impulse-unit-function-using-plots-jl-and-sympy-jl/131066)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 6\
**Last updated:** [July 27, 2025, 10:15am UTC](https://discourse.julialang.org/t/how-to-plot-a-impulse-unit-function-using-plots-jl-and-sympy-jl/131066 "2025-07-27T10:15:54Z")

</div>

Hello. Good evening. I’m doing all exercises of the Sadiku’s book in julia programming. The code is in github Im stucked to plot the impulse unit function after get it differentiating the unit step function. The p…

---

## [Error if lambdify target function is zero](https://discourse.julialang.org/t/error-if-lambdify-target-function-is-zero/128587)

<div class="topic-metadata">

**Author:** [@inkie](https://discourse.julialang.org/u/inkie)\
**Replies:** 2\
**Last updated:** [May 1, 2025, 9:34pm UTC](https://discourse.julialang.org/t/error-if-lambdify-target-function-is-zero/128587 "2025-05-01T21:34:56Z")

</div>

Hi guys, im implementing the fourier functions in julia + sympy but when i have an odd function my bn is not working as expected since bn(1) for example is not working giving this error: MethodError: no method matching (…

---

## [How to create an equation with a symbolic matrix using SymPy.jl?](https://discourse.julialang.org/t/how-to-create-an-equation-with-a-symbolic-matrix-using-sympy-jl/125937)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 2\
**Last updated:** [February 15, 2025, 7:07pm UTC](https://discourse.julialang.org/t/how-to-create-an-equation-with-a-symbolic-matrix-using-sympy-jl/125937 "2025-02-15T19:07:06Z")

</div>

Hello, good morning. How to build an equation using a symbolic matrix with SymPy.jl? Using python, I would just call sympy.Matrix class. In julia, we have Matrix in SymPy package, but it seems not create a symbol, and …

---

## [SymPy makes REPL to stuck](https://discourse.julialang.org/t/sympy-makes-repl-to-stuck/124814)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 19\
**Last updated:** [January 23, 2025, 2:47pm UTC](https://discourse.julialang.org/t/sympy-makes-repl-to-stuck/124814 "2025-01-23T14:47:43Z")

</div>

When I tried the following in REPL, it gets stuck when I types the last line. I cannot keep typing. The command top shows that Julia is using all the CPU. Any suggestion on how to trouble shoot the problem? I thought it…

---

## [Symbolic Integration for hard expressions and generate function](https://discourse.julialang.org/t/symbolic-integration-for-hard-expressions-and-generate-function/124744)

<div class="topic-metadata">

**Author:** [@MechRob](https://discourse.julialang.org/u/MechRob)\
**Replies:** 9\
**Last updated:** [January 22, 2025, 6:22pm UTC](https://discourse.julialang.org/t/symbolic-integration-for-hard-expressions-and-generate-function/124744 "2025-01-22T18:22:59Z")

</div>

Hello All, I am trying to generate Julia functions by deriving the symbolic expressions in Julia. I started using Symbolics.jl and SymbolicNumericIntegration.jl, however it seems that SymbolicNumericIntegration.jl is no…

---

## [Lambdify function to matrix](https://discourse.julialang.org/t/lambdify-function-to-matrix/123163)

<div class="topic-metadata">

**Author:** [@ccmejia](https://discourse.julialang.org/u/ccmejia)\
**Replies:** 2\
**Last updated:** [November 27, 2024, 5:57pm UTC](https://discourse.julialang.org/t/lambdify-function-to-matrix/123163 "2024-11-27T17:57:18Z")

</div>

Hi there! Im trying to obtain a 20x20 matrix from the next code fn = lambdify(t, \[V, g, k\]) ges = range(1, 2, 20); kes = range(1, 2, 20) fn.(1, ges, kes) But I obtain a vector… 20-element Vector{ComplexF64}: Functi…

---

## [Detecting Function Composition in Symbolics.jl](https://discourse.julialang.org/t/detecting-function-composition-in-symbolics-jl/115885)

<div class="topic-metadata">

**Author:** [@nicrummel](https://discourse.julialang.org/u/nicrummel)\
**Replies:** 5\
**Last updated:** [July 5, 2024, 6:06pm UTC](https://discourse.julialang.org/t/detecting-function-composition-in-symbolics-jl/115885 "2024-07-05T18:06:05Z")

</div>

Motivation I have a system of differential equations \\dot{U} = F(U,w) where U\\in \\mathbb{R}^D are dependent variables and w \\in\\mathbb{R}^J are parameters. And I can quickly build (in-place) Julia functions from Symbol…

---

## [Best Practices for converting a Mathematica expression to Julia](https://discourse.julialang.org/t/best-practices-for-converting-a-mathematica-expression-to-julia/18335)

<div class="topic-metadata">

**Author:** [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Replies:** 33\
**Last updated:** [April 11, 2024, 8:24pm UTC](https://discourse.julialang.org/t/best-practices-for-converting-a-mathematica-expression-to-julia/18335 "2024-04-11T20:24:36Z")

</div>

Are there suggestions how to convert a rather long Mathematica expression to Julia? With Matlab I use http://library.wolfram.com/infocenter/MathSource/577/ I also would appreciate suggestions for the same problem with …

---

## [Is there a way to calculate eigenvalues for symbolic matrices?](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818)

<div class="topic-metadata">

**Author:** [@swsw](https://discourse.julialang.org/u/swsw)\
**Replies:** 5\
**Last updated:** [March 21, 2024, 2:43am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818 "2024-03-21T02:43:15Z")

</div>

I’d like to calculate the eigenvalues for the matrix like \[1 1; x x\] in julia. is there a way to do it? I tried the following but didn’t work. using SymPy @syms x A = \[1 1; x x\] eigen(A)

---

## [Getting precompilation error for SymPy](https://discourse.julialang.org/t/getting-precompilation-error-for-sympy/106899)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 1\
**Last updated:** [November 29, 2023, 7:10pm UTC](https://discourse.julialang.org/t/getting-precompilation-error-for-sympy/106899 "2023-11-29T19:10:51Z")

</div>

I’m getting this error while trying to precompile SymPy \[ Info: Precompiling SymPy \[24249f21-da20-56a4-8eb1-6a02cf4ae2e6\] Python path configuration: PYTHONHOME = '/Users/sahil.khan/.julia/conda/3:/Users/sahil.khan/.ju…

---

## [From PyCall to PythonCall](https://discourse.julialang.org/t/from-pycall-to-pythoncall/104874)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 12\
**Last updated:** [October 12, 2023, 3:42pm UTC](https://discourse.julialang.org/t/from-pycall-to-pythoncall/104874 "2023-10-12T15:42:27Z")

</div>

I am trying to convert SymbolicControlSystems.jl from using PyCall to PythonCall. How can I translate the following line: const sp = SymPy.PyCall.PyNULL() I tried, but this does not work: const sp = SymPyPythonCall.P…

---

## [Plotting the tangent line of a vector-valued function](https://discourse.julialang.org/t/plotting-the-tangent-line-of-a-vector-valued-function/104297)

<div class="topic-metadata">

**Author:** [@Alf](https://discourse.julialang.org/u/Alf)\
**Replies:** 2\
**Last updated:** [September 27, 2023, 10:10pm UTC](https://discourse.julialang.org/t/plotting-the-tangent-line-of-a-vector-valued-function/104297 "2023-09-27T22:10:51Z")

</div>

Hi! I want to plot the tangent line of the vector valued function \\mathbf{f}(t)=(\\cos(t),\\sin(t),t) at t=\\pi, but I get an error. I can’t not understad what I am doing wrong. using SymPy, Plots @syms t::real g(t) = \[cos…

---

## [How to add assumptions to the integrated function](https://discourse.julialang.org/t/how-to-add-assumptions-to-the-integrated-function/99912)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 4\
**Last updated:** [June 6, 2023, 5:43pm UTC](https://discourse.julialang.org/t/how-to-add-assumptions-to-the-integrated-function/99912 "2023-06-06T17:43:02Z")

</div>

I posted the question here because it seemed to me the least unrelated to the question. Of the following integral I am interested only in the real part. How can I force to consider a\>x\>0? Or, alternatively, how can I s…

---

## [Symbolic integration with SymPy.jl](https://discourse.julialang.org/t/symbolic-integration-with-sympy-jl/78624)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 6\
**Last updated:** [June 6, 2023, 8:14am UTC](https://discourse.julialang.org/t/symbolic-integration-with-sympy-jl/78624 "2023-06-06T08:14:57Z")

</div>

I ran into a problem with SymPy.jl for symbolic integration, using SymPy m = symbols(“m”, integer=true) n = symbols(“n”, integer=true) x = symbols(“x”, integer=true) integrate(diff(x^4,(x,2)),x) The output is 4\*…

---

## [Problem using SymPy](https://discourse.julialang.org/t/problem-using-sympy/98012)

<div class="topic-metadata">

**Author:** [@joeit](https://discourse.julialang.org/u/joeit)\
**Replies:** 4\
**Last updated:** [June 3, 2023, 8:07am UTC](https://discourse.julialang.org/t/problem-using-sympy/98012 "2023-06-03T08:07:17Z")

</div>

Hi everybody, I am new to Julia and I would like to use the sympy functionalities. I have Julia 1.8 installed on Mac OS, with python 3. The SymPy package throws the error below. Any clue? Thanks Joe julia\> using Sy…

---

## [Numeric value substitution into SymPy Symbolic array or matrix](https://discourse.julialang.org/t/numeric-value-substitution-into-sympy-symbolic-array-or-matrix/99204)

<div class="topic-metadata">

**Author:** [@johannesnauta](https://discourse.julialang.org/u/johannesnauta)\
**Replies:** 5\
**Last updated:** [May 22, 2023, 10:42am UTC](https://discourse.julialang.org/t/numeric-value-substitution-into-sympy-symbolic-array-or-matrix/99204 "2023-05-22T10:42:10Z")

</div>

I am having trouble substituting numerical values into symbolic arrays and matrices. I have read about lambdify, but I still fail to provide numerical values for the arguments in a consistent way. As an example, consid…

---

## [Plot inequality using sympy](https://discourse.julialang.org/t/plot-inequality-using-sympy/97722)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 1\
**Last updated:** [April 20, 2023, 9:41pm UTC](https://discourse.julialang.org/t/plot-inequality-using-sympy/97722 "2023-04-20T21:41:53Z")

</div>

How to plot this inequality in sympy? I did other inequations and dont have this problem. Also this works pretty neat in python with plot\_implicit @syms x, y; ineq = Ge(x + 2y, 5); @info ineq; w = solve(…

---

## [The step-by-step of the SymPy package procedure](https://discourse.julialang.org/t/the-step-by-step-of-the-sympy-package-procedure/95901)

<div class="topic-metadata">

**Author:** [@maoc](https://discourse.julialang.org/u/maoc)\
**Replies:** 3\
**Last updated:** [March 11, 2023, 8:08pm UTC](https://discourse.julialang.org/t/the-step-by-step-of-the-sympy-package-procedure/95901 "2023-03-11T20:08:49Z")

</div>

I am reading the tutorial of the SymPy package. I would like to know if there is a way to show the step-by-step calculations that the package performs. For example, we know that this works well: using SymPy x = symbols(…

---

## [How to get Simplified variance of a random variable?](https://discourse.julialang.org/t/how-to-get-simplified-variance-of-a-random-variable/95071)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 6\
**Last updated:** [February 28, 2023, 5:14am UTC](https://discourse.julialang.org/t/how-to-get-simplified-variance-of-a-random-variable/95071 "2023-02-28T05:14:53Z")

</div>

Hi all, I want to use Julia to get the end result like this: the Expectation of (X - \\mu)^{2} will be computed at the end to become: E(X^{2}) - \\mu^{2} but how? this is my try out: using SymPy # https://docs.symp…

---

## [Visualizing and understanding Fourier transforms](https://discourse.julialang.org/t/visualizing-and-understanding-fourier-transforms/93898)

<div class="topic-metadata">

**Author:** [@skittishdev](https://discourse.julialang.org/u/skittishdev)\
**Replies:** 4\
**Last updated:** [February 2, 2023, 2:07pm UTC](https://discourse.julialang.org/t/visualizing-and-understanding-fourier-transforms/93898 "2023-02-02T14:07:38Z")

</div>

Hi, I am trying to understand Fourier transforms, and decided to create some plots using Julia to help validate my own understanding. What I want Create a known signal as a sum/product of 2 other simple sinusoidal si…

---

## [Using Serialization to store then load a lambdified function?](https://discourse.julialang.org/t/using-serialization-to-store-then-load-a-lambdified-function/85884)

<div class="topic-metadata">

**Author:** [@pluie](https://discourse.julialang.org/u/pluie)\
**Replies:** 7\
**Last updated:** [January 30, 2023, 11:08am UTC](https://discourse.julialang.org/t/using-serialization-to-store-then-load-a-lambdified-function/85884 "2023-01-30T11:08:26Z")

</div>

I have a lengthy symbolic expression that I find and lambdify in one function once. I hope to use this lambdified function repeatedly in a different function. It takes about a minute for lambdify to execute, so I do not …

---

## [SymPy: solving a system of equation and replacing the values in the original expression](https://discourse.julialang.org/t/sympy-solving-a-system-of-equation-and-replacing-the-values-in-the-original-expression/93653)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 6:06pm UTC](https://discourse.julialang.org/t/sympy-solving-a-system-of-equation-and-replacing-the-values-in-the-original-expression/93653 "2023-01-27T18:06:45Z")

</div>

Hello, I am trying to replicate this (old) simple example on symbolically finding the resolution of a system of equations and replacing an expression with the founded numerical solution: I arrived to it by manually r…

---

## [How to solve these equations?](https://discourse.julialang.org/t/how-to-solve-these-equations/92788)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 33\
**Last updated:** [January 12, 2023, 7:37am UTC](https://discourse.julialang.org/t/how-to-solve-these-equations/92788 "2023-01-12T07:37:53Z")

</div>

using SymPy @syms x y z e₁ e₂ c₁ c₂ c₃ c₅ s₁ s₂ s₃ g₁ g₂ fx = x\*(x - 1)\*(c₁ + c₂\*y\*z - c₂\*y - c₂\*z - e₁ - e₂\*y\*z + e₂\*y + e₂\*z - g₁\*y - g₂\*z - s₁\*y) fy = y\*(y - 1)\*(c₃ + g₁\*x - g₁ + s₁\*x) fz = -z\*(z - 1)\*(-c₅ + s₂ + s…

---

## [Is there a \\ operator for Unitful?](https://discourse.julialang.org/t/is-there-a-operator-for-unitful/92195)

<div class="topic-metadata">

**Author:** [@FelixHeox](https://discourse.julialang.org/u/FelixHeox)\
**Replies:** 6\
**Last updated:** [December 28, 2022, 12:42am UTC](https://discourse.julialang.org/t/is-there-a-operator-for-unitful/92195 "2022-12-28T00:42:08Z")

</div>

I was running into a problem using the \\ (linear system solver) operator in Julia. I guess I wrongly assumed the \\ operator was overloaded for matrices/vectors with entries of type \<: Number (witch unitful types are). Is…

---

## [Julia Sympy Apply To Both Sides Of Equation](https://discourse.julialang.org/t/julia-sympy-apply-to-both-sides-of-equation/91514)

<div class="topic-metadata">

**Author:** [@Brian\_Toomey](https://discourse.julialang.org/u/Brian_Toomey)\
**Replies:** 10\
**Last updated:** [December 13, 2022, 3:25pm UTC](https://discourse.julialang.org/t/julia-sympy-apply-to-both-sides-of-equation/91514 "2022-12-13T15:25:46Z")

</div>

Julia Sympy is great! Many thanks to the people that worked on it. I’m wondering about how one might implement a strategy like the one described here so that I could work through calculations myself for problem sets. T…

---

## [Lambdify getting error if expression is function of time](https://discourse.julialang.org/t/lambdify-getting-error-if-expression-is-function-of-time/90118)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 6\
**Last updated:** [November 13, 2022, 8:55pm UTC](https://discourse.julialang.org/t/lambdify-getting-error-if-expression-is-function-of-time/90118 "2022-11-13T20:55:22Z")

</div>

using SymPy using PyCall sp = pyimport("sympy") @vars t x = sp.Function("x")(t) y = sp.Function("y")(t) z = x^2+y^2 hz = lambdify(z,(x,y)) # hz = lambdify(z,(x,y)) hz(1,1)

---

## [Getting Error while using lambdify](https://discourse.julialang.org/t/getting-error-while-using-lambdify/89956)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 4\
**Last updated:** [November 11, 2022, 1:17pm UTC](https://discourse.julialang.org/t/getting-error-while-using-lambdify/89956 "2022-11-11T13:17:05Z")

</div>

---

## [SymPy undefined behavior](https://discourse.julialang.org/t/sympy-undefined-behavior/89432)

<div class="topic-metadata">

**Author:** [@mendeli](https://discourse.julialang.org/u/mendeli)\
**Replies:** 3\
**Last updated:** [October 28, 2022, 12:59pm UTC](https://discourse.julialang.org/t/sympy-undefined-behavior/89432 "2022-10-28T12:59:06Z")

</div>

Being relatively new to Julia, I wrote something like the code below and stumbled on undefined behavior. Since the code below does not use the correct expr.subs() syntax, shouldn’t it issue an error message or warning? T…

---

## [How to substitute variable in expression contains its derivative also](https://discourse.julialang.org/t/how-to-substitute-variable-in-expression-contains-its-derivative-also/88241)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 2\
**Last updated:** [October 4, 2022, 11:35pm UTC](https://discourse.julialang.org/t/how-to-substitute-variable-in-expression-contains-its-derivative-also/88241 "2022-10-04T23:35:35Z")

</div>

using SymPy using PyCall sp = pyimport("sympy") t1 = sp.Function("theta\_1")(t) f = t1^2 +t1 df = sp.diff(f,t) # so df = 2\*t1\*(d(t1)/d(t))+ (d(t1)/d(t)) # if substitution done of t1 value that is t1 = 2 s = df.subs(\[(…

[Next page](https://discourse.julialang.org/tag/sympy/662.md?match_all_tags=true&page=1&tags%5B%5D=sympy)
