示例#1
0
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
#
# pyderiv is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyderiv.  If not, see <http://www.gnu.org/licenses/>.

# Example usage:

import deriv

x = deriv.varying(5)
y = deriv.varying(-7)

r = (x * x + y * y) ** .5

print "r", deriv.v(r)
print "dr/dx", deriv.v(deriv.d(r, x))
print "dr/dy", deriv.v(deriv.d(r, y))
print "d2r/dx2", deriv.v(deriv.d(r, x, x))
print "d2r/dy2", deriv.v(deriv.d(r, y, y))
print "d2r/dx/dy", deriv.v(deriv.d(r, x, y))
print "d2r/dy/dx", deriv.v(deriv.d(r, y, x))

print

r = deriv.sin(x)
示例#2
0
文件: noise.py 项目: forrestv/pyderiv
def noise2(variance):
    assert variance >= 0
    return math.sqrt(variance) * deriv.varying(0, noise=True)