fun1.js

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3780/spring2026/notes/javascript/code/newton/fun1.js
 
"use strict"

import { Complex } from './complex.js';

const ONE = new Complex(1,0);
const THREE = new Complex(3,0);

// z^3 - 1
export function F(z) {
   let rv = new Complex(z.Real(), z.Imag());
   rv = rv.Mult(rv);   // z^2
   rv = rv.Mult(z);    // z^3
   rv = rv.Sub(ONE);
   return rv;
}

// 3 z^2
export function FPrime(z) {
   let rv = new Complex(z.Real(), z.Imag());
   rv = rv.Mult(rv);  // z^2
   rv = rv.Mult(THREE);
   return rv;
}

export function FunctionName() {
    return "F(z) = z^3  - 1";
}