Back to Blog

Tag: Playground


Newton Raphson method for finding roots of a cubic equation [Swift 3]

This is the most basic implementation of NR method to find root of a cubic equation! import UIKit var a = Double() var b = Double() var c = Double() var d = Double() func calc(a:Double,b:Double,c:Double,d:Double) { var rootArray = [Double]() var fvalueArray = [Double]() var fdvalueArray = [Double]() var solved = false if !solved { for i in 0...10…
Continue Reading