# Multivariate function won't evaluate

When I define the following variables and function and then evaluate that function at given values:

c = 3*10^10;
k = 1.381*10^-16;
h = 6.626*10^-27;

g[x1_, x2_, x3_, x4_, x5_, x6_] = (2*h*c^2)/(x2^5*x6)*(x3 + x4*x1 + x5/2*x1^2)^-1 + 1.

g[0.2, 3737, 0.1435, 0.9481, -0.0920, 42.0*10^13]


I get the following output:

1. + 0.0000119268/(x2^5 (x3 + x1 x4 + (x1^2 x5)/2) x6)

1.


I tried a simpler function to see if I get the same output and I did. I entered the following:

h1[x_, y_] = Log[x + y];
h1[1, 1]


which yielded Log[2]

What is going on here?

• Welcome to the forum! There are some fundamental differences in how the Wolfram Language works compared to other languages that you may already be familiar with. I suggest that you read the guides here, reference.wolfram.com/language/tutorial/Numbers.html, and here reference.wolfram.com/language/tutorial/…. Mar 4, 2022 at 1:11
• Please note that it is not equal to 1, Rationalize[g[1, 1, 1, 1, 1, 1], 0]==62255051/62254754 Mar 4, 2022 at 1:12
• Welcome to Mma SE. To get started:1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking checkmark sign, 4) give help too, by answering questions in your areas of expertise.
– user49048
Mar 4, 2022 at 1:41
• And an added comment, these numbers are a bit familiar. They remind me of quantum mechanics stuff or quantum field theory stuff. Should that be the case, you can also work in Natural Units and make your life easier with the constants
– user49048
Mar 4, 2022 at 2:42
• What is the different result you were expecting? Mar 4, 2022 at 14:42

To understand what's going on, I think I have understood the question of the OP correctly, I think it's educational to do the computation step by step, while keeping in mind the comment by @cvgmt.

If you sub in all the values except for the x6 you have the following:

((2*h*c^2)/(x2^5*x6)*(x3 + x4*x1 + x5/2*x1^2)^-1 + 1.) /.
x1 -> 0.2 /. x2 -> 3737 /. x3 -> 0.1435 /. x4 -> 0.9481 /.
x5 -> -0.0920 // Rationalize


1 + 4.93984*10^-23/x6

Now, if we check

4.939843951797836*^-23/x6 /. x6 -> (42.0*10^13)


we get

1.17615*10^-37

So, we want Mathematica to keep this and not Chop it to zero.

Borrowing the code from the wondeful answer by kirma

ClearAll@RationalizedN;
SetAttributes[RationalizedN, HoldFirst];
RationalizedN[expr_, n_: \$MachinePrecision] :=
N[FixedPoint[
ReleaseHold@*
ReplaceAll[
x_ :> RuleCondition[Hold@Evaluate@Rationalize[x, 0],
InexactNumberQ@Unevaluated@x]], Hold@expr], n];


we can run the following

RationalizedN[g[0.2, 3737, 0.1435, 0.9481, -0.0920, 42.0*10^13], 50]


which yields

1.0000000000000000000000000000000000001176153321857`