QuestionQuestion

Transcribed TextTranscribed Text

Computer Programming for Scientists and Engineers Question 2 The purpose of this question is to write a program that computes the approximate value of eix, where x > 0 and i=√−1. It is obvious that eix may have real and imaginary parts. Your program must get the maximum acceptable tolerance for both real and imaginary part of result in the input and the value of x. Hint: Based on the Euler equation: . Therefore, if you write code for estimating cos (x) and sin (x) separately, it can be easier to estimate eix. Compute the value of eix using Python's exp function and display the value to 14 decimal places using exponential format. Using the exp function and the value that your code has estimated for eix and calculate the actual tolerance by subtracting the estimated and actual values of both real and imaginary parts. If the tolerance is less than or equal to the acceptable input tolerance for both real and imaginary parts, stop the code and print the result and tolerance in the output. Also, you have to mention how many terms it needs for both real and imaginary part to obtain the entered tolerance. Be careful that you have to use exp function from cmath library for this question because your numbers are complex numbers. Following you can see the output of the proper answer for desired 10-7 tolerance and 10 degrees as x. ------------------------------------------------------------- Enter the acceptable tolerance: 1e-7 Enter an angle in degrees: 10 Angle in radians = 0.174533, angle in degrees = 10.00 Python's value of e^ix(10.00) = 0.984807753012208 + 0.173648177666930 i Approximate value of e^ix(10.00) = 0.984807792249180 + 0.173648178645355 i Number of terms 4 for real part and 4 for imaginary part Tolerance= -0.000000039236972 + -0.000000000978424 i Programmed by Stew Dent. Date: Sun May 12 21:03:47 2019 End of processing. Test your program using different values of x including 1and tolerance. Make sure that your code is working properly and there is not any syntax error in it.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

from time import ctime
import cmath
import math
import numpy as np

print('\n---------------------------------------------\n')

tolerance = input("Enter the acceptable tolerance: ")

print ("\n")

angle_degree = input("Ente...

By purchasing this solution you'll be able to access the following files:
Solution.py.

$10.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats