$SPAD/src/input newton.input

Timothy Daly December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool newton.output
)set message test on
)set message auto off
)clear all

———-

2 Newton’s Iteration function

The function newtonStep(f) returns a newton’s iteration function for the expression f.

— * —

--S 1 of 5
newtonStep(f) ==
  fun  := complexNumericFunction f
  deriv := complexDerivativeFunction(f,1)
  (b:Complex DoubleFloat):Complex DoubleFloat +->
    b - fun(b)/deriv(b)
--R
--R                                                                   Type: Void
--E 1

———-

Create complex numeric functions from an expression — * —

--S 2 of 5
complexFunPack := _
  MakeUnaryCompiledFunction(EXPR INT, Complex DoubleFloat, Complex DoubleFloat)
--R
--R
--R   (2)
--R  MakeUnaryCompiledFunction(Expression(Integer),Complex(DoubleFloat),Complex(Do
--R  ubleFloat))
--R                                                                 Type: Domain
--E 2

———-

Create a complex numeric function from an expression — * —

--S 3 of 5
complexNumericFunction x ==
  v := theVariable x
  compiledFunction(x, v)$complexFunPack
--R
--R                                                                   Type: Void
--E 3

———-

Create a complex numeric derivatiave function from an expression — * —

--S 4 of 5
complexDerivativeFunction(x,n) ==
  v := theVariable x
  df := differentiate(x,v,n)
  compiledFunction(df, v)$complexFunPack
--R
--R                                                                   Type: Void
--E 4

———-

Return the unique variable in x, or an error if it is multivariate — * —

--S 5 of 5
theVariable x ==
  vl := variables x
  nv := # vl
  nv > 1 => error "Expression is not univariate."
  nv = 0 => 'x
  first vl
--R
--R                                                                   Type: Void
--E 5
)spool
)lisp (bye)

———-

References^{[1] nothing}

5