2024-10-27 21:56:24 +01:00
|
|
|
#!/usr/bin/env julia
|
|
|
|
|
|
|
|
# Jacek Poziemski 272389
|
|
|
|
|
|
|
|
"""
|
2024-11-08 10:54:40 +01:00
|
|
|
f(x::Float64)::Float64
|
2024-10-27 21:56:24 +01:00
|
|
|
|
|
|
|
Calculate `sqrt(x^2 + 1) - 1`.
|
|
|
|
|
|
|
|
# Arguments
|
|
|
|
- `x::Float64`: function argument
|
|
|
|
"""
|
2024-11-08 12:29:30 +01:00
|
|
|
f(x::Float64)::Float64 = sqrt(x^2 + one(Float64)) - one(Float64)
|
2024-10-27 21:56:24 +01:00
|
|
|
|
|
|
|
"""
|
2024-11-08 10:54:40 +01:00
|
|
|
g(x::Float64)::Float64
|
2024-10-27 21:56:24 +01:00
|
|
|
|
|
|
|
Calculate `x^2 / (sqrt(x^2 + 1) + 1)`.
|
|
|
|
|
|
|
|
# Arguments
|
|
|
|
- `x::Float64`: function argument
|
|
|
|
"""
|
2024-11-08 12:29:30 +01:00
|
|
|
g(x::Float64)::Float64 = x^2 / (sqrt(x^2 + one(Float64)) + one(Float64))
|
2024-10-27 21:56:24 +01:00
|
|
|
|
2024-11-08 10:54:40 +01:00
|
|
|
for i::Int in 1:20
|
2024-10-27 21:56:24 +01:00
|
|
|
x::Float64 = 8.0^(-i)
|
|
|
|
println("f(8^-$i) = $(f(x))")
|
|
|
|
println("g(8^-$i) = $(g(x))")
|
|
|
|
end
|