obliczenia_naukowe/l1/6.jl
2024-11-08 10:54:40 +01:00

33 lines
585 B
Julia
Executable file

#!/usr/bin/env julia
# Jacek Poziemski 272389
"""
f(x::Float64)::Float64
Calculate `sqrt(x^2 + 1) - 1`.
# Arguments
- `x::Float64`: function argument
"""
function f(x::Float64)::Float64
return sqrt(x^2 + one(Float64)) - one(Float64)
end
"""
g(x::Float64)::Float64
Calculate `x^2 / (sqrt(x^2 + 1) + 1)`.
# Arguments
- `x::Float64`: function argument
"""
function g(x::Float64)::Float64
return x^2 / (sqrt(x^2 + one(Float64)) + one(Float64))
end
for i::Int in 1:20
x::Float64 = 8.0^(-i)
println("f(8^-$i) = $(f(x))")
println("g(8^-$i) = $(g(x))")
end