473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can anyone please help me with these? I did save America, a few times...

#1 in Calculus you learned that
log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ...

for x in the interval (-1,1] (here x^2 means "x squared", etc.).
Write a program which asks the user to type a number in the interval
[1,2] and then calculates the natural logarithm of that number using
this series with 6 decimal places accuracy (you can use the
alternating harmonic series program as a template).
#2 Modify the program from the first problem and define a function
caled mylog which gives the natural logarithm of a number in the
interval [1,2] using the above series with the six decimal places
accuracy. Use this function in a program which to prints a table which
has 1.0, 1.1, 1.2, 1.3, ... , 2.0 in the first column, the value of
your function mylog for these numbers in the second column, and the
machine values of log for these numbers in the third column.
Check for the accuracy of your computation by comparing the values in
the second and third column. Observe that it takes much longer to
calculate log(2.0) than any other entry in the table. Can you tell
why?
#3 Modify the program for the second problem in the first assignment
so that the table of logarithms is written to a file named output.txt
instead of the standard output.

Mar 5 '07 #1
4 1863
sk***********@gmail.com writes:
Subject: Can anyone please help me with these? I did save
America, a few times...
Sorry, we don't do homework. Not even Brian Boitano's homework.
--
"This is a wonderful answer.
It's off-topic, it's incorrect, and it doesn't answer the question."
--Richard Heathfield
Mar 5 '07 #2
On Mar 4, 8:59 pm, skatemore9...@gmail.com wrote:
#1 in Calculus you learned that

log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ...

for x in the interval (-1,1] (here x^2 means "x squared", etc.).
Write a program which asks the user to type a number in the interval
[1,2] and then calculates the natural logarithm of that number using
this series with 6 decimal places accuracy (you can use the
alternating harmonic series program as a template).
#2 Modify the program from the first problem and define a function
caled mylog which gives the natural logarithm of a number in the
interval [1,2] using the above series with the six decimal places
accuracy. Use this function in a program which to prints a table which
has 1.0, 1.1, 1.2, 1.3, ... , 2.0 in the first column, the value of
your function mylog for these numbers in the second column, and the
machine values of log for these numbers in the third column.
Check for the accuracy of your computation by comparing the values in
the second and third column. Observe that it takes much longer to
calculate log(2.0) than any other entry in the table. Can you tell
why?
#3 Modify the program for the second problem in the first assignment
so that the table of logarithms is written to a file named output.txt
instead of the standard output.
At least have enough decency to try to disguise your homework!!!

Mar 5 '07 #3
At about the time of 3/4/2007 5:59 PM, sk***********@gmail.com stated
the following:
#1 in Calculus you learned that
log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ...

for x in the interval (-1,1] (here x^2 means "x squared", etc.).
Write a program which asks the user to type a number in the interval
[1,2] and then calculates the natural logarithm of that number using
this series with 6 decimal places accuracy (you can use the
alternating harmonic series program as a template).
#2 Modify the program from the first problem and define a function
caled mylog which gives the natural logarithm of a number in the
interval [1,2] using the above series with the six decimal places
accuracy. Use this function in a program which to prints a table which
has 1.0, 1.1, 1.2, 1.3, ... , 2.0 in the first column, the value of
your function mylog for these numbers in the second column, and the
machine values of log for these numbers in the third column.
Check for the accuracy of your computation by comparing the values in
the second and third column. Observe that it takes much longer to
calculate log(2.0) than any other entry in the table. Can you tell
why?
#3 Modify the program for the second problem in the first assignment
so that the table of logarithms is written to a file named output.txt
instead of the standard output.
Did you make an attempt? We'll help if you show that you made an
attempt by posting your code.

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Mar 5 '07 #4
<sk***********@gmail.comwrote:
#1 in Calculus you learned that
log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ...

for x in the interval (-1,1] (here x^2 means "x squared", etc.).
Write a program which asks the user to type a number in the interval
[1,2] and then calculates the natural logarithm of that number using
this series with 6 decimal places accuracy (you can use the
alternating harmonic series program as a template).
Firstly, ignore exercises 2 and 3. They may just cloud your mind with a
fear factor. I would also ignore the parenthetical sentence above. It just
makes me wonder "What program? What is a template"? The equation is there,
use the damned equation. If you wrote some program in a prior assignment,
part of that may make sense to you. It's just obfuscating to me,

I would write three functions. Main deals with the user, getting sample
input and reporting the answers. A ln function would do the overall stuff
in the equation, including deciding when the precision was good enough.
Then I would write a function to compute an individual term for all terms
except the first. Note that each term is a nice little bundle and you can
determine the sign from within the "bundle" I would call the term function
from a for loop in the ln function. If the value returned by term is less
than some epsilon, say 1e-6, the precision is adequate and you can bail out
of the for loop.

I would put a detection mechanism at the start of the ln function to detect
out of range arguments.

Compile and test often. Sounds like it should be both fun and instructive
Mar 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Yeongja_Choi | last post by:
How Dare Could America Industrial Property Office Be In Conspiracy With Jungang International Patent Office To Make An Extravagant International Crime ? Currently a Korean party now holds the...
33
by: Larry | last post by:
Does anyone use the 3rd party utility CodeRush for VStudio? If so then I would like to see how well it is loved or hated. I have been using the trial for a week and I have a mixed opinion about...
45
by: salad | last post by:
I'm curious about your opinion on setting relationships. When I designed my first app in Access I'd go to Tools/Relationships and set the relationships. Over time I'd go into the window and see...
13
by: Snis Pilbor | last post by:
Hello, Here is an idea I've been toying with to speed up programs but still keep them portable. It's just a very handwavey rough description right now since I haven't worked out details. The...
10
by: =?Utf-8?B?am9uaWdy?= | last post by:
New to VB.NET, designing my first form with an MS manual at my side, placing objects and writing code. For good reason I just: SAVED All (!!) deleted all objects leaving only a grey form,...
72
by: dbahooker | last post by:
hey guys I just wanted to send a reminder out to you all.. if you've got a brain then sign this petition http://classicvb.org/petition/ THANKS! -Aaron
7
by: Just_a_fan | last post by:
I save some data to an array in my program. I can reopen the setting screen and see that the data is, in fact, in the array. I then do a lot of these: My.Settings.Brkr1 = BreakerAmps(1)...
4
by: James Cooke | last post by:
I've just been laid off and I am freaking out (new wife, new baby 2 months away, new house yada yada yada). (not recommended at this time) Apart from the usual jobsites, (dice, monster etc) what...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.