Author Topic: Python and Math  (Read 5041 times)

0 Members and 1 Guest are viewing this topic.

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
IPython: Math Processor
« Reply #15 on: March 12, 2016, 03:50:12 pm »
Much has been written about the difference between mathematics and other intellectual disciplines — how mathematics is less accessible, more difficult, more esoteric. But modern computers are closing the gap between mathematics and activities that have a lower threshold for productive activity, like word processing.

We're seeing a rapid change in the role of computers in society and in education, driven by the fact that computer power is increasing as quickly as computer costs decline. This should allow something I call "math processing" to take its place alongside word processing in the personal toolkit of the modern computer user.


IPython: Math Processor

tips and tricks

To Whom It May Concern: If you have Sympy installed, you should be able to type isympy at the command line which will load IPython with SymPy environment (and pretty printing):

de = Eq(f(t).diff(t), (2*f(t)**4 + t**4)/(t*f(t)**3))

de

Very Pretty ...
____________________________________________________________________

hentrich@coyote ~ $ isympy
IPython console for SymPy 0.7.6.1 (Python 2.7.11-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at http://www.sympy.org

In [1]: de = Eq(f(t).diff(t), (2*f(t)**4 + t**4)/(t*f(t)**3))

In [2]: de
Out[2]:
            4      4   
d          t  + 2⋅f (t)
──(f(t)) = ────────────
dt              3     
             t⋅f (t)   

In [3]: dsolve(de, f(t))
Out[3]:
            ______________
            ╱   8 ⎛         1 ⎞
f(t) =    ╱  t  ⋅ ⎜C₁ - ──⎟
       4 ╱       ⎜          4⎟
       ╲╱       ⎝          t ⎠


It's even more impressive when using "ipython notebook" ... gives me goosebumps to see the Mathese.
« Last Edit: March 12, 2016, 11:21:56 pm by H »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
Re: Python and Math
« Reply #16 on: October 31, 2019, 09:47:00 am »
Holden, I am sure thie file basics.py is one I put together while going through Peter Farell's Hacking Math Class with Python.   The functions in those would be a good place to start.

I can also attach (maybe) others that I was using in 2015 that may be of interest or else I will email.
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
Re: Python and Math
« Reply #17 on: October 31, 2019, 10:44:00 am »
Note that a few of these were already posted in this thread but as text.
___________________________________________________________________

So, some files of interest pertaining to Number Theory (eea.py), Numerical Methods (numeth.py), and frac.py (you know the obsession I share with Pythagoras: rational numbers) ... all from around 2015 I suppose.  That was when I was spontaneously exploring mathematics with Python.   It was a worthwhile journey, and I only scratched the surface before, in a very natural and slow-motion manner, found myself where I am right now, obsessed with implementing "generic programming" using C++ templates and its STL, which is an attempt to apply the simplicity and elegance of mathematics to programming.

When it comes to your personal "relationship" to the realm of mathematics and programming, I think that Python can help you become familiar with the fundamental techniques.
_________________________________________________________________________

an aside:  ABOUT local SEARCH ENGINE

I have found that, when searching locally on this message board using its search engine, you get better results if you can first recall which forum the term in question might reside.  Go to that forum first, then do the search.  For example, to find this thread, I went to "Why Mathematics?" then searched for "python" ...

If I had done that on the home page, it only shows the Generic Programming thread's hits.
____________________________________________________________________________

Meanwhile, a mechanism on the the vacuume cleaner broke just after I dusted ceiling fan this morning.
I have potatoes to peel and have to drive Maman to yet another godforsaken doctor, quite a ways, close to my hometown ... must leave at noon and feel the accompanying "everyday/normal" stress others must feel every morning.   I hate driving out there.  We live in an insanely nongratifying world.

Getting mangled in an automobile accident driving to an inane examination.   Horrific irony.  So much for all the math and code.    First, potatoes and eggs.   I move slowly and begrudgingly, very irritated when I am prevented by the outside world from being being able to think, being prevented from manifesting my will or even given the opportunity to know what my own will even is!?
« Last Edit: October 31, 2019, 11:12:56 am by mike »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
Re: Python and Math
« Reply #18 on: November 17, 2019, 09:17:19 am »
Note about Numerical Methods master file: numeth.py
library: scitools

How can I install Python's SciTools with Anaconda?

Solution: 
This one hangs:   conda install -c asmeurer scitools

---> copy this then paste --->  conda install -c johannr scitools

This channel, johannr, while it seemed to hang, did eventually gather its dependencies and install.  Maybe the same would have been the case with channle "asmeurer" had I been a little more patient.   

I had discovered the initial absence of scitools in my current incarnation of Conda Installation when testing function deriv().  It was looking for scitools.StringFunction ....  You see how fragile all this "technical software" is.   Enough to drive one madder than the fictional author of that mysterious book from Lovecraft's mythos.   


Also, you may need to : source activate vpy, where vpy would be a Python 2.7 environment.

My system's default "base" anaconda python version is 3.6, but it is easy enoough to switch. 
I just thought I would mention it, and thereby break the ice, forging ahead into "post back-up" territory.

None of what we add from this point forward will be in the ZIP extraction, obviously, until the next back-up, at which time, virtually anyone could crawl and compress and upload tarball or zip to their own archive.org repository ...   We will be swallowed by the void in time, so it is probably all in vain in the end.  Hence, Why Bother ?

 ;D

After installing scitools:
----------------------------------------------
Executing transaction: done                                                           
(vpy) mwh@coyote:[/mnt/data/code/py]:                                                 
$ ----> ipython                                                                       
Python 2.7.15 |Anaconda custom (64-bit)| (default, Dec 14 2018, 19:04:19)             
Type "copyright", "credits" or "license" for more information.                         
                                                                                       
IPython 5.8.0 -- An enhanced Interactive Python.                                       
?         -> Introduction and overview of IPython's features.                         
%quickref -> Quick reference.                                                         
help      -> Python's own help system.                                                 
object?   -> Details about 'object', use 'object??' for extra details.                 
                                                                                       
In [1]: from numeth import *

In [2]: deriv()
Enter an expression involving x: 3*x**3 + 5*x - 666
The derivative of 3*x**3 + 5*x - 666 with respect to x is 9*x**2 + 5
Out[2]: 9*x**2 + 5
_______________________________________________________________
Do not be alarmed if the system takes several seconds to compute the result.
Maybe Holden is stranded somewhere out of reach or out of commission.   :-\
« Last Edit: November 17, 2019, 09:43:38 am by _id_Crisis_ »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Ibra

  • Philosopher of the Void
  • Posts: 132
Re: Python and Math
« Reply #19 on: November 17, 2019, 05:01:31 pm »
Quote
You see how fragile all this "technical software" is. 
It is not only the technical software I guess. all software are duct-taped now.
Python story from 2 to 3 was a mess. sometimes  I think compiled languages are better but they have their own problems and warts too. but what i know, I am just a guy who wrote some amateur C code and python scripts (a script kiddie?)  in the past but now no more.

I looked recently upon the world of "professional" software on Github. It's all useless, many layers of abstractions and dependencies hell. I'd take your approach of minimalism (cmdline calculators) anytime instead of the code monkeys. well, my mind is a toast and maybe programming is not my thing.


thanks hentrich for uploading the backup archive of this site.

I found this pic in the antinatalism sub of reddit (geometric progression of pain ?). I hope i stay away from "Love".  :D
https://i.redd.it/3v91bbdk28z31.jpg
« Last Edit: November 17, 2019, 05:04:47 pm by Ibra »
Suffering is the only fruit of human race

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
Re: Python and Math
« Reply #20 on: November 18, 2019, 06:24:16 am »
Quote from: Ibra
thanks hentrich for uploading the backup archive of this site.

Thank you, Ibra, for requesting and suggesting it.  There are many banging their heads against the wall with sophisticated Python code to archive their "experiencible" objects, and yet you came up with the quick, down, and dirty solution: crawl, compress, upload ----> download, extract: browse in peace even with no internet access, with no care of "real time" --- for what is real time?   I wish we could speak as though we were already dead, as sensitive human beings with a developed sense of how life unravels from memory to dust.   

That text "Denial of Death" is helping me face the actual terror of living with astonishment rather than crippling anxiety.   I am not much for "psychoanalysis," but this Ernest Becker lays it out bare as Schopenhauer did.   Life is terror for a human organism due to our fragility, sensitivity, and (especially as infants) total dependence upon parents for survival.

This must leave some inpression on us all, no?   I've been feeling a little more compassionate lately, maybe from realizing that we could learn a thing or two from the "stupid" who have no need to repress this existential terror since they don't experience it.    No, I think it is more likely that ALL experience the terror of being human, but the most intellectually courageous (or mad, insane) dare alllow themselves to really experience themselves as creatures HONESTLY.   We would be too terrofied, too terrified to function, paralyzed with fear of our own predicament:  freaking out, tripping .... you know, I am some kind of comedian in my own head.  That's how I have learned to cope with the awareness of the "terror of living."

The oceans are so very powerful.   What man would be a braggart standing on small vessel with raging waves?


Quote from: Ibra
I'd take your approach of minimalism (cmdline calculators) anytime instead of the code monkeys. well, my mind is a toast and maybe programming is not my thing.

Yes, I'm afraid I'm not interested in the "mobile-look" - the integrated GUI-Google-Mobile Interface experience that the gorts are brainwashed into navigating via their entertainment suites.  Thankfully, I prefer not to expend any energy whatsoever conforming my interests to suit the tastes and demands of such consumers and industries.   As far as I'm concerned, I am already dead to society ... or, that's what it "feels" like from my perspective, as an honest man in a society built on layer upon layer of gimmicks.   It's a wonder I haven't gone bonckers yet, or I have gone nuts and am repressing the awareness of my insanity in order to sidestep the terror.

Yes, I find that tinkering around creating command line programs tailored to one's own peculiar interests can be very satisfying.   I am afraid I am not much of a team player, so those large projects which require submitting to Head Ego in Charge may be problematic.    Imagine submitting your intellect to another.    Human beings must prostitute their minds to advance in the social hierarchies.   I don't know.

The only hero in such a world is the one who can look at reality, be terrified, be depressed, and allow oneself to experience coherent madness.   How clever can we ever be with words?

Add to the list of terrors:   these mental disciplines:  physics, mathematics, computer science ---- what honest man would trust any liar who presents himself as a master of such "disciplines" ?   At what point do we allow ourselves to fully contemplate that no one individual human being can cope with the "knowledge of the ages" ---

I break code up ... write it down with pencil ... tinker inside gdb debugger using "whatis" often to inspect types, inspecting things.   I am an outsider and a freak, but I am trying to make some leaps and bounds to see if I can retrain my brain to code with the standard ... and to see about how I might incorporate this.  I am no professional, just a man who finds the stuff interesting (to say the least).  Other than that I am of an ape-like species facing existential meltdown.  As a species, something is not right, no?  There is an excess if evil.   What is this thing called a "personality" that comes up with a "philosophy" to make some sense of anything?

There is very little real honesty in human interactions, normally.    It is rare.  Here, we have nothing to lose or gain, so we can let it rip as if we were just ghosts.   :D

I will study some programming and prepare my mind for death, somehow.  We all have to prepare ourselves to disintergate into tin air.  This could be fun?   I don't think it will be fun.
___________________________________________
Speaking of ghosts, I recall when my maternal grandmother gave me a snide insult on one Father's Day where all the cousins were gathered.   I am the oldest male, but the one without any "offspring".  My grandmother served my "cake" last with the snide remark, "You're not a father so you get served last."

It is disrespectful to hold such grudges - sorry, I suppose.   That's another thing Denial of Death covers:  these feelings of guilt over our inner hostilities toward kin, starting with conflicting feelings toward parents.    HA!   What a rollercoaster ride from Hell for all of us!
« Last Edit: November 18, 2019, 06:44:14 am by _id_Crisis_ »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4756
  • Life teaches me not to want it.
    • What Now?
This is not something for the everyday gort, so I will be terse

how I use:

cd /mnt/data/code/py
source activate vpy     # the Python environment with 2.7
python julian.py

The menu is then displayed.
If I want to know the day of week that the third of April, 2027 is?
dow
then enter: 2027.04.03
It returns: Saturday

That implies the eagle Shits on a Friday that month, woooo wheeee, one whole day early, which is a godsend for those in dire need of frog skins and debit card cushioning.

footnote ---> frog skin, like "clam," implies currency, as in dollar, in whatever denominations.

how all-too-cyberpunk, old-style, not new style CyberPunkJunk
« Last Edit: January 04, 2020, 10:02:22 am by { .?. } »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Holden

  • { ∅, { ∅ } }
  • Posts: 5070
  • Hentrichian Philosophical Pessimist
Re: Python and Math
« Reply #22 on: January 18, 2020, 11:41:22 am »
“Every good mathematician is at least half a philosopher, and every good philosopher is at least half a mathematician.”

― Gottlob Frege
La Tristesse Durera Toujours                                  (The Sadness Lasts Forever ...)
-van Gogh.