Scipy - Python library - Math tool - Begin

Introduction

Scientific Computing Tools for Python. Seen in Scipy.org.

Environment

Linux, CentOS 7 with KDE, python 2.7

Installation

1 python -m pip install --upgrade pip
2 # Do not use sudo for the next command
3 pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
4 # change the environment
5 vim ~/.bashrc
6 # export PATH=$PATH:/home/leaf/.local/bin

A simple demo to solve a Bessel function

Bessel function:  most commonly, the canonical solutions y(x) of the differential equation. Seen in wiki.

Code (Python):

1 from matplotlib.pyplot import *
2 from numpy import *
3 from scipy import special, optimize
4 f = lambda x: -special.jv(3,x)
5 sol = optimize.minimize(f, 1.0)
6 x = linspace(0, 10, 5000)
7 x
8 plot(x, special.jv(3, x), ‘-‘, sol.x, -sol.fun, ‘o‘)
9 savefig(‘plot.png‘, dpi=96)

Result:

Simple case. Just for the beginning of applying Scipy.

时间: 2025-01-02 03:32:08

Scipy - Python library - Math tool - Begin的相关文章

Theano is a Python library: A CPU and GPU math expression compiler

Welcome¶ Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. Theano features: tight integration with NumPy – Use numpy.ndarray in Theano-compiled functi

Where is the python library installed?

configure: error: Could not link test program to Python. Maybe the main Python library has been installed in some non-standard library path. If so, pass it to configure, via the LDFLAGS environment variable. Example: ./configure LDFLAGS="-L/usr/non-s

kivy.org - Open source Python library for rapid development of applications

kivy.org - Open source Python library for rapid development of applicationsthat make use of innovative user interfaces, such as multi-touch apps. ????. 原文地址:https://www.cnblogs.com/edisp/p/10358625.html

python 实现 math.log(x,base)

python 用闭包实现math.log(x,base) #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys,math import random import pprint def log(n,d): i = 0 status = 0 while True: if d**i==n: status=1 break elif d**i<n<d**(i+1): break i+=1 def test(level=100): if status

Python library note-collection

Reference: https://docs.python.org/2/library/collections.html namedtuple() factory function for creating tuple subclasses with named fields deque list-like container with fast appends and pops on either end Counter dict subclass for counting hashable

Python STL math&amp;cmath

Python标准库math math所提供的数学常量 pi 数学常量 pi,所属的变量空间为标准库math e 数学常量 e,e即自然常数,所属的变量空间为标准库math math库中常用的函数 三角函数 函数名 格式 功能 sin sin(x) 返回的x弧度的正弦值 cos cos(x) 返回的x弧度的余弦值 tan tan(x) 返回的x弧度的正切值 asin asin(x) 返回x的反正弦弧度值. acos acos(x) 返回x的反余弦弧度值. atan atan(x) 返回x的反正切弧

【python】math模块的使用

1 import math 2 print math.sin (0.5) 3 print math.cos (0.5) 关键点: 1.sin.cos等数学符号后面要加括号(),括号内的参数为弧度制表示法(我也忘了什么是弧度制了...) 2.调用sin.cos的时候,要用math.sin(),math.cos(),而不是sin(),cos(). !!!

python之math模块

1.math简介 >>>import math #导入math模块 >>>dir(math) #这句可查看所有函数名列表 >>>help(math) #查看具体定义及函数原型 2.常用函数 acos(x) # Return the arc cosine (measured in radians) of x. asin(x) # Return the arc sine (measured in radians) of x. atan(x) # Retur

由python的math.log想到的问题

result = math.log(243,3) print(result) 输出5.0 print("%f"%result) 还是输出5.0 看出问题了吗?对,没错.int(5.0) = 4????? 不只是这个,还有取余 5.0 mod 1 为 1????? 经过和同学的激烈讨论. 得出了这么一个结论. 其实result = math.log(243,3) ,返回的result是4.9999(具体多少个9)不清楚,总之不是我们觉得应该的5. 所以可以解答上面的疑惑了. 1.int(