473,595 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1877
sk***********@g mail.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...@g mail.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***********@g mail.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
1689
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 American patent 4919933, the Taiwanese patent 37414, the Japanese patent 2733523 and a Korean patent 044435 through The Korean Jungang International Patent Law Office(Address : 5th Floor, Jae Insurance Bld, #80, Susong-Dong, Jongro-Gu, Seoul, the...
33
2688
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 it, neither love nor hate. Thanks, Larry.
45
3379
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 relationship spaghetti....tables/queries all overthe place with lots of relationship lines between here and there. After that first app I didn't do relationships. If I had a query, I defined the relationship. Many of the times when I create a...
13
2235
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 program would contain lots of little utility functions which do small amounts of work. None of these would actually be run. Rather, they would be typecast as strings and those strings would be examined by the program. In otherwords, the...
10
1329
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, ran my program to see the result, then UNDO to get my objects back.
72
2321
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
3304
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) My.Settings.Brkr2 = BreakerAmps(2) My.Settings.Brkr3 = BreakerAmps(3) My.Settings.Brkr4 = BreakerAmps(4) My.Settings.Brkr5 = BreakerAmps(5)
4
2484
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 is the best place I can go to get a job using dotnet? I have been programming for 2 years in dotnet and have MSSQL experience. My current title says "Junior Programmer" but I think I have sufficient experience now to drop off the "junior" prefix....
0
7955
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7883
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.