#include <cmath>
#include <iostream>
using namespace std;
struct Function {
double a = 0;
double x = 0;
void args(const double _a, const double _x) {
a = _a;
x = _x;
}
private:
double f() const {
if (a > 0) return 2.0 * a * x + fabs(a - 1.0);
return exp(x) / sqrt(1.0 + pow(a, 2)) - 1.0;
}
friend ostream& operator<<(ostream& out, const Function& table) {
if (table.a <= 0) {
cout.setf(ios::fixed);
cout.precision(15);
}
return out << table.f();
}
};
double input(const char* prompt) {
cout << prompt;
double value;
cin >> value;
cin.ignore(0x1000, '\n');
return value;
}
int main() {
const auto x = input("x: ");
const auto a = input("a: ");
Function fn;
fn.args(a, x);
cout << "f(a, x) = " << fn << '\n';
}