Mathworks Interview Question for Development Support Engineers






Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use Taylor series:
sin(x) = x / 1! - x^3 / 3! + x^5 / 5! - ...

- thomas November 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//Taylor Series Approximation
        double theta = 45; //45 degrees
	double PIby180 = 3.14159265358979323846264338327950/180;
	double x = theta*PIby180;
        double sinx = x*(1 - (x*x)*(1 - (x*x)*(1 - (x*x)/(6*7) ) / (4*5) ) /(2*3) );
	x = (theta+90)*PIby180;
	double cosx = x*(1 - (x*x)*(1 - (x*x)*(1 - (x*x)/(6*7) ) / (4*5) ) /(2*3) );

- blueskin.neo November 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

const double PI = 3.14159265358979323846264338327950;
const double epsilon = 0.000000000000000000000000001;

//sinx = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ...
//this is not for old-fashioned handhold calculator
double sine(double x){
x = x - 2 * PI * (int)((x + PI)/(2*PI)); //put x in the interval (-PI, PI]
double result = x;
flip = 1;
xsquare = x * x;
xexp = x;
fac = 1;
curOrder = 1;
double oldvalue = 0;
while (abs(result - oldvalue) > epsilon){
oldvalue = result;
flip = flip * -1;
fac = fac * (curOrder + 1) * (curOrder + 2);
curOrder += 2;
xexp *= xexp * xsqure;
result = result + flip * xexp / fac;
}
return result;
}

- css February 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

i think it should be xexp = xexp*xsquare;
perhaps you meant to write: xexp *= xsquare;

- nharryp March 28, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More