Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
48
Task/Arithmetic-Complex/Yabasic/arithmetic-complex.basic
Normal file
48
Task/Arithmetic-Complex/Yabasic/arithmetic-complex.basic
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rem CADDI/CADDR addition of complex numbers Z1 + Z2 with Z1 = a1 + b1 *i Z2 = a2 + b2*i
|
||||
rem CADDI returns imaginary part and CADDR the real part
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
export sub caddi( a1 , b1 , a2 , b2)
|
||||
return (b1 + b2)
|
||||
end sub
|
||||
export sub caddr( a1 , b1 , a2 , b2)
|
||||
return (a1 + a2)
|
||||
end sub
|
||||
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rem CDIVI/CDIVR division of complex numbers Z1 / Z2 with Z1 = r + s *i Z2 = t + u*i
|
||||
rem CDIVI returns imaginary part and CDIVR the real part
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
export sub cdivi(r,s,t,u)
|
||||
return ((s*t- u*r) / (t^2 + u^2))
|
||||
end sub
|
||||
export sub cdivr( r , s , t , u)
|
||||
return ((r*t- s*u) / (t^2 + u^2))
|
||||
end sub
|
||||
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rem CMULI/CMULR multiplication of complex numbers Z1 * Z2, with Z1 = r + s *i Z2 = t + u*i
|
||||
rem CMULI returns imaginary part and CMULR the real part
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
export sub cmuli( r , s , t , u)
|
||||
return (r * u + s * t)
|
||||
end sub
|
||||
export sub cmulr( r , s , t , u)
|
||||
return (r * t - s * u)
|
||||
end sub
|
||||
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rem CSUBI/CSUBR subtraction of complex numbers Z1 - Z2 with Z1 = a1 + b1 *i Z2 = a2 + b2*i
|
||||
rem CSUBI returns imaginary part and CSUBR the real part
|
||||
rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
export sub csubi( a1 , b1 , a2 , b2)
|
||||
return (b1 - b2)
|
||||
end sub
|
||||
export sub csubr( a1 , b1 , a2 , b2)
|
||||
return (a1 - a2)
|
||||
end sub
|
||||
|
||||
if (peek$("library") = "main") then
|
||||
print "Example: Z1 + Z2 with Z1 = 3 +2i , Z2 = 1-3i: Z1 + Z2 = 4 -1i"
|
||||
print caddr(3,2,1,-2), "/", caddi(3,2,1,-3) // 4/-1
|
||||
end if
|
||||
Loading…
Add table
Add a link
Reference in a new issue