README.md in dydx-0.1.4 vs README.md in dydx-0.1.25

- old
+ new

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