i have 2 sets x [xmin,xmax] , y [ymin, ymax] , execute function going stepwise min max values of x , y. want apply function cartesian product of x , y. save each combination row csv file. i've been trying time do loop, got bit stuck on how create list in end. instance:
for x: 1 thru 2 step 1 y: 1 thru 2 step 1 print([x,y,find_root (exp(a*x) = y, a, 0, 1)]) i'd values of x , y , function of combinations, struggle save , export csv, because don't know how create list [[1,1,function(1,1)],[1,2,function(1,2)],[2,1,function(2,1)],[2,2,function(2,2)]], export write_data.
alternatively, i'd use:
xlist:makelist(x,x,1,2,1); ylist:makelist(y,y,1,2,1); create_list([x,y,x^y],x,xlist,y,ylist); in case don't know how include function in create list or how use map.
how do above or there better way?
about speeding construction of 1 million item list, how solving equation once , substituting values of x , y? e.g.:
solve (exp(a*x) = y, a); my_solution : rhs (first (%)); create_list ([x, y, ev (my_solution)], x, xlist, y, ylist); here ev evaluates my_solution current values of variables contains (namely x , y).
about writing csv file, try this:
write_data (my_list, "my_output_file", 'comma);
Comments
Post a Comment