Symbolic Manipulation in Python

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ • 68

  • @thevgancheetah
    @thevgancheetah 4 роки тому +4

    This video is the most helpful video ever when it comes to symbolic manipulation using Python!! Thank you so much!!!

  • @yem.t.3930
    @yem.t.3930 3 роки тому +3

    Perfect, comprehensive, very informative and concise, Thank you v. much sir!!!

  • @adaml929
    @adaml929 4 роки тому +4

    Thank you so much for this! quarantine classes expected me to already to know how to do this when I have used python in only one previous class. This helped SO much.

    • @apm
      @apm  4 роки тому +1

      Glad it helped! It can be hard to remember your introductory class, especially if you don't use Python on a regular basis.

  • @rohitsrao
    @rohitsrao 5 років тому +1

    Thanks for the video. Clear concise explanation and covered major basic functionality!

  • @kqnrqdtqqtttel1778
    @kqnrqdtqqtttel1778 4 роки тому

    27:17 is not invertible because the determinate = 0, so that will result in a 1/0 in the formula

    • @apm
      @apm  4 роки тому

      You are correct. The answer from Sympy is correct for my incorrect matrix. When I fixed my matrix, I received the solution that I expected.

  • @CrypticBTR
    @CrypticBTR 5 років тому +7

    fantastic tutorial. Good work!

  • @soumakbhattacharjee3866
    @soumakbhattacharjee3866 3 роки тому +1

    This is very useful. Thank you very much. Is this notebook available online and open access?

    • @apm
      @apm  3 роки тому +1

      Yes, the notebooks are available here: github.com/APMonitor/learn_python

  • @2fbDJLL
    @2fbDJLL 5 років тому +2

    Could you please share the HW document for practice in your video description? Thanks

    • @apm
      @apm  5 років тому

      Sure, it is HW17 here: github.com/APMonitor/learn_python

  • @muntoonxt
    @muntoonxt 5 років тому +3

    If you use sp.display (instead of sp.pprint), it will print out a LaTeX formatted version.

    • @apm
      @apm  5 років тому +1

      Thanks for the tip!

    • @junyang1710
      @junyang1710 5 років тому +2

      module 'sympy' has no attribute 'display'

  • @falolayusuf9684
    @falolayusuf9684 6 років тому +2

    Thanks so much for this video. It really helped for my coursework.

  • @aqueeqazam
    @aqueeqazam 3 роки тому +1

    Highly informative.

  • @abdulrahimshihabuddin1119
    @abdulrahimshihabuddin1119 3 роки тому +1

    Is there any way to equate symbolic derivatives to zero and solve it ? Say for example, I have dy/dx=0 and dy/dx would be in terms of x . Is it possible to obtain solutions of x from this equation

    • @apm
      @apm  3 роки тому

      Yes, you can use the evalf() method in an fsolve function call.

  • @afifakhanak
    @afifakhanak 4 роки тому +1

    How can we use symbolic manipulator for cryogenic liquid in a cylindrical tank equation solution? Can u help!

    • @apm
      @apm  4 роки тому +1

      Here is more information on symbolic solutions in Python: github.com/APMonitor/data_science/blob/master/10.%20Solve_Equations.ipynb

  • @adekunleajibode214
    @adekunleajibode214 4 роки тому +1

    This is a good tutorial.
    But please if I have two long mathematical formulas and wish to turn them to only one, is it possible with sympy? I mean to shuffle the formulas and construct new formula from the combination?

    • @apm
      @apm  4 роки тому

      Yes, that is possible. If you have one function named x and another named y then you can define a new function such as z = x+y or z=x*y. You can then simplify with z.simplify()

    • @adekunleajibode214
      @adekunleajibode214 4 роки тому +1

      @@apm Thanks so much boss.
      I actually combined like five formulas, the Simplified output is damn too long.
      Meanwhile, is there any machine learning technique that can achieve better performance than this?
      Though, the expression of A+B is shorter than A*B

    • @apm
      @apm  4 роки тому

      @@adekunleajibode214 I'm not aware of a machine learning method that will combine equations. However, you can use machine learning to create a new regression model from data sampled from your correlations. More information on machine learning is available from the short course: apmonitor.github.io/data_science

  • @mahathik8592
    @mahathik8592 4 роки тому +1

    how to find unknown value x by making determinant equal to zero in last example ?

    • @apm
      @apm  4 роки тому

      You could use the Sympy determinant function for a matrix such as M.det(). You could then solve for when the determinant is equal to zero with the solve function as shown here: github.com/APMonitor/data_science/blob/master/10.%20Solve_Equations.ipynb

  • @giannismaris13
    @giannismaris13 4 роки тому +2

    what an amazing work.

  • @dhimanbhowmick9558
    @dhimanbhowmick9558 3 роки тому +1

    Great tutorial, thanks, it is very helpful.

  • @invittimarcelo
    @invittimarcelo 5 років тому +1

    Amazing tutorial. Thank you and congratulations!

    • @apm
      @apm  5 років тому +1

      Thanks, Marcelo!

  • @bharatarse1503
    @bharatarse1503 3 роки тому +1

    Amazing thanks for sharing..

  • @Nogh_art
    @Nogh_art 4 роки тому +1

    Hi ! thank you for this video ! Very very helpful ! But I have one little question. When using sp.simplify (), (visual studio) it dosen't print the code. And simplify is in violet just like sp. Is it normal ? Maybe someone had the same problem ?

    • @apm
      @apm  4 роки тому

      You may need to run sp.init_printing() or else use sp.pprint() to print the expression. Let me know if this helps. I haven't used it in visual studio before so your insights will be valuable.

    • @Nogh_art
      @Nogh_art 4 роки тому +1

      @@apm Hi ^^, thank you for answering so quickly ! I do run the sp.init_printing () If I can contact you in private I could send you a screenshot ? If I use only the sp.pprint () it dosen't expand or simplify the result ^^'

    • @apm
      @apm  4 роки тому

      @@Nogh_art unfortunately, I can't help with specific / private requests for support but you may be able to get it from StackOverflow. Also, try including the simplify inside the pprint such as: sym.pprint(f.simplify())

    • @Nogh_art
      @Nogh_art 4 роки тому

      @@apm Hi ^^ ! first of all, that last line worked ! I wasn't thinking about a private request, I though that I might not be the only one having this problem ^^' Thank you so much for your help !

    • @apm
      @apm  4 роки тому

      @@Nogh_art No problem - I just get so many requests from individuals who want help with their specific problem. If I can reply on a public forum then at least it is there for others as well. I think your comment will help others too!

  • @jstello
    @jstello 6 років тому

    wonderful stuff!!
    can you please explain how you got TeX font into Markdown? Thank you!

    • @apm
      @apm  6 років тому +1

      Markdown supports TeX. You just need to use $ $ if it is inline. Here are a few examples: jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Typesetting%20Equations.html

  • @rvilleg95
    @rvilleg95 8 років тому

    How would it be if I wanted to iterate or solve an integral to a certaing value? example, I want to know the upper limit of (some random x) function until the area of the curve is 25 (for example)

    • @apm
      @apm  8 років тому

      Here is some example code:
      import sympy as sp
      from scipy.optimize import fsolve
      sp.init_printing()
      x = sp.Symbol('x')
      f = sp.integrate(x**2,x)
      sp.pprint(f)
      def myIntegral(y):
      g = f.subs(x,y).evalf()
      return g
      def myResidual(y):
      # put your objective here (what you want the integral to equal)
      diff = 25.0 - myIntegral(y)
      return diff
      guess = 1
      z = fsolve(myResidual,guess)
      print('Integral at ' + str(z[0]) + ' is ' + str(myIntegral(z)))

    • @rvilleg95
      @rvilleg95 8 років тому

      man yo should write a book or something. This was a project of mine the last semester and the code, even if it was short, wasnt THAT short haha. Thanks. Really enjoy your videos

  • @vitorfranca80
    @vitorfranca80 4 роки тому +1

    Fantastic! Tks for this tutorial

  • @gt9538
    @gt9538 7 років тому +2

    fair play man. well presented.

  • @pedroalexanderhernandezriv9912
    @pedroalexanderhernandezriv9912 4 роки тому +1

    gracias profe por tu tiempo

    • @apm
      @apm  4 роки тому

      de nada

  • @ef7496
    @ef7496 6 років тому +1

    how I can get the homework problem plz ???

    • @apm
      @apm  6 років тому

      All of the homework problems and solutions are posted to apmonitor.com/che263/index.php/Main/CourseHomework

    • @ef7496
      @ef7496 6 років тому

      Thank you so much sir

  • @JulioBarrancoGalaviz
    @JulioBarrancoGalaviz 5 років тому +1

    Great tutorial!

  • @abdallahjafaradi9463
    @abdallahjafaradi9463 6 років тому

    Can you please tell me how can I install Sympy into python?

    • @apm
      @apm  6 років тому

      You can install it with "pip install sympy". It is also included in the Anaconda distribution. Here is a tutorial: ua-cam.com/video/bXWlyOMYpRE/v-deo.html

    • @abdallahjafaradi9463
      @abdallahjafaradi9463 6 років тому

      Thank you very much. I used pip method and it worked. I have another question, is it possible to use sympy inside PyQt ?

  • @amirhosseinhamedanizad1153
    @amirhosseinhamedanizad1153 6 років тому

    TypeError: 'module' object is not callable ????

    • @apm
      @apm  6 років тому

      You need to run this in a Jupyter notebook. There are example notebook files at apmonitor.com/che263

  • @Bbdu75yg
    @Bbdu75yg 4 роки тому +1

    Nice!

  • @maranac10
    @maranac10 4 роки тому

    Great work.

  • @josephbargo5024
    @josephbargo5024 4 роки тому +1

    @22.15 This is fixed now btw

  • @Irina-fc3pb
    @Irina-fc3pb 4 роки тому +1

    amazing,thank you

  • @SpaceGhostNick
    @SpaceGhostNick 6 років тому

    cant we just do this by hand with a ti-89?

    • @apm
      @apm  6 років тому

      Yes, a lot of the functionality with SymPy is also available on a TI-89 calculator or similar graphing calculator. The advantage of Python is that it can run on a PC versus limited to a stand-alone calculator. SymPy is one of many packages in a feature rich programming language that can do much more than symbolic math. Sometimes the symbolic math part is only a small part of the overall larger calculation or data manipulation that would be impossible with a graphing calculator.

    • @theultimatereductionist7592
      @theultimatereductionist7592 6 років тому +1

      I'll take Sympy seriously when it can manipulate (take determinants, inverses) of matrices whose entries are indeterminate variables (i.e. NOT numbers), and
      (super-grand challenge) take the matrix size, N, as a variable itself.
      i.e. construct/fill a matrix of size, N, whose value I can specify at run time, with letters
      a(i,j) i, j = 1 through N

    • @selrahcnamtrah
      @selrahcnamtrah 6 років тому +2

      27:50

  • @hmblackfox1860
    @hmblackfox1860 6 років тому +1

    thank you so much

  • @MarkMcDaniel
    @MarkMcDaniel 5 років тому +1

    Dude, you need to get a better microphone. Lots of static noise coming through.

    • @apm
      @apm  5 років тому +1

      Yup, I got a new microphone. Check out my later videos.

  • @miguelramirez187
    @miguelramirez187 4 роки тому +1

    Thank you so much