Assignment 1 Derivative calculator solved

$24.99 $18.99

In this assignment, you need to complete a derivative calculator independently. Submissions before the deadline xx:xx:xx are treated as normal submissions. Function Requirement In test A, each math expression includes “+”, “-”, “*”, “^”(see the example below) x only appears once in each term of a polynomial x will be the only variable, there will…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

In this assignment, you need to complete a derivative calculator independently.

Submissions before the deadline xx:xx:xx are treated as normal submissions.

Function Requirement

In test A, each math expression includes “+”, “-”, “*”, “^”(see the example below)

  1. x only appears once in each term of a polynomial

  1. x will be the only variable, there will be no more than variables like y, z appear.

  1. x will not be the power term

  1. All constant numbers are integer, with no float (doubles).

  1. The answer should be compact, i.e. no space within bits.

  1. There will be no “(“ and “)” (brackets)

  1. Space can appear in test A

  1. In test A, all expressions are valid.

  1. Tab will not be tested in oj.

  1. Neglect “^1” when the answer power is 1. Example 3: 35*x^6+16*x-6 However, “x^1” can appear in test.

An example of an input file for test A

Expected output file:

x

1

x^2

2*x

5 * x ^ 7+ 8 * x ^ 2 – 6 *x^1

35*x^6+16*x-6

In test B, all requirements in test A should be satisfied, plus:

  1. (no more than 2) functions including “sin” (sine function), “cos” (cosine function), the function must use a bracket to include variable x both in input and output

2. sin and cos are compact without space splited (i.e. no “s i n (x) ”

situation) .

  1. (“ and “)” (brackets);

  1. In test B, the expression may not be valid. When the answer is invalid, return string “invalid”

  1. Please don’t use any product-to-sum formula or sum-to-product formula.

  1. When there is no need to use the bracket, don’t use it, save it (example 2: -sin(sin(45*x))*cos(45*x) ).

  1. The chain rule should follow expanding from the outside to the inside

  1. ++”, “+-”, “- -” not allowed

  1. *-constant” is viewed as the valid answer, when you take derivative f(−w x + b) in chain rule.

The answer is fw.

  1. +(-”, “-(-” is no need to simplify. Example 3: cos(x)-(-sin(4*x)), more example cos(cos(x))→sin(cos(x))*(-sin(x))

  2. Invalidation occurs only if square brackets do not appear in pairs. Other invalid will not be tested in oj.

An example of an input file for test B

Expected output file:

1+ 2.0 * sin(x)

2*cos(x)

cos( sin (45 * x) )

-sin(sin(45*x))*cos(45*x)

sin(x)-cos(4*x)

cos(x)-(-sin(4*x))

sin(35-cos(4*x)) + cos(cos(x))

cos(35-cos(4*x))*(-sin(4*x))*4-sin(cos(x))*(-sin(x))

5*((3x+4)+8

invalid

sin(x)-cos(4*x)

cos(x)-1*(-sin(4*x))*4

Assignment 1 Derivative calculator 2

Assignment 1 Derivative calculator solved
$24.99 $18.99