Skip to content

Commit 6ddb9ba

Browse files
authored
widen signature for simplify, add not to solve documentation (#344)
1 parent 45920c7 commit 6ddb9ba

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SymPy"
22
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
3-
version = "1.0.19"
3+
version = "1.0.20"
44

55

66
[deps]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ easier.
2121

2222
The [tutorial](examples/tutorial.md) provides an overview. It is
2323
viewable as an `IJulia` notebook
24-
[here](http://nbviewer.ipython.org/github/JuliaPy/SymPy.jl/blob/master/examples/tutorial.ipynb). In addition, most of the SymPy tutorial has the `julia` counterparts illustrated starting from [index.html](http://htmlpreview.github.io/?https://github.com/JuliaPy/SymPy.jl/blob/master/examples/index.html)
24+
[here](http://nbviewer.ipython.org/github/JuliaPy/SymPy.jl/blob/master/examples/tutorial.ipynb). In addition, most of the SymPy tutorial has the `julia` counterparts illustrated starting from [index.html](http://htmlpreview.github.io/?https://github.com/JuliaPy/SymPy.jl/blob/master/examples/index.html).
2525

2626
### Installation
2727

src/mathfuns.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ end
7878

7979

8080
## Add interfaces for solve, nonlinsolve when vector of equations passed in
81+
"""
82+
solve
83+
84+
Use `solve` to solve algebraic equations.
85+
86+
Examples:
87+
```
88+
@vars x y a b c d
89+
solve(x^2 + 2x + 1, x) # [-1]
90+
solve(x^2 + 2a*x + a^2, x) # [-a]
91+
solve([a*x + b*y-3, c*x + b*y - 1], [x,y]) # Dict(y => (a - 3*c)/(b*(a - c)),x => 2/(a - c))
92+
```
93+
94+
!!! Note
95+
A very nice example using `solve` is a [blog](https://newptcai.github.io/euclidean-plane-geometry-with-julia.html) entry on [Napolean's theorem](https://en.wikipedia.org/wiki/Napoleon%27s_theorem) by Xing Shi Cai.
96+
"""
97+
solve() = ()
8198
solve(V::Vector{T}, args...; kwargs...) where {T <: SymbolicObject} =
8299
sympy.solve(V, args...; kwargs...)
83100

src/utils.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ subs(;kwargs...) = ex -> subs(ex; kwargs...)
111111
subs(dict::Dict; kwargs...) = ex -> subs(ex, dict...; kwargs...)
112112
subs(d::Pair...; kwargs...) = ex -> subs(ex, [(p.first, p.second) for p in d]...; kwargs...)
113113

114+
## simplify(ex::SymbolicObject, ...) is exported
115+
"""
116+
simplify
117+
118+
SymPy has dozens of functions to perform various kinds of simplification. There is also one general function called `simplify` that attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression. (See [Simplification](https://docs.sympy.org/latest/tutorial/simplification.html) for details on `simplify` and other related functionality).
119+
120+
For non-symbolic expressions, `simplify` returns its first argument.
121+
"""
122+
simplify(x,args...;kwargs...) = x
114123

115124
##################################################
116125
# avoid type piracy. After we call `pytype` mappings, some

test/tests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ import PyCall
130130
ex = line(10)
131131
@test ex(sol) == ex(sol...) == 11
132132

133+
## Simplify (issue 343)
134+
@vars x
135+
@test simplify(sin(x)^2 + cos(x)^2) == 1
136+
@test simplify(sympy.gamma(x)/sympy.gamma(x-2)) == (x-1)*(x-2)
137+
_ones = (1, 1.0, big"1", "1", one)
138+
@test simplify.(_ones) == _ones
139+
133140
## Conversion
134141
x = Sym("x")
135142
p = x.subs(x,pi)

0 commit comments

Comments
 (0)