Tag Info

New answers tagged


You could use Function[{args1, var2, var3}, With[{deg = args1[[1]], knots = args1[[2]]}, code ]] Not the neatest, but it would seem to do the job.


The problem with your original code is that the order argument you specified (4) is in fact not the same as the order of the midpoint method (2). Thus: MidpointCoefficients[2, prec_] := N[{{{1/2}}, {0, 1}, {1/2}}, prec]; For comparison purposes, here's the Butcher table for Heun's method: HeunCoefficients[2, prec_] := N[{{{1}}, {1/2, 1/2}, {1}}, prec]; ...


The problem is with the behaviour of Set. Consider the following example: a = {1,2,3,4,5}; a[[2;;]] = {1,2,3,4} a[[3;;]] = {1,2,3,4} a[[4;;]] = {1,2,3,4} a[[5;;]] = {1,2,3,4} Notice that in the [[2;;]] part, Mathematica decides you want to replace elements 2, 3, 4 and 5 of a with the corresponding elements 1, 2, 3, 4 rather than all with the list ...


I remember reading somewhere that everytime I use =, Mathematica copies an expression in the memory (which may be slow and inefficient). This is not quite true, as written here. Mathematica uses a copy-on-write behaviour, i.e. it will only create an actual copy of a datastructure if you modify it. Example: a = {1,2,3}; As this is evaluated, first ...


An alternative solution would be changing the myfun14[list_] to myfun14[list_ /; VectorQ[list, NumberQ]], the result can be obtained after a few seconds. Setting a high AccuracyGoal is also necessary to get the correct answer for the problem.

Top 50 recent answers are included