# Finding same output values by varying input values of function

I have written a function in Mathematica that needs five input variables. The function outputs a single real number. The underlying model is a complex model for option pricing. To ease things up, let me define it in a similar way with the built-in FinancialDerivative function (Black-Scholes model) instead of my model:

calcImpVol[Maturity_, riskfree_, v1_, v2_, v3_] :=
FinancialDerivative[{"European", "Call"}, {"StrikePrice" -> v1,
"Expiration" -> Maturity,
"Value" -> v3}, {"InterestRate" -> riskfree,
"CurrentPrice" -> v2, "Dividend" -> 0.0}, "ImpliedVolatility"];


The values of Maturity and riskfree are fixed: Maturity = 2 and riskfree = 0.03. furthermore, v1 and v2 can be any positive real number and 0$\leq$v3 $\leq$ v2.

I would like to find all values of v1, v2, and v3 for which the output values of calcImpVolare more or less the same for the given input values, i.e. differ with a maximum of 0.5 from a target value: [targetOutput-.5,targetOutput+.5].

I want to use Mathematica to iterate in an efficient way to find values of the other three variables, v1 - v3, that yield the required results. I would like to store all of these combinations of the four variables, along with the respective calcImpVolvalue.

I could think of using loops by iterating over all combinations of v1 - v3 using Tuples and then manually keep all combinations that output results in the target interval. This process would takes hours, so there's got to be a smarter way. Could anyone help me with an efficient implementation of this problem?

• can the function be rewritten as MyFunc[v1_, v2_,g_] where g is equal to Total[ v3_, v4_, v5_, v6_]? – Alucard Aug 18 '17 at 12:42
• More generally, are there any constraints on the input variables? You talk about Tuples, does that mean that only discrete values are allowed? Without more information it might be impossible to help you. (Consider for example a function with chaotic behavior - there is no way to achieve what you're after in this case) – Lukas Lang Aug 18 '17 at 13:01
• I have edited the question. This should give more information about what I want to achieve. – Peter Lawrence Aug 18 '17 at 13:10
• If v2 is positive, do you mean $0\le v3 \le v2$? – John Joseph M. Carrasco Aug 18 '17 at 14:43
• Excuse me, I made a typo there. You are correct, I have edited the question – Peter Lawrence Aug 18 '17 at 15:08