项目作者: PSS1998

项目描述 :
A Flexible math library for python
高级语言: Python
项目地址: git://github.com/PSS1998/Math-Library.git
创建时间: 2020-08-25T08:59:31Z
项目社区:https://github.com/PSS1998/Math-Library

开源协议:

下载


Math Library

this is a math library written in python. You can create a math expression containing numbers, variables and functions. You can also set a value for each variable. You can get the deriative of any expression with this library and finaly you can add your own function to the library from client side without adding code to the library.

TODO

1- adding integral ability

2- adding more predefined functions.

3- adding a parser so users can use a more math friendly interface.


Test

for running the testcases you only need to run the following command.

python3 testcase.py

there are 9 tests in this file and each test will print one final value.

test 1: 5(x^2)+2 , x=2 => result = 22

test 2: 5
(x^2)+2+y , x=2 , y=3 => result = 25

test 3: 5(x^2)+2+y , deriative based on y => result = 1

test 4: 5
(x^2)+2+y , deriative based on x , x=2 => result = 20

test 5: 5(x^2)+2+y , deriative based on x , deriative based on x => result = 10

test 6: sin(5
(x^2)+2+y) , x=2, y=3 => result = sin(25) = -0.13235175009

test 7: sin(5x+2) , deriative based on x , x=2 => result = 5(cos(12)) = 4.21926979366

test 8: (funcx)+5 , func=5(x^2)+2+y , deriative based on x , x=3 , y=10 => result = 5(x^3)+2x+yx+5 = 15(x^2)+2+y = 135+2+10 = 147

test 9: func(x,y) , func=5*(x^2)+2+y , y=3x , x=3 => result = 5(x^2)+2+3x = 45+2+9 = 56