README.md in dydx-0.1.2 vs README.md in dydx-0.1.3

- old
+ new

@@ -1,91 +1,132 @@ -# Dydx -It always happens you want to differentiate some formulas with ruby. right?..... +# Dydx is new math DSL in Ruby +### Since you report a bug, I will fix it within 24 hours. + +The most important thing in this DSL is + +we can handle math in the same sense sense of the math on paper. + +ex. limit, trigonometric functions and logarithmic. + + After `inlcude Dydx` , ruby become like other language. -``` +## Outline +```ruby: require 'dydx' include Dydx -# There are three types of differential interface +# Define the function. syntax is not good enough... +f(x) <= x ^ 2 -( d/dx(x^2) ).to_s -=> "( 2 * x )" +f(3) +=> 9 -log(z).d(z).to_s -=> "( 1 / z )" +f(x).to_s +=> "( x ^ 2 )" -$y = e ^ x -(dy/dx).to_s -=> "( e ^ x )" +f(x) == eval('f(x).to_s') +=> true -``` +# Differentiate +g(x) <= d/dx(f(x)) -You may wonder why undefined `x` , `e` and `z` are handleable? +g(3) +=> 6 -`method_missing` solve this problem by converting undefine variable into internal class object. +g(x).to_s +=> '2 * x' -Like this. - +# Integrate +S(f(x), dx)[0, 1] +=> 0.3333333333333334 ``` - x + x -=> #<Dydx::Algebra::Formula:0x007fb0a4039fb0 @f=#<Dydx::Algebra::Set::Num:0x007fb0a48169e0 @n=2>, @operator=:*, @g=:x> -e -=> #<Dydx::Algebra::Set::E:0x007fb0a383e9f0> -log(sin(x)) -=> #<Dydx::Algebra::Set::Log:0x007fe7cd971528 @f=#<Dydx::Algebra::Set::Sin:0x007fe7cd971550 @x=:x>> -``` +#### limit, trigonometric functions and logarithmic. +```ruby: -And this DSL has strong simplify. +f(z) <= log(z) +S(f(z), dz)[0,1] +=> -Infinity -``` -((x * y) + (z * x)).to_s -=> "( x * ( y + z ) )" +( d/dx(log(x)) ).to_s +=> "( 1 / x )" -((x ^ y) / (x ^ z)).to_s -=> "( x ^ ( y - z ) )" +( d/dx(cos(x)) ).to_s +=> "( - sin( x ) )" -(x + x).to_s -=> "( 2 * x )" -``` +( d/dx(e ^ x) ).to_s +=> "( e ^ x )" -I show some differential calculus. +f(x) <= sin(x) +S(f(x), dx)[0, Math::PI/2] +=> 1.000000000021139 +# standard normal distribution; +f(x) <= (1.0 / ( ( 2.0 * pi ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) ) +S(f(x), dx)[-oo, oo] +=> 0.9952054164466917 ``` -# pretermit '#to_s' -d/dz(log(z)) -=> "( 1 / z )" +#### it's like a magic... -d/dx(x^n) -=> "( n * ( x ^ ( n - 1 ) ) )" +```ruby: +f(x) <= x ^ 2 -$y = cos(x) -dy/dx -=> "( - sin( x ) )" +f(a + b).to_s +=> "( ( a + b ) ^ 2 )" -$x = a * ( (t ^ 2) / 2 ) -dx/dt -=> "( a * t )" +#↓it"s magic!!! +g(a, b) <= f(a + b) -d/dt(dx/dt) -=>"a" +g(a, b).to_s +=> "( ( a + b ) ^ 2 )" -((x ^ 2) * y).d(x) -=> "( ( 2 * x ) * y )" +g(2, 2) +=> 16 -((x ^ 2) * y).d(x).d(y) -=> "( 2 * x )" +( d/da(g(a, b)) ).to_s +=> "( 2 * ( a + b ) )" +# simplify +((x * y) + (z * x)).to_s +=> "( x * ( y + z ) )" + +((x ^ y) / (x ^ z)).to_s +=> "( x ^ ( y - z ) )" + +(x + x).to_s +=> "( 2 * x )" ``` -(That's wonderful!!!!! ..............) +## Documents +I'm going to write now...cominng soon.... +### Module, class configuration + +``` +Dydx + |- Algebra + | |- Set + | | |- Num + | | |- .... + | | + | |- Operator + | | |- Interface + | | |- .... + | | + | |- Formula + | |- inverse + | + |- Function + |- Delta + |- Integrand +``` + ## Installation Add this line to your application's Gemfile: gem 'dydx' @@ -113,8 +154,8 @@ ## Test run `bundle exec rake spec` ``` -Finished in 0.11282 seconds -231 examples, 0 failures +Finished in 3.23 seconds +309 examples, 0 failures ```