Sha256: f8c3641f73ea12d5e79fab4bfcefe63a503322376aa365fd38741cad0d60891d
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
require 'spec_helper' describe Dydx::Delta do it { expect(d.class).to eq(Delta) } it { expect(dx.class).to eq(Delta) } it { expect(dx.var).to eq(:x) } it { expect(dx(y).class).to eq(Delta) } it { expect(dx(y).var).to eq(:x) } it { expect(dx(y).function).to eq(:y) } it { expect { dxy }.to raise_error(NameError) } before { reset } it 'ex1' do $y = x ** n expect(d/dx($y)).to eq( n * ( x ** ( n - 1 ) )) end it 'ex2' do $y = x ** (x * 2) expect( eval((d/dx($y)).to_s) ).to eq( ( ( x ** ( 2 * x ) ) * ( 2 * ( 1 + log( x ) ) ) ) ) end it 'ex3' do $y = (t ** 2) / 2 expect(dy/dt).to eq(t) end it 'ex4' do $y = 2 * (e ** (2 * z)) expect(dy/dz).to eq(4 * ( e ** ( 2 * z ) )) end it 'ex5' do $y = 2 ** x expect(dy/dx).to eq(( 2 ** x ) * log( 2 )) end it 'ex6' do $y = x ** x expect(dy/dx).to eq(x ** x * (log(x) + 1)) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dydx-0.2.7000001 | spec/lib/delta_spec.rb |
dydx-0.2.7000000 | spec/lib/delta_spec.rb |
dydx-0.1.41421 | spec/lib/delta_spec.rb |