Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Numerical differentiation

node v8.17.0
version: 3.0.0
endpointsharetweet
const { Stack } = require('@hypercubed/f-flat'); const f = new Stack(); f.eval(` math: rcl use core: rcl use shuffle: rcl use 200 set-precision nd: [ dup [ over + rot bi@ - ] dip / ] ; // forward difference approximation to the derivative `).stack;
Setup f-flat with required modules and define the forward difference approximation to the derivative
f.eval(` [exp] 1 1e-100 nd `).stack[0].toString();
d(exp(x)) / dx => exp(x) exp(x) | x = 1 => e
f.eval(` clr [ dup sqrt * ] -1 1e-100 nd `).stack[0].toString();
d(x*sqrt(x))/dx => 3*sqrt(x)/2 3*sqrt(x)/2 | x = 1 => 3 / 2 * i
f.eval(` clr [ inv ] 0 1e-100 nd `).stack[0].toString();
d(1/x)/dx => -1/x^2 -1/x^2 | x = 0 => -Infinity
Loading…

no comments

    sign in to comment