## Question

## Transcribed 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 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...

This is only a preview of the solution. Please use the purchase button to see the entire solution