0
$\begingroup$

The first code here.

x = 100;
list4 = Table[i^2, {i, 3, x}]; list5 = Table[3 i, {i, 3, x}];
Transpose[{list4, list5}] // FindFormula

Output:

3. #1^0.5 &

The second one

x = 1000;
list4 = Table[i^2, {i, 3, x}]; list5 = Table[3 i, {i, 3, x}];
Transpose[{list4, list5}] // FindFormula

Output:

\!\(
TagBox[GridBox[{
{"\[Piecewise]", GridBox[{
{
RowBox[{
RowBox[{"-", "215.59113232341036`"}], "-", 
RowBox[{"462.8447599959154`", " ", 
RowBox[{"Log", "[", 
RowBox[{
RowBox[{"-", "1.`"}], "+", "#1"}], "]"}]}], "+", 
RowBox[{"510.22846254395745`", " ", 
RowBox[{"Log", "[", "#1", "]"}]}], "+", 
RowBox[{"0.0076258318162933944`", " ", "#1"}]}], 
RowBox[{"9.`", "<=", "#1", "<", "63221.253155283164`"}]},
{
RowBox[{
RowBox[{"-", "3396.8684645398685`"}], "+", 
RowBox[{"365.162688790241`", " ", 
RowBox[{"Log", "[", "#1", "]"}]}], "+", 
RowBox[{"0.0014401159532839128`", " ", "#1"}]}], 
RowBox[{"63221.253155283164`", "<=", "#1", "<", "705500.890275878`"}]},
{
RowBox[{
RowBox[{"-", "7319.177400203924`"}], "+", 
RowBox[{"687.8323472075917`", " ", 
RowBox[{"Log", "[", "#1", "]"}]}], "+", 
RowBox[{"0.0008165452390911563`", " ", "#1"}]}], 
RowBox[{"705500.890275878`", "<=", "#1", "<", "1.`*^6"}]},
{"0", 
TagBox["True",
"PiecewiseDefault",
AutoDelete->True]}
},
AllowedDimensions->{2, Automatic},
Editable->True,
GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{1.}}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.84]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}},
Selectable->True]}
},
GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{1.}}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.35]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}}],
"Piecewise",
DeleteWithContents->True,
Editable->False,
SelectWithContents->True,
Selectable->False,
StripWrapperBoxes->True]\)

Is there a means for me find the exact Formula after I set x to 1000?

$\endgroup$
2
  • $\begingroup$ For exact, use FindSequenceFunction[Transpose[{list4, list5}]]... $\endgroup$
    – ciao
    Commented Dec 26, 2019 at 6:29
  • $\begingroup$ How can I achieve that with FindFormula? @ciao $\endgroup$
    – kile
    Commented Dec 26, 2019 at 6:44

2 Answers 2

1
$\begingroup$
Clear["Global`*"]

FindFormula uses a randomized approach with the allowed TargetFunctions {Plus, Times, Power, Sin, Cos, Tan, Cot, Log, Sqrt, Csc, Sec, Abs, Exp} within the TimeConstraint. Using a large number of data points uses the available time dealing with all of the data. Generally, it is better to limit the amount of data used. Alternatively, restrict the set of TargetFunctions and increase the TimeConstraint. Because the approach is randomized, you generally need to specify the RandomSeeding option to get reproducible results.

x = 1000;
list4 = Table[i^2, {i, 3, x}]; list5 = Table[3 i, {i, 3, x}];

f1 = With[{n = 10},
   Transpose[{list4[[1 ;; n]], list5[[1 ;; n]]}] // 
    FindFormula[#, RandomSeeding -> 1234] &] // Rationalize

(* 3 Sqrt[#1] & *)

f2 = Transpose[{list4, list5}] //
   FindFormula[#,
     TargetFunctions -> {Times, Power},
     TimeConstraint -> 15,
     RandomSeeding -> 1234] & //
  Simplify

enter image description here

$\endgroup$
2
  • $\begingroup$ What's the meaning of "1234"? why do you choose RandomSeeding ->1234? Does that mean a specific formula to solve this? How about set the value of RandomSeeding to 123? Is that gonna be okay? $\endgroup$
    – kile
    Commented Dec 26, 2019 at 15:32
  • $\begingroup$ As stated in the documentation for RandomSeeding, "use an explicit integer or string as a seed". It doesn't matter what you use since the intent is just to enable starting at the same point and being able to reproduce the results. $\endgroup$
    – Bob Hanlon
    Commented Dec 26, 2019 at 16:05
0
$\begingroup$

It seems to work properly

x = 100;
list4 = Table[i^2, {i, 3, x}]; list5 = Table[3 i, {i, 3, x}];
data = Transpose[{list4, list5}];
fy = FindFormula[data, y]
Show[ListPlot[data, PlotStyle -> Red], Plot[fy, {y, 0, 10000}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.