Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Jeremy G.
Freelance Tutor for 3 Years, CS Student at Florida Tech
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

Write a Class that allows the use of Complex numbers as objects. It should have the following operations: toString abs plus times theta minus conjugate divides power

Jeremy G.
Answer:

public class Complex { private final double re; // the real part private final double im; // the imaginary part public Complex(final double real, final double imag) { re = real; im = imag; } public final double theta () { return Math.atan2(this.im, this.re); } public final Complex minus (final Complex num) { return new Complex(this.re - num.re, this.im - num.im); } public final Complex conjugate () { return new Complex(this.re, this.im * -1); } public final Complex divides (final Complex num) { final double realPart; final double imagPart; realPart = ((this.re * num.re) + (this.im * num.im)) / ((num.re * num.re) + (num.im * num.im)); imagPart = -1 * ((this.re * num.im) - (this.im * num.re)) / ((num.re * num.re) + (num.im * num.im)); return new Complex(realPart, imagPart); } public final Complex power (final int b) { if (b == 0) { return new Complex(1, 0); } else if (b == 1) { return this; } else { return this.times(this.power(b - 1)); } } public final Complex squareRoot () { final double r = Math.hypot(this.re, this.im); final double theta = this.theta(); return new Complex(Math.sqrt(r) * Math.cos(theta / 2), Math.sqrt(r) * Math.sin(theta / 2)); } public final String toString () { return String.format("%.2f%c%.2fi", re, im >= 0 ? '+' : '-', Math.abs(im)); } public final double abs () { // Math.sqrt(re*re + im*im) return Math.hypot(re, im); } public final Complex plus (final Complex b) { final double real = re + b.re; final double imag = im + b.im; return new Complex(real, imag); } public final Complex times (final Complex b) { final double real = re * b.re - im * b.im; final double imag = re * b.im + im * b.re; return new Complex(real, imag); } }

Discrete Math
TutorMe
Question:

In the game of Scrabble a player has 7 tiles with letters on them. How many combinations of 5 tiles can the player make (assume all letters are different)?

Jeremy G.
Answer:

The question asks for combinations of 7 items taken 5 at a time, for which we can use the binomial coefficient which is defined as follows $$_nC_k=\frac{n!}{k!\left(n-k\right)!}$$ So substituting we get $$_7C_5=\frac{7!}{5!2!}$$ expanding using the definition of factorial $$\frac{7*6*5*4*3*2*1}{5*4*3*2*2*1*1}$$ $$\frac{7*6}{2}$$ $$21$$

Calculus
TutorMe
Question:

The error function $$erf(x) = \frac{2}{ \sqrt{\pi} } \int_{0}^{x} e^{-t^2} dt$$ is used in probability, statistics, and engineering. (a) Show that $$\int_{a}^{b} e^{-t^2} dt = \frac{1}{2} \sqrt{\pi} [erf(b) - erf(a)]$$ (b) Show that the function $y=e^{x^2} erf(x)$ satisfies the following differential equation $$y' = 2xy + \frac{2}{\sqrt{\pi}}$$

Jeremy G.
Answer:

(a) First we use the given definition of the error function and substitute on the right side to get $$\frac{1}{2} \sqrt{\pi} \left[\left(\frac{2}{ \sqrt{\pi} } \int_{0}^{b} e^{-t^2}dt\right) - \left(\frac{2}{ \sqrt{\pi} } \int_{0}^{a} e^{-t^2}\right)dt\right]$$ We can factor out the $\frac{2}{\sqrt{\pi}}$ from the integral terms which will cancel with the $\frac{\sqrt{\pi}}{2}$ on the outside, which simplifies the whole expression to just $$\left(\int_{0}^{b} e^{-t^2}dt\right) - \left(\int_{0}^{a} e^{-t^2}dt\right)$$ We get from the properties of integrals $$\int_{a}^{b}f(x)dx = -\int_{b}^{a}f(x)dx$$ and $$\int_{x}^{n}f(t)dt + \int_{n}^{y}f(t)dt = \int_{x}^{y}f(t)dt$$ therefore: $$\left(\int_{0}^{b} e^{-t^2}dt\right) + \left(\int_{a}^{0} e^{-t^2}dt\right)$$ $$\int_{a}^{b} e^{-t^2} dt$$ (b) We will divide out the $e^{x^2}$ factor to get the error function on its own side. We can use implicit differentiation on the left side, and the fundamental theorem of calculus on the right side. $$y=e^{x^2}erf(x)$$ $$\frac{y}{e^{x^2}}=erf(x)$$ We'll invoke the definition of the error function and take the derivative of both sides $$\frac{d}{dx}\left[\frac{y}{e^{x^2}}\right]=\frac{d}{dx}\left[\frac{2}{ \sqrt{\pi} } \int_{0}^{x} e^{-t^2} dt\right]$$ The derivative operator is a \textit{linear operator} meaning we can take the constant $\frac{2}{\sqrt{\pi}}$ factor and move it to the outside of the derivative $$\frac{d}{dx}\left[\frac{y}{e^{x^2}}\right]=\frac{2}{ \sqrt{\pi} }\frac{d}{dx}\left[\int_{0}^{x} e^{-t^2} dt\right]$$ First we'll work out the right side. From the Fundamental Theorem of Calculus we get $$\frac{d}{dx}\left[\int_{0}^{x}f(t)dt\right]=f(x)$$ therefore the right side reduces to $$\frac{2}{\sqrt{\pi}}e^{-x^2}$$ We'll write the left hand side as a product, and then take the derivative using the product rule, chain rule, and implicit differentiation $$\frac{d}{dx}\left[ye^{-x^2}\right]$$ $$y'e^{-x^2}-2xye^{-x^2}$$ then to bring it all together $$y'e^{-x^2}-2xye^{-x^2}=\frac{2}{\sqrt{\pi}}e^{-x^2}$$ We divide out the $e^{-x^2}$ term and do some algebraic manipulation to get to the solution $$y'-2xy=\frac{2}{\sqrt{\pi}}$$ $$y'=2xy+\frac{2}{\sqrt{\pi}}$$

Send a message explaining your
needs and Jeremy will reply soon.
Contact Jeremy
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.