New answers tagged

2

Like this, P[g_] := h[#]/h[0.5] & /. NDSolve[{h''[x] == g[x], h[0] == 0, h[1] == 0}, h, {x, 0, 1}][[1]] or like this P[g_] := With[{h = NDSolveValue[{h''[x] == g[x], h[0] == 0, h[1] == 0}, h, {x, 0, 1}]}, h[#]/h[.5] &] Both evaluate as expected, P[f][.5] (* 1. *)


1

It's unclear what exactly is an input but here's my interpretation: ClearAll[f] f[x_, y_] := 3.23425124` x^2 + 5.8978587` y; f[2, 3] 30.6306 DownValues[f] = DownValues[f] /. n_?NumericQ :> RuleCondition@Round[n, 0.1]; f[2, 3] 30.5


3

3.23425124` x^2 + 5.8978587` y /. Times[a_, b_] :> Times[Round[a, 0.1], b] (*3.2 x^2 + 5.9 y*) coefficient * variable is of Times[coefficient, variable] in full form, therefore you can use this pattern to match and round only the coefficient.



Top 50 recent answers are included