D
D
Dragon12020-10-16 10:27:38
Java
Dragon1, 2020-10-16 10:27:38

How to write a validation condition for a function?

I need a domain of definition, I am writing a program that displays the value of the start point x + step and calculates the value of the function to the end point, I need to write a condition when the error "function is undefined" will be displayed and when the value will be calculated by the formula.
5f894b475a1e7457080488.jpeg
I am writing in java (beginner, only scanner, loops, data types, formatted output)
For example, x initial = 1, x final = 10, step s = 1
There will be similar values ​​(taken from another function:
1.00 not defined
2.00 not defined
3.00 not defined
4.00 1.41
5.00 1.43
6.00 2.12
7.00 not defined
8.00 not defined
9.00 not defined
10.00 2.30

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2020-10-16
@Dragon1

This function is not defined for x < 0 or 1-cos(x) = 0. I.e. If x < 0 or x= pi/2+2pi*k.
In the program, calculate the function in steps. First, the denominator, if it turned out to be 0 - not defined. Otherwise, see that the numerator can be calculated (x>=0).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question