How to resolve the algorithm Roots of a function step by step in the PicoLisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Roots of a function step by step in the PicoLisp programming language

Table of Contents

Problem Statement

Create a program that finds and outputs the roots of a given function, range and (if applicable) step width.
The program should identify whether the root is exact or approximate.

For this task, use:     ƒ(x)   =   x3 - 3x2 + 2x

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Roots of a function step by step in the PicoLisp programming language

Source code in the picolisp programming language

(de findRoots (F Start Stop Step Eps)
   (filter
      '((N) (> Eps (abs (F N))))
      (range Start Stop Step) ) )

(scl 12)

(mapcar round
   (findRoots
      '((X) (+ (*/ X X X `(* 1.0 1.0)) (*/ -3 X X 1.0) (* 2 X)))
      -1.0 3.0 0.0001 0.00000001 ) )

  

You may also check:How to resolve the algorithm Binary digits step by step in the Rust programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the Cubescript programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Haskell programming language
You may also check:How to resolve the algorithm Keyboard input/Keypress check step by step in the Wee Basic programming language
You may also check:How to resolve the algorithm Arrays step by step in the Perl programming language