Arithmetic/Complex: Difference between revisions
Content deleted Content added
Add Lang example |
m Fix ordering of Lambdatalk and Lang |
||
Line 2,871:
x* = 1.0 - 3.0i
</pre>
=={{header|Lambdatalk}}==▼
<syntaxhighlight lang="scheme">▼
{require lib_complex}▼
{def z1 {C.new 1 1}} ▼
-> z1 = (1 1)▼
{C.x {z1}} -> 1▼
{C.y {z1}} -> 1▼
{C.mod {z1}} -> 1.4142135623730951▼
{C.arg {z1}} -> 0.7853981633974483 // 45°▼
{C.conj {z1}} -> (1 -1)▼
{C.negat {z1}} -> (-1 -1)▼
{C.invert {z1}} -> (0.5 -0.4999999999999999)▼
{C.sqrt {z1}} -> (1.0986841134678098 0.45508986056222733)▼
{C.exp {z1}} -> (1.4686939399158851 2.2873552871788423)▼
{C.log {z1}} -> (0.3465735902799727 0.7853981633974483) ▼
{def z2 {C.new 1.5 1.5}}▼
-> z2 = (1.5 1.5)▼
{C.add {z1} {z2}} -> (2.5 2.5)▼
{C.sub {z1} {z2}} -> (-0.5 -0.5)▼
{C.mul {z1} {z2}} -> (0 3)▼
{C.div {z1} {z2}} -> (0.6666666666666667 0)▼
</syntaxhighlight>▼
=={{header|Lang}}==
Line 2,915 ⟶ 2,942:
conj(a) = 1.500-3.000i
</pre>
▲=={{header|Lambdatalk}}==
▲<syntaxhighlight lang="scheme">
▲{require lib_complex}
▲{def z1 {C.new 1 1}}
▲-> z1 = (1 1)
▲{C.x {z1}} -> 1
▲{C.y {z1}} -> 1
▲{C.mod {z1}} -> 1.4142135623730951
▲{C.arg {z1}} -> 0.7853981633974483 // 45°
▲{C.conj {z1}} -> (1 -1)
▲{C.negat {z1}} -> (-1 -1)
▲{C.invert {z1}} -> (0.5 -0.4999999999999999)
▲{C.sqrt {z1}} -> (1.0986841134678098 0.45508986056222733)
▲{C.exp {z1}} -> (1.4686939399158851 2.2873552871788423)
▲{C.log {z1}} -> (0.3465735902799727 0.7853981633974483)
▲{def z2 {C.new 1.5 1.5}}
▲-> z2 = (1.5 1.5)
▲{C.add {z1} {z2}} -> (2.5 2.5)
▲{C.sub {z1} {z2}} -> (-0.5 -0.5)
▲{C.mul {z1} {z2}} -> (0 3)
▲{C.div {z1} {z2}} -> (0.6666666666666667 0)
▲</syntaxhighlight>
=={{header|LFE}}==
|