Comments (7)
Sorry, I should have explained that a bit more.
x = z*(2^m)
therefore
z = x/(2^m)
we can choose any m
as long as -1 < z < 1
.
Questions asks for x=3, for which m=2
and z=0.75
works.
Possible pseudo-code for program:
set ln2 = 0.6931472
ask user for value of x
ask user for value of m
calculate z = x/(2^m)
check that -1 < z < 1
calculate xi= (1-z)/(1+z)
calculate lnx = m*ln2 - 2*sum( (xi^(1:N))/(1:N) )
compare with exact value of ln(x)
Can try different values of m
- I think smaller m
will give a larger z
which will give a smaller xi
which will lead to fewer terms necessary for a certain precision.
Hope that helps a bit more.
edit: this repository is a really nice collection of Fortran snippets - great work!
from fcs.
Thank you very much @LKedward
from fcs.
@FortranFan, the exercises appear to be from: Bose, S., 2019. Numerical Methods Of Mathematics Implemented In Fortran. Singapore. Springer. See here on google.
The text does not provide a derivation for the relation; my summary conclusion is that it is an error since z <= 0
implies x <= 0
which would be problematic for then calculating ln(x)
.
As you point out, 0 < z <= 1
appear to be the correct bounds for z
here.
from fcs.
I think m=2
and z=0.75
perhaps?
from fcs.
I think
m=2
andz=0.75
perhaps?
How?
from fcs.
Can you provide a reference to a derivation for the relationship you show in the original post?
A quick glance suggests the series is divergent for z <= 0, so a numerical approach is unclear for -1 <= z <= 0.
When z > 0, xi < 1, so one can compute the series numerically to determine lnx.
from fcs.
One derivation of the relation in the original post follows from the identities
y(z) = (1-z)/(1+z)
z(y) = (1-y)/(1+y)
From this, it follows that
ln(z) = ln(1-y) - ln(1+y)
Taylor expansion at y=0 on the right then gives the result shown in the original post where all of the even terms vanish. The radius of convergence of ln() on the right is -1<y<1. However, convergence is slow for large |y|, so the only useful values for computation are when y is small, which is when z is near +1. Thus in the computation where x is given, m should be chosen to make z<=1 as close to 1 as possible.
from fcs.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fcs.