Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Regula falsi

  • Loading branch information...
commit 8d4b39fbe48f2a91b57704a4d24173d34edd4f44 1 parent f38a8e8
Andreas Pauley authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 Chapter1/regula-falsi.scm
21 Chapter1/regula-falsi.scm
View
@@ -0,0 +1,21 @@
+;; The Method of False Position (Regula Falsi)
+;; Section 1.2, p. 40 of Applied Numerical Analysis
+
+;; This method is similar to the secant method, except that
+;; (f x0) and (f x1) need to bracket the root (have opposite signs),
+;; like the bisection method.
+
+(load "helpers")
+(define (regula-falsi f x0 x1)
+ (define x2 (linear-interpolate f x0 x1))
+ (define (opposite-sign? value1 value2)
+ (<= (* value1 value2) 0))
+
+ (println x0 " " x1 " " x2 " " (f x2))
+ (if (close-enough-to-zero? (f x2))
+ x2
+ (if (opposite-sign? (f x2) (f x0))
+ (regula-falsi f x0 x2)
+ (regula-falsi f x2 x1))))
+
+(println (regula-falsi example-f 0 1))
Please sign in to comment.
Something went wrong with that request. Please try again.