Complex Function - NoaAizer/OOP_Ex1 GitHub Wiki

This class is an implemention of complex_function interface.
This class represents a complex function that have a left and right branches, with an operator in the middle. Each complex function have these three fields: leftFunc, rightFunc, op.
Each branch can be a complex function by itself.

The functions-

Constructors:
We have 6 constructors for complex function: one for each place the operator can be in (first, second, third). The constructors also handle the cases which in the operator can appears as a String, also in each place.
We have a constructor that builds a complex function from a Polynom, a Monom, a complex function and a function.

plus- sums up the leftFunc and the rightFunc
mul- multiplies the leftFunc by the rightFunc
div- divides the leftFunc by the rightFunc
max- returns the max value between the leftFunc and the rightFunc
min- returns the min value between the leftFunc and the rightFunc
comp- returns the function composition of this leftFunc on this rightFunc
left- returns the leftFunc
right- returns the rightFunc
getOp- returns the operation of this complex function
f(x)- computes the value of this complex function with the given value
initFromString- creates a complex function from a given String
copy- deep copies this complex function
toString- prints to user this complex function.

equals- checkes if two complex functions are eqauls. while we were working on this project, we found out that it is impossible for us to determine if two function are equals by a String (factors can divided by each other etc.)-
The best way to test if two complex functions are equals is to check if their values with a few different numbers are equals. So we built a visual equals function to determine if it's true or false, checking all the values between -1 to 1, each time increasing the number by 0.0000001 (Epsilon)

  • Note: In most cases this system is working, except when the two functions are equal between x= -1 and x= 1 but in the other x values they have different values.
⚠️ **GitHub.com Fallback** ⚠️