Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64391

Re: matlabFunction Equivalent?

Path csiph.com!usenet.pasdenom.info!goblin1!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <johannes.schneider@galileo-press.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'syntax': 0.04; 'output': 0.05; 'scipy': 0.05; 'amtsgericht': 0.07; 'expressions': 0.07; 'hrb': 0.07; 'variables': 0.07; '1200,': 0.09; 'don': 0.09; 'sub': 0.09; 'python': 0.11; '1400': 0.16; '[y,': 0.16; 'equation': 0.16; 'matlab': 0.16; 'numpy': 0.16; 'rainer': 0.16; 'ralf': 0.16; 'subject:skip:m 10': 0.16; 'symbols': 0.16; 'thoughts?': 0.16; 'wrote:': 0.18; 'hey': 0.18; 'variable': 0.18; 'all,': 0.19; 'trying': 0.19; 'seems': 0.21; 'import': 0.22; 'gmbh': 0.22; 'header:User-Agent:1': 0.23; 'germany': 0.24; 'math': 0.24; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'derivatives': 0.31; 'equivalent.': 0.31; 'symbolic': 0.31; 'this.': 0.32; 'know.': 0.32; 'maybe': 0.34; 'could': 0.34; "can't": 0.35; 'etc': 0.35; 'but': 0.35; 'really': 0.36; 'installing': 0.36; 'subject:?': 0.36; 'turn': 0.37; 'to:addr :python-list': 0.38; 'short': 0.38; 'supporting': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'skip:y 20': 0.60; 'most': 0.60; 'free': 0.61; 'new': 0.61; 'range': 0.61; 'email addr:gmail.com': 0.63; 'received:194': 0.64; 'skip:+ 10': 0.65; 'tel.:': 0.65; 'press': 0.70; 'programs,': 0.74; 'hand': 0.80; 'pasting': 0.84; 'received:192.168.57': 0.84; 'do:': 0.91; 'inefficient': 0.91; 'that),': 0.91; 'mistakes': 0.93
Date Tue, 21 Jan 2014 09:05:12 +0100
From Johannes Schneider <johannes.schneider@galileo-press.de>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10
MIME-Version 1.0
To python-list@python.org
Subject Re: matlabFunction Equivalent?
References <403d8fa2-171f-4f8e-8e77-f30ae57a3135@googlegroups.com>
In-Reply-To <403d8fa2-171f-4f8e-8e77-f30ae57a3135@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5772.1390292806.18130.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1390292806 news.xs4all.nl 2903 [2001:888:2000:d::a6]:39512
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64391

Show key headers only | View raw


On 20.01.2014 23:09, rpi.baldum@gmail.com wrote:
> Hey all,
>
> I'm new at Python, so if you see any mistakes feel free to let me know.
>
> I'm trying to take a symbolic expression and turn it into a variable equation or function. I think that just an expression of variables would be preferable.
>
> I have a range equation which I form using symbols and then take various derivatives of it. I then want to have these derivatives on hand to use for various functions, but short of using sub every time or just copy pasting from the console output (I don't want to do that), I can't find an efficient way to do this. Matlab had matlabFunction which was really handy, but I don't think Python has an equivalent.
>
> ########
> import numpy as np
> import scipy as sp
> import sympy as sy
> import math as ma
>
> x, y, z, x_s, y_s, z_s, theta, theta_dot, x_dot, y_dot, z_dot = sy.symbols('x y z x_s y_s z_s theta theta_dot x_dot y_dot z_dot')
>
> rho = (x**2 + y**2 + z**2 + x_s**2 + y_s**2 + z_s**2 - 2*(x*x_s + y*y_s)*sy.cos(theta) + 2*(x*y_s - y*x_s)*sy.sin(theta) - 2*z*z_s)**(0.5)
>
> rho_dot = (x*x_dot + y*y_dot + z*z_dot - (x_dot*x_s + y_dot*y_s)*sy.cos(theta) + theta_dot*(x*x_s + y*y_s)*sy.sin(theta) + (x_dot*y_s - y_dot*x_s)*sy.sin(theta) + theta_dot*(x*y_s - y*x_s)*sy.cos(theta) - z_dot*z_s)/rho
>
> drho_dx = sy.diff(rho, x)
>
> drho_dy = sy.diff(rho, y)
>
> drho_dz = sy.diff(rho, z)
>
> #I then want drho_dx, etc to be variable expressions with x, y, z, etc as variables instead of symbols or numbers. I could do:
>
> x, y, z = 1200, 1300, 1400 #m
>
> drho_dx = subs([x, x], [y, y], [z, z])
>
> #but this seems inefficient to do multiple times. Thoughts?
>

If you  don not mind installing other programs, maybe you can have a 
look at sage (www.sagemath.org). That's a ComputerAlgebraSystem using 
python as its base and supporting most (all?) of the python syntax and 
moduls

bg,
Johannes



-- 
Johannes Schneider
Webentwicklung
johannes.schneider@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

matlabFunction Equivalent? rpi.baldum@gmail.com - 2014-01-20 14:09 -0800
  Re: matlabFunction Equivalent? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-20 22:48 +0000
  Re: matlabFunction Equivalent? Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-01-21 09:05 +0100

csiph-web