[Updated] Help output algorithms for complex numbers in Pascal Triangle

Yeah I thought that QScript would be useful but I can’t seem to figure out how to use the operations in even simple code.

for just multiplying two sets of complex numbers I’m stuck at here:
[I was helped with complex number multiplication in another thread (How to multiply (a + bi)(a + bi) with this Complex Number Class?) but it’s not using QScript and trying to use QScript operators with the same method has got me confused.]

import org.qscript.*;
import org.qscript.editor.*;
import org.qscript.errors.*;
import org.qscript.events.*;
import org.qscript.eventsonfire.*;
import org.qscript.operator.*;

Complex z1 = new Complex(2.0, 3.0);
Complex z2 = new Complex(2.0, 3.0);

Complex result = mult(Complex z1, Complex z2);
println(result);

and for the complex numbers to an exponent all I’ve been able to identify in QScript is this, but not how to actually use it:

	/**
	 * Returns the exponential of this number (e^z)
	 */
	public Complex exp() {
		Complex c, d;
		double a, b;
		a = Math.exp(real);
		b = Math.cos(imag);
		c = Z_0_1i.mult(Math.sin(imag));
		d = add(b, c);
		return mult(a, d);
	}

Edit: This method while applicable isn’t the route I’m looking to take, as shown in the following post. (This is the reason I’m moving the thread from the Libraries back to the Coding Questions Section)

1 Like