1

I have the following expression:

enter image description here

I initalize the variables:

capital = 1200; rate = 0.02; time = 6; period = 12; 

and then run for second term, for example:

HoldForm[c (1 + r*t)] /. {c -> capital, r -> rate, 
  t -> Internal`RationalNoReduce[n, m] /. {n -> time, m -> period}}

I get

enter image description here

I receive the same result if I use Inactivate or Unevaluated beforehand. It is necesary that the fraction 6/12 does not get simplified to 1/2. This result is not exactly what I want but it is enough for me. But when I enter that instruction in a Row function, I get a different output:

enter image description here

First multiplication symbol × disappears, better, but second make easier to read expression. I have tried with FractionBox, but no difference. I use version 12.3.1 for Windows and Linux

user64494
  • 26,149
  • 4
  • 27
  • 56

2 Answers2

3

You're looking for AutoMultiplicationSymbol:

Row@{
  Style[
   HoldForm[1200 (1 + (0.02 6)/12)],
   AutoMultiplicationSymbol -> {"Numbers"}
   ]
  }

enter image description here

Note how this solves both the missing symbol inside Row, and the unwanted symbol before the parentheses (you can check the documentation page for other settings for where to include the symbol).

Lukas Lang
  • 33,963
  • 1
  • 51
  • 97
0

You did not write what your aim is. Depending on that, one selects the solution. I guess that you need it for some demonstration. If this is right, I propose instead of HoldForm, using the figures in the form of strings. Then they do not cancel with one another. For example, this is the definition of your parameters:

capital = 1200; rate = 0.02; time = 6; period = 12;

Let us introduce a rule:

rule = {c -> capital, r -> rate, n -> time, m -> period} /. 
  Rule[a_, b_] :> Rule[a, ToString[b]]

(* {c -> "1200", r -> "0.02", n -> "6", m -> "12"} *)

Here it is clearly seen that each figure is s string. However, this is not visible in Mathematica. There they look as usual figures.

Here is your calculation

c (1 + r*n/m) /. rule

(* "1200" (1 + ("0.02" "6")/("12")) *)

Again, in Mathematica, the output looks as follows:

enter image description here

I hope it helps. Have fun!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96