0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

「sympyのPiecewise」を調べた。

Posted at

DOC

Represents an expression, condition pair.
https://docs.sympy.org/latest/modules/functions/elementary.html#piecewise

sympyで

from sympy import *
var('t',real=True)
y =Piecewise((t      ,t<  3),
             (3-(t-3),t<=12),
             (999,True     )
            )
print("# ",y)
print("# ",y.args[0])
print("# ",y.args[1])
print("# ",y.args[2])
print("# ",y.args   )
print("# ",len(y.args))
#  Piecewise((t, t < 3), (6 - t, t <= 12), (999, True))
#  (t, t < 3)
#  (6 - t, t <= 12)
#  (999, True)
#  ((t, t < 3), (6 - t, t <= 12), (999, True))
#  3
from sympy.plotting import plot
plot(0,3,y,(t,0,12),aspect_ratio=(1.0,1.0))

9.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?