Skip to content

RockfordWei/NewtonRaphson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NewtonRaphson

Newton Raphson Method to solve an equation

Assuming f(x) = x^ + 2x, so the differential function f'(x) = 2x + 2

giving an initial value of x0 = 1, so the equation can be solved by this snippet:

let solver = NewtonRaphson(
   initialValue: 1,
   function: { x in
       return x * x + 2 * x
   }, differential: { x in
       return 2 * x + 2
   })
let result = try solver.solve()
XCTAssertEqual(result.x, 0)

Releases

No releases published

Packages

No packages published

Languages